Updated some javadoc in org.eclipse.linuxtools.tmf.core plug-in
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfEventField.java
index 88c55e10044e216e95c5dcf8751871cbea9019c5..7793f0af7219477421095f9f8698d70906bc9b74 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 import org.eclipse.linuxtools.ctf.core.event.types.ArrayDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
+import org.eclipse.linuxtools.ctf.core.event.types.FloatDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration;
@@ -23,7 +24,11 @@ import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 
 /**
- * <b><u>CTFEventField</u></b>
+ * The CTF implementation of the TMF event field model 
+ * 
+ * @version 1.0
+ * @author Matthew khouzam
+ * @author Alexandre Montplaisir
  */
 public abstract class CtfTmfEventField implements ITmfEventField {
 
@@ -37,8 +42,12 @@ public abstract class CtfTmfEventField implements ITmfEventField {
     // Constructors
     // ------------------------------------------------------------------------
 
+    /**
+     * Constructor for CtfTmfEventField.
+     * @param name String
+     */
     protected CtfTmfEventField(String name) {
-        /* Strip the damn underscores, screw you CTF */
+        /* Strip the underscore*/
         if ( name.startsWith("_") ) { //$NON-NLS-1$
             this.name = name.substring(1);
         } else {
@@ -50,6 +59,11 @@ public abstract class CtfTmfEventField implements ITmfEventField {
     // Getters/Setters/Predicates
     // ------------------------------------------------------------------------
 
+    /**
+     * Method getName.
+     * @return String
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getName()
+     */
     @Override
     public String getName() {
         return this.name;
@@ -59,6 +73,12 @@ public abstract class CtfTmfEventField implements ITmfEventField {
     // Operations
     // ------------------------------------------------------------------------
 
+    /**
+     * Method parseField.
+     * @param fieldDef Definition
+     * @param fieldName String
+     * @return CtfTmfEventField
+     */
     public static CtfTmfEventField parseField(Definition fieldDef,
             String fieldName) {
         CtfTmfEventField field = null;
@@ -109,12 +129,20 @@ public abstract class CtfTmfEventField implements ITmfEventField {
                 field = new CTFIntegerArrayField(values, fieldName);
             }
             /* Add other Sequence types here */
+        } else if (fieldDef instanceof FloatDefinition){
+            FloatDefinition floatDef = (FloatDefinition) fieldDef;
+            field = new CTFFloatField( floatDef.getValue(), fieldName);
         }
-        /* Add other field types here */
+
 
         return field;
     }
 
+    /**
+     * Method copyFrom.
+     * @param other CtfTmfEventField
+     * @return CtfTmfEventField
+     */
     public static CtfTmfEventField copyFrom(CtfTmfEventField other) {
         switch (other.getFieldType()) {
         case 0:
@@ -126,11 +154,19 @@ public abstract class CtfTmfEventField implements ITmfEventField {
         case 2:
             return new CTFIntegerArrayField(
                     ((CTFIntegerArrayField) other).getValue(), other.name);
+        case 3:
+            return new CTFFloatField(
+                    ((CTFFloatField) other).getValue(), other.name);
         default:
             return null;
         }
     }
 
+    /**
+     * Method clone.
+     * @return CtfTmfEventField
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#clone()
+     */
     @Override
     public CtfTmfEventField clone() {
         return CtfTmfEventField.copyFrom(this);
@@ -138,45 +174,71 @@ public abstract class CtfTmfEventField implements ITmfEventField {
 
     /**
      * Return the int representing this field's value type
-     * 
-     * @return
-     */
+     *
+
+     * @return the field type */
     public abstract int getFieldType();
 
     /**
      * Return this field's value. You can cast it to the correct type depending
      * on what getFieldType says.
-     * 
-     * @return
+     *
+
+     * @return the field value * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue()
      */
     @Override
     public abstract Object getValue();
 
     /**
-     * @name Other methods defined by ITmfEventField, but not used here: the CTF
+     * Other methods defined by ITmfEventField, but not used here: the CTF
      *       fields do not have sub-fields (yet!)
-     */
+     *
 
+     * @return the field names * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getFieldNames()
+     */
     @Override
     public String[] getFieldNames() {
         return null;
     }
 
+    /**
+     * Method getFieldName.
+     * @param index int
+     * @return String
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getFieldName(int)
+     */
     @Override
     public String getFieldName(int index) {
         return null;
     }
 
+    /**
+     * Method getFields.
+     * @return ITmfEventField[]
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getFields()
+     */
     @Override
     public ITmfEventField[] getFields() {
         return null;
     }
 
+    /**
+     * Method getField.
+     * @param fieldName String
+     * @return ITmfEventField
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getField(String)
+     */
     @Override
     public ITmfEventField getField(String fieldName) {
         return null;
     }
 
+    /**
+     * Method getField.
+     * @param index int
+     * @return ITmfEventField
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getField(int)
+     */
     @Override
     public ITmfEventField getField(int index) {
         return null;
@@ -185,6 +247,8 @@ public abstract class CtfTmfEventField implements ITmfEventField {
 
 /**
  * <b><u>CTFIntegerField</u></b>
+ * @author ematkho
+ * @version $Revision: 1.0 $
  */
 final class CTFIntegerField extends CtfTmfEventField {
 
@@ -193,17 +257,28 @@ final class CTFIntegerField extends CtfTmfEventField {
     /**
      * A CTF "IntegerDefinition" can be an integer of any byte size, so in the
      * Java parser this is interpreted as a long.
+     * @param longValue long
+     * @param name String
      */
     CTFIntegerField(long longValue, String name) {
         super(name);
         this.longValue = longValue;
     }
 
+    /**
+     * Method getFieldType.
+     * @return int
+     */
     @Override
     public int getFieldType() {
         return 0;
     }
 
+    /**
+     * Method getValue.
+     * @return Long
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue()
+     */
     @Override
     public Long getValue() {
         return this.longValue;
@@ -211,7 +286,7 @@ final class CTFIntegerField extends CtfTmfEventField {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see java.lang.Object#toString()
      */
     @Override
@@ -222,21 +297,37 @@ final class CTFIntegerField extends CtfTmfEventField {
 
 /**
  * <b><u>CTFStringField</u></b>
+ * @author ematkho
+ * @version $Revision: 1.0 $
  */
 final class CTFStringField extends CtfTmfEventField {
 
     private final String strValue;
 
+    /**
+     * Constructor for CTFStringField.
+     * @param strValue String
+     * @param name String
+     */
     CTFStringField(String strValue, String name) {
         super(name);
         this.strValue = strValue;
     }
 
+    /**
+     * Method getFieldType.
+     * @return int
+     */
     @Override
     public int getFieldType() {
         return 1;
     }
 
+    /**
+     * Method getValue.
+     * @return String
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue()
+     */
     @Override
     public String getValue() {
         return this.strValue;
@@ -244,7 +335,7 @@ final class CTFStringField extends CtfTmfEventField {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see java.lang.Object#toString()
      */
     @Override
@@ -255,26 +346,46 @@ final class CTFStringField extends CtfTmfEventField {
 
 /**
  * <b><u>CTFIntegerArrayField</u></b>
+ * @author ematkho
+ * @version $Revision: 1.0 $
  */
 final class CTFIntegerArrayField extends CtfTmfEventField {
 
     private final long[] longValues;
 
+    /**
+     * Constructor for CTFIntegerArrayField.
+     * @param longValues long[]
+     * @param name String
+     */
     CTFIntegerArrayField(long[] longValues, String name) {
         super(name);
         this.longValues = longValues;
     }
 
+    /**
+     * Method getFieldType.
+     * @return int
+     */
     @Override
     public int getFieldType() {
         return 2;
     }
 
+    /**
+     * Method getValue.
+     * @return long[]
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue()
+     */
     @Override
     public long[] getValue() {
         return this.longValues;
     }
 
+    /**
+     * Method toString.
+     * @return String
+     */
     @Override
     public String toString() {
         StringBuffer buffer = new StringBuffer();
@@ -289,4 +400,48 @@ final class CTFIntegerArrayField extends CtfTmfEventField {
     }
 }
 
+/**
+ */
+final class CTFFloatField extends CtfTmfEventField {
+
+    Double value;
+    /**
+     * Constructor for CTFFloatField.
+     * @param value double
+     * @param name String
+     */
+    protected CTFFloatField(double value ,String name) {
+        super(name);
+        this.value = value;
+    }
+
+    /**
+     * Method getFieldType.
+     * @return int
+     */
+    @Override
+    public int getFieldType() {
+        return 3;
+    }
+
+    /**
+     * Method getValue.
+     * @return Object
+     * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue()
+     */
+    @Override
+    public Double getValue() {
+        return this.value;
+    }
+
+    /**
+     * Method toString.
+     * @return String
+     */
+    @Override
+    public String toString(){
+        return name + '=' + value;
+    }
+
+}
 /* Implement other possible fields types here... */
This page took 0.027259 seconds and 5 git commands to generate.