Clean up code.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 11 May 2012 21:49:09 +0000 (17:49 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 11 May 2012 23:02:32 +0000 (19:02 -0400)
16 files changed:
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/FloatDeclarationTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/FloatDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDeclaration.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java [new file with mode: 0644]
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java

index 4cb0a956c9c72992ff6ea61108a61452cb7002ba..94759fc5a9f16dbf8fd90b4d923366d2f7aff656 100644 (file)
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteOrder;
 
-import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
 import org.eclipse.linuxtools.ctf.core.event.types.FloatDeclaration;
 import org.junit.Test;
 
@@ -18,24 +17,23 @@ public class FloatDeclarationTest {
     @Test
     public void ctorTest() {
         for( int i = 1; i < 20; i++) {
-            fixture = new FloatDeclaration(i, 32-i, ByteOrder.nativeOrder(), Encoding.NONE, 0);
+            fixture = new FloatDeclaration(i, 32-i, ByteOrder.nativeOrder(),  0);
             assertNotNull(fixture);
         }
     }
 
     @Test
     public void getterTest() {
-        fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), Encoding.NONE, 0);
+        fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
         assertEquals( fixture.getAlignment(), 0);
         assertEquals( fixture.getByteOrder(), ByteOrder.nativeOrder());
-        assertEquals( fixture.getEncoding(), Encoding.NONE);
         assertEquals( fixture.getExponent(), 8);
         assertEquals( fixture.getMantissa(), 24);
     }
 
     @Test
     public void toStringTest() {
-        fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), Encoding.NONE, 0);
+        fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
         assertTrue(fixture.toString().contains("float")); //$NON-NLS-1$
     }
 }
index d6c22d61a0b33276645fad3bd30f4d6f4447b872..8513f2e4f01aef628d1b7a9e8f996434d2029910 100644 (file)
@@ -6,7 +6,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteOrder;
 
-import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
 import org.eclipse.linuxtools.ctf.core.event.types.FloatDeclaration;
 import org.eclipse.linuxtools.ctf.core.event.types.FloatDefinition;
 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
@@ -64,8 +63,8 @@ public class FloatDefinitionTest {
 
     @Test
     public void testFloat248() {
-        parent = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), Encoding.NONE, 0);
-        singleFixture = (FloatDefinition) parent.createDefinition(null, fieldName);
+        parent = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
+        singleFixture = parent.createDefinition(null, fieldName);
         assertNotNull(singleFixture);
     }
 
@@ -73,8 +72,8 @@ public class FloatDefinitionTest {
 
     @Test
     public void testFloat5311() {
-        parent = new FloatDeclaration(11, 53, ByteOrder.nativeOrder(), Encoding.NONE, 0);
-        doubleFixture = (FloatDefinition) parent.createDefinition(null, fieldName);
+        parent = new FloatDeclaration(11, 53, ByteOrder.nativeOrder(), 0);
+        doubleFixture = parent.createDefinition(null, fieldName);
         assertNotNull(doubleFixture);
     }
 
@@ -82,8 +81,8 @@ public class FloatDefinitionTest {
     public void testFloat32Bit(){
         for(int i = 1; i < 31 ; i++)
         {
-            parent = new FloatDeclaration(i, 32-i, ByteOrder.nativeOrder(), Encoding.NONE, 0);
-            fixture = (FloatDefinition) parent.createDefinition(null, fieldName);
+            parent = new FloatDeclaration(i, 32-i, ByteOrder.nativeOrder(), 0);
+            fixture = parent.createDefinition(null, fieldName);
             assertNotNull(fixture);
             fixture.setValue(2.0);
             assertTrue(fixture.toString().contains("2")); //$NON-NLS-1$
@@ -94,8 +93,8 @@ public class FloatDefinitionTest {
     public void testFloat64Bit(){
         for(int i = 1; i < 63 ; i++)
         {
-            parent = new FloatDeclaration(i, 64-i, ByteOrder.nativeOrder(), Encoding.NONE, 0);
-            fixture = (FloatDefinition) parent.createDefinition(null, fieldName);
+            parent = new FloatDeclaration(i, 64-i, ByteOrder.nativeOrder(), 0);
+            fixture = parent.createDefinition(null, fieldName);
             assertNotNull(fixture);
             BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
             fixture.read(input);
@@ -106,8 +105,8 @@ public class FloatDefinitionTest {
 
     @Test
     public void testFloat48Bit(){
-        parent = new FloatDeclaration(12, 32, ByteOrder.nativeOrder(), Encoding.NONE, 0);
-        fixture = (FloatDefinition) parent.createDefinition(null, fieldName);
+        parent = new FloatDeclaration(12, 32, ByteOrder.nativeOrder(), 0);
+        fixture = parent.createDefinition(null, fieldName);
         assertNotNull(fixture);
         BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
         fixture.read(input);
index 1b8a11c90552c5e4c13b7f7648ac5020b76a34be..16e49198ecdb93bf3fcce398619b540450b0be9e 100644 (file)
@@ -91,7 +91,7 @@ public class VariantDefinitionTest {
         VariantDeclaration varDec = new VariantDeclaration();
         EnumDeclaration tagDec = new EnumDeclaration(iDec);
         ArrayDeclaration arrDec = new ArrayDeclaration(2, iDec);
-        FloatDeclaration fDec = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, Encoding.NONE, 8);
+        FloatDeclaration fDec = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 8);
         tagDec.add(0, 1, ENUM_1);
         tagDec.add(2, 3, ENUM_2);
         tagDec.add(4, 5, ENUM_3);
index fc727a155ef9600488eb63d3fb1c4b06fedc1c5b..0af919f6c215ead6462a9158d44588dd2345af56 100644 (file)
@@ -14,11 +14,24 @@ package org.eclipse.linuxtools.ctf.core.event;
 
 import java.util.HashMap;
 
+/**
+ */
 public class CTFClock {
 
+    /**
+     * Field properties.
+     */
     final private HashMap<String, Object> properties = new HashMap<String, Object>();
+    /**
+     * Field name.
+     */
     private String name;
 
+    /**
+     * Method addAttribute.
+     * @param key String
+     * @param value Object
+     */
     public void addAttribute(String key, Object value) {
         this.properties.put(key, value);
         if (key.equals("name")) { //$NON-NLS-1$
@@ -26,10 +39,19 @@ public class CTFClock {
         }
     }
 
+    /**
+     * Method getName.
+     * @return String
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Method getProperty.
+     * @param key String
+     * @return Object
+     */
     public Object getProperty(String key) {
         return properties.get(key);
     }
index e8f833b06154ca24059b6de0d08477cada107e0d..8a118a464fabf700227e99492cf50625b18e4ba8 100644 (file)
@@ -90,7 +90,7 @@ public class EventDeclaration {
     public synchronized static EventDeclaration getLostEventDeclaration(){
         EventDeclaration lostEvent = new EventDeclaration();
         lostEvent.fields = new StructDeclaration(1);
-        lostEvent.id = (long) -1;
+        lostEvent.id = -1L;
         lostEvent.name = "Lost event"; //$NON-NLS-1$
         return lostEvent;
     }
index afc14bff55fd274e3a8405b27ec224e19d413d13..455d6a849516caffa52da90a4fcc99dfed8b85df 100644 (file)
@@ -54,7 +54,7 @@ public class EventDefinition implements IDefinitionScope {
     /**
      * The StreamInputReader that reads this event definition.
      */
-    public final StreamInputReader streamInputReader;
+    private final StreamInputReader streamInputReader;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -150,32 +150,33 @@ public class EventDefinition implements IDefinitionScope {
 
     @Override
     public String toString() {
-        HashMap<String, Definition> f;
+        HashMap<String, Definition> definitions;
         List<String> list;
-        StringBuilder b = new StringBuilder();
+        StringBuilder retString = new StringBuilder();
+        final String cr = System.getProperty("line.separator");//$NON-NLS-1$
 
-        b.append("Event type: " + declaration.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-        b.append("Timestamp: " + Long.toString(timestamp) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+        retString.append("Event type: " + declaration.getName() + cr); //$NON-NLS-1$
+        retString.append("Timestamp: " + Long.toString(timestamp) + cr); //$NON-NLS-1$
 
         if (context != null) {
-            f = context.getDefinitions();
+            definitions = context.getDefinitions();
             list = context.getDeclaration().getFieldsList();
 
             for (String field : list) {
-                b.append(field + " : " + f.get(field).toString() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                retString.append(field + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
             }
         }
 
         if (fields != null) {
-            f = fields.getDefinitions();
+            definitions = fields.getDefinitions();
             list = fields.getDeclaration().getFieldsList();
 
             for (String field : list) {
-                b.append(field + " : " + f.get(field).toString() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                retString.append(field + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
             }
         }
 
-        return b.toString();
+        return retString.toString();
     }
 
 }
index 52ea6ef36643245a2e6c5bd34a26dfc9a2b587c9..a1966116071cb26281074de145bb7c6a00e142b6 100644 (file)
@@ -23,13 +23,13 @@ public abstract class Definition {
     // Attributes
     // ------------------------------------------------------------------------
 
-    /* The name of the field in its container */
+    /** The name of the field in its container */
     protected final String fieldName;
 
-    /* The complete path of this field */
+    /** The complete path of this field */
     protected final String path;
 
-    /*
+    /**
      * The definition scope in which this definition is found.
      *
      * The complete path of a definition is thus the path of the definition
index 5576e3fdf4467798f6445ec3b69246d79e9a0a9c..293528f2769e27a48ecaac028304fb2843ff35af 100644 (file)
@@ -23,7 +23,6 @@ public class FloatDeclaration implements IDeclaration {
     private final int mant;
     private final int exp;
     private final ByteOrder byteOrder;
-    private final Encoding encoding;
     private final long alignment;
 
     // ------------------------------------------------------------------------
@@ -31,11 +30,10 @@ public class FloatDeclaration implements IDeclaration {
     // ------------------------------------------------------------------------
 
     public FloatDeclaration(int exponent, int mantissa, ByteOrder byteOrder,
-            Encoding encoding, long alignment) {
+            long alignment) {
         mant = mantissa;
         exp = exponent;
         this.byteOrder = byteOrder;
-        this.encoding = encoding;
         this.alignment = alignment;
 
     }
@@ -65,13 +63,6 @@ public class FloatDeclaration implements IDeclaration {
         return byteOrder;
     }
 
-    /**
-     * @return the encoding
-     */
-    public Encoding getEncoding() {
-        return encoding;
-    }
-
     @Override
     public long getAlignment() {
         return alignment;
index dfc55087c5e22fdf616da0ec152991e1de7d57ef..397be25d7ee41bebc03f6d635a695f3c1ce58862 100644 (file)
@@ -30,6 +30,7 @@ public class FloatDefinition extends Definition {
         super(definitionScope, fieldName);
         this.declaration = declaration;
     }
+
     // ------------------------------------------------------------------------
     // Gettters/Setters/Predicates
     // ------------------------------------------------------------------------
@@ -50,34 +51,27 @@ public class FloatDefinition extends Definition {
     // Operations
     // ------------------------------------------------------------------------
 
-
-
     @Override
     public void read(BitBuffer input) {
         int exp = declaration.getExponent();
         int mant = declaration.getMantissa();
-        if( (exp + mant) == 32 ){
-            value = readRawFloat32(input, mant , exp);
-        }
-        else if((exp + mant) == 64)
-        {
-            value = readRawFloat64(input, mant,exp);
-        }
-        else
-        {
+        if ((exp + mant) == 32) {
+            value = readRawFloat32(input, mant, exp);
+        } else if ((exp + mant) == 64) {
+            value = readRawFloat64(input, mant, exp);
+        } else {
             value = Double.NaN;
         }
     }
 
-
-
-    private static double readRawFloat64(BitBuffer input, final int manBits, final int expBits) {
-       long low = input.getInt(32, false);
-       low = low & 0x00000000FFFFFFFFL;
-       long high = input.getInt(32, false);
-       high = high & 0x00000000FFFFFFFFL;
-       long temp = (high << 32) | low;
-       return createFloat(temp, manBits-1, expBits);
+    private static double readRawFloat64(BitBuffer input, final int manBits,
+            final int expBits) {
+        long low = input.getInt(32, false);
+        low = low & 0x00000000FFFFFFFFL;
+        long high = input.getInt(32, false);
+        high = high & 0x00000000FFFFFFFFL;
+        long temp = (high << 32) | low;
+        return createFloat(temp, manBits - 1, expBits);
     }
 
     /**
@@ -85,12 +79,13 @@ public class FloatDefinition extends Definition {
      * @param manBits
      * @param expBits
      */
-    private static double createFloat(long rawValue, final int manBits, final int expBits) {
+    private static double createFloat(long rawValue, final int manBits,
+            final int expBits) {
         long manShift = 1L << (manBits);
         long manMask = manShift - 1;
         long expMask = (1L << expBits) - 1;
 
-        int exp = (int) ((rawValue >> (manBits))&expMask)+1;
+        int exp = (int) ((rawValue >> (manBits)) & expMask) + 1;
         long man = (rawValue & manMask);
         double expPow = Math.pow(2.0, exp - (1 << (expBits - 1)));
         double ret = man * 1.0f;
@@ -101,9 +96,9 @@ public class FloatDefinition extends Definition {
     }
 
     private static double readRawFloat32(BitBuffer input, final int manBits,
-    final int expBits) {
+            final int expBits) {
         long temp = input.getInt(32, false);
-        return createFloat(temp, manBits-1, expBits);
+        return createFloat(temp, manBits - 1, expBits);
     }
 
     @Override
index 32729d86b1ee97170121a11b902ba37057728f9d..92283535ff2d8c1dfea5927a6b386baecf490730 100644 (file)
@@ -74,6 +74,7 @@ public class IntegerDeclaration implements IDeclaration {
         return length;
     }
 
+    @Override
     public long getAlignment(){
         return alignment;
     }
index 9581988fdd6757fa88ac02e15e62c6646085368e..9317d550531b25bcdac7839cc7b6e9680ace97ed 100644 (file)
@@ -139,7 +139,7 @@ public class CTFTrace implements IDefinitionScope {
 
     /** Handlers for the metadata files */
     private final static FileFilter metadataFileFilter = new MetadataFileFilter();
-    private final static Comparator<File> metadataComparator = new MetadataComparator();
+    private final static Comparator<File> metadataComparator = new MetadataComparator(); // $codepro.audit.disable fieldJavadoc
 
     /** map of all the event types */
     private final HashMap<Long, EventDeclaration> events;
@@ -240,6 +240,11 @@ public class CTFTrace implements IDefinitionScope {
                 }
             }
         }
+        try {
+            super.finalize();
+        } catch (Throwable e) {
+            // TODO Auto-generated catch block
+        }
     }
 
     // ------------------------------------------------------------------------
index 920b34d455f1b3f6f64d684a35797241dec7b725..ac758b3a9e969a05534bcdae87a5891a2e8c8770 100644 (file)
@@ -516,7 +516,7 @@ public class CTFTraceReader {
         if (obj == null) {
             return false;
         }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof CTFTraceReader)) {
             return false;
         }
         CTFTraceReader other = (CTFTraceReader) obj;
index db82ea05217dc4b8d5e1852d941b970278786259..0648c1194bdd6a617dbdf81dd9e50a7459d03201 100644 (file)
@@ -49,12 +49,12 @@ public class Metadata {
     /**
      * Name of the metadata file in the trace directory
      */
-    final String METADATA_FILENAME = "metadata"; //$NON-NLS-1$
+    final static String METADATA_FILENAME = "metadata"; //$NON-NLS-1$
 
     /**
      * Size of the metadata packet header, in bytes, computed by hand.
      */
-    final int METADATA_PACKET_HEADER_SIZE = 37;
+    final static int METADATA_PACKET_HEADER_SIZE = 37;
 
     // ------------------------------------------------------------------------
     // Attributes
diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java
new file mode 100644 (file)
index 0000000..52e0d17
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.ctf.core.event.metadata;
+
+public interface CTFStrings {
+
+    public static final String NONE = "none"; //$NON-NLS-1$
+    public static final String ASCII = "ASCII"; //$NON-NLS-1$
+    public static final String UTF8 = "UTF8"; //$NON-NLS-1$
+    public static final String BIN = "b"; //$NON-NLS-1$
+    public static final String BINARY = "binary"; //$NON-NLS-1$
+    public static final String OCTAL_CTE = "o"; //$NON-NLS-1$
+    public static final String OCT = "oct"; //$NON-NLS-1$
+    public static final String OCTAL = "octal"; //$NON-NLS-1$
+    public static final String POINTER = "p"; //$NON-NLS-1$
+    public static final String X2 = "X"; //$NON-NLS-1$
+    public static final String X = "x"; //$NON-NLS-1$
+    public static final String HEX = "hex"; //$NON-NLS-1$
+    public static final String HEXADECIMAL = "hexadecimal"; //$NON-NLS-1$
+    public static final String UNSIGNED_CTE = "u"; //$NON-NLS-1$
+    public static final String DEC_CTE = "d"; //$NON-NLS-1$
+    public static final String INT_MOD = "i"; //$NON-NLS-1$
+    public static final String DEC = "dec"; //$NON-NLS-1$
+    public static final String DECIMAL = "decimal"; //$NON-NLS-1$
+    public static final String NATIVE = "native"; //$NON-NLS-1$
+    public static final String NETWORK = "network"; //$NON-NLS-1$
+    public static final String BE = "be"; //$NON-NLS-1$
+    public static final String LE = "le"; //$NON-NLS-1$
+    public static final String ALIGN = "align"; //$NON-NLS-1$
+    public static final String MANT_DIG = "mant_dig"; //$NON-NLS-1$
+    public static final String EXP_DIG = "exp_dig"; //$NON-NLS-1$
+    public static final String LOGLEVEL2 = "loglevel"; //$NON-NLS-1$
+    public static final String NAME2 = "name"; //$NON-NLS-1$
+    public static final String EVENT_CONTEXT = "event.context"; //$NON-NLS-1$
+    public static final String FIELDS_STRING = "fields"; //$NON-NLS-1$
+    public static final String CONTEXT = "context"; //$NON-NLS-1$
+    public static final String STREAM_ID = "stream_id"; //$NON-NLS-1$
+    public static final String PACKET_CONTEXT = "packet.context"; //$NON-NLS-1$
+    public static final String ID = "id"; //$NON-NLS-1$
+    public static final String PACKET_HEADER = "packet.header"; //$NON-NLS-1$
+    public static final String EVENT_HEADER = "event.header"; //$NON-NLS-1$
+    public static final String BYTE_ORDER = "byte_order"; //$NON-NLS-1$
+    public static final String UUID_STRING = "uuid"; //$NON-NLS-1$
+    public static final String FALSE2 = "FALSE"; //$NON-NLS-1$
+    public static final String FALSE = "false"; //$NON-NLS-1$
+    public static final String TRUE2 = "TRUE"; //$NON-NLS-1$
+    public static final String TRUE = "true"; //$NON-NLS-1$
+    public static final String MINOR = "minor"; //$NON-NLS-1$
+    public static final String MAJOR = "major"; //$NON-NLS-1$
+
+
+}
index 1380de49be9eafb2a3e14a79f54bd8ac2cdb55aa..5039efbcd07172e09f7a0e7a73058d95e326c3bf 100644 (file)
@@ -214,14 +214,11 @@ public class IOStructGen {
             }
             for (CommonTree event : events) {
                 parseEvent(event);
-                CommonTree name = (CommonTree) event.getChild(0).getChild(1)
-                        .getChild(0).getChild(0);
-                if (DEBUG_) {
-                    out.write("Name = " + name); //$NON-NLS-1$
-                }
-                CommonTree id = (CommonTree) event.getChild(1).getChild(1)
-                        .getChild(0).getChild(0);
                 if (DEBUG_) {
+                    CommonTree name = (CommonTree) event.getChild(0).getChild(1)
+                            .getChild(0).getChild(0);
+                    CommonTree id = (CommonTree) event.getChild(1).getChild(1)
+                            .getChild(0).getChild(0);
                     out.write("Name = " + name + " Id = " + id + '\n'); //$NON-NLS-1$ //$NON-NLS-2$
                 }
             }
@@ -348,19 +345,19 @@ public class IOStructGen {
 
         String left = concatenateUnaryStrings(leftStrings);
 
-        if (left.equals("major")) { //$NON-NLS-1$
+        if (left.equals(CTFStrings.MAJOR)) {
             if (trace.majortIsSet()) {
                 throw new ParseException("major is already set"); //$NON-NLS-1$
             }
 
             trace.setMajor(getMajorOrMinor(rightNode));
-        } else if (left.equals("minor")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.MINOR)) {
             if (trace.minorIsSet()) {
                 throw new ParseException("minor is already set"); //$NON-NLS-1$
             }
 
             trace.setMinor(getMajorOrMinor(rightNode));
-        } else if (left.equals("uuid")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.UUID_STRING)) {
             UUID uuid = getUUID(rightNode);
 
             /*
@@ -376,7 +373,7 @@ public class IOStructGen {
                 trace.setUUID(uuid);
             }
 
-        } else if (left.equals("byte_order")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.BYTE_ORDER)) {
             ByteOrder byteOrder = getByteOrder(rightNode);
 
             /*
@@ -393,7 +390,7 @@ public class IOStructGen {
             } else {
                 trace.setByteOrder(byteOrder);
             }
-        } else if (left.equals("packet.header")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.PACKET_HEADER)) {
             if (trace.packetHeaderIsSet()) {
                 throw new ParseException("packet.header already defined"); //$NON-NLS-1$
             }
@@ -450,7 +447,7 @@ public class IOStructGen {
 
         if (stream.idIsSet()) {
             if (!trace.packetHeaderIsSet()
-                    || !trace.getPacketHeader().hasField("stream_id")) { //$NON-NLS-1$
+                    || !trace.getPacketHeader().hasField(CTFStrings.STREAM_ID)) {
                 throw new ParseException(
                         "Stream has an ID, but there is no stream_id field in packet header."); //$NON-NLS-1$
             }
@@ -484,7 +481,7 @@ public class IOStructGen {
 
         String left = concatenateUnaryStrings(leftStrings);
 
-        if (left.equals("id")) { //$NON-NLS-1$
+        if (left.equals(CTFStrings.ID)) {
             if (stream.idIsSet()) {
                 throw new ParseException("stream id already defined"); //$NON-NLS-1$
             }
@@ -492,7 +489,7 @@ public class IOStructGen {
             long streamID = getStreamID(rightNode);
 
             stream.setId(streamID);
-        } else if (left.equals("event.header")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.EVENT_HEADER)) {
             if (stream.eventHeaderIsSet()) {
                 throw new ParseException("event.header already defined"); //$NON-NLS-1$
             }
@@ -512,7 +509,7 @@ public class IOStructGen {
             }
 
             stream.setEventHeader((StructDeclaration) eventHeaderDecl);
-        } else if (left.equals("event.context")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.EVENT_CONTEXT)) {
             if (stream.eventContextIsSet()) {
                 throw new ParseException("event.context already defined"); //$NON-NLS-1$
             }
@@ -532,7 +529,7 @@ public class IOStructGen {
             }
 
             stream.setEventContext((StructDeclaration) eventContextDecl);
-        } else if (left.equals("packet.context")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.PACKET_CONTEXT)) {
             if (stream.packetContextIsSet()) {
                 throw new ParseException("packet.context already defined"); //$NON-NLS-1$
             }
@@ -648,7 +645,7 @@ public class IOStructGen {
 
         String left = concatenateUnaryStrings(leftStrings);
 
-        if (left.equals("name")) { //$NON-NLS-1$
+        if (left.equals(CTFStrings.NAME2)) {
             if (event.nameIsSet()) {
                 throw new ParseException("name already defined"); //$NON-NLS-1$
             }
@@ -656,7 +653,7 @@ public class IOStructGen {
             String name = getEventName(rightNode);
 
             event.setName(name);
-        } else if (left.equals("id")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.ID)) {
             if (event.idIsSet()) {
                 throw new ParseException("id already defined"); //$NON-NLS-1$
             }
@@ -664,7 +661,7 @@ public class IOStructGen {
             long id = getEventID(rightNode);
 
             event.setId(id);
-        } else if (left.equals("stream_id")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.STREAM_ID)) {
             if (event.streamIsSet()) {
                 throw new ParseException("stream id already defined"); //$NON-NLS-1$
             }
@@ -678,7 +675,7 @@ public class IOStructGen {
             }
 
             event.setStream(stream);
-        } else if (left.equals("context")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.CONTEXT)) {
             if (event.contextIsSet()) {
                 throw new ParseException("context already defined"); //$NON-NLS-1$
             }
@@ -697,7 +694,7 @@ public class IOStructGen {
             }
 
             event.setContext((StructDeclaration) contextDecl);
-        } else if (left.equals("fields")) { //$NON-NLS-1$
+        } else if (left.equals(CTFStrings.FIELDS_STRING)) {
             if (event.fieldsIsSet()) {
                 throw new ParseException("fields already defined"); //$NON-NLS-1$
             }
@@ -721,7 +718,7 @@ public class IOStructGen {
             final StructDeclaration fields = (StructDeclaration) fieldsDecl;
             event.setFields(fields);
         }
-        else if (left.equals("loglevel")){ //$NON-NLS-1$
+        else if (left.equals(CTFStrings.LOGLEVEL2)){
 
             long logLevel = parseUnaryInteger((CommonTree) rightNode.getChild(0)) ;
             event.setLogLevel(logLevel);
@@ -1196,12 +1193,9 @@ public class IOStructGen {
         FloatDeclaration floatDeclaration = null;
         ByteOrder byteOrder = trace.getByteOrder();
         long alignment = 0;
-        int base = 2;
         int exponent = 8;
         int mantissa = 24;
 
-        Encoding encoding = Encoding.NONE;
-
         /* Iterate on all integer children */
         for (CommonTree child : children) {
             switch (child.getType()) {
@@ -1225,13 +1219,13 @@ public class IOStructGen {
                 }
                 String left = concatenateUnaryStrings(leftStrings);
 
-                if (left.equals("exp_dig")) { //$NON-NLS-1$
+                if (left.equals(CTFStrings.EXP_DIG)) {
                     exponent = (int) parseUnaryInteger((CommonTree) rightNode.getChild(0));
-                } else if (left.equals("byte_order")) { //$NON-NLS-1$
+                } else if (left.equals(CTFStrings.BYTE_ORDER)) {
                     byteOrder = getByteOrder(rightNode);
-                } else if (left.equals("mant_dig")) { //$NON-NLS-1$
+                } else if (left.equals(CTFStrings.MANT_DIG)) {
                     mantissa = (int) parseUnaryInteger((CommonTree) rightNode.getChild(0));
-                } else if (left.equals("align")) { //$NON-NLS-1$
+                } else if (left.equals(CTFStrings.ALIGN)) {
                     alignment = getAlignment(rightNode);
                 } else {
                     throw new ParseException("Float: unknown attribute " + left); //$NON-NLS-1$
@@ -1256,7 +1250,7 @@ public class IOStructGen {
             }
         }
 
-        floatDeclaration = new FloatDeclaration(exponent, mantissa, byteOrder, encoding, alignment);
+        floatDeclaration = new FloatDeclaration(exponent, mantissa, byteOrder, alignment);
 
         assert (floatDeclaration != null);
         return floatDeclaration;
@@ -1351,11 +1345,11 @@ public class IOStructGen {
 
                 if (left.equals("signed")) { //$NON-NLS-1$
                     signed = getSigned(rightNode);
-                } else if (left.equals("byte_order")) { //$NON-NLS-1$
+                } else if (left.equals(CTFStrings.BYTE_ORDER)) {
                     byteOrder = getByteOrder(rightNode);
                 } else if (left.equals("size")) { //$NON-NLS-1$
                     size = getSize(rightNode);
-                } else if (left.equals("align")) { //$NON-NLS-1$
+                } else if (left.equals(CTFStrings.ALIGN)) {
                     alignment = getAlignment(rightNode);
                 } else if (left.equals("base")) { //$NON-NLS-1$
                     base = getBase(rightNode);
@@ -2454,9 +2448,9 @@ public class IOStructGen {
         if (isUnaryString(firstChild)) {
             String strval = concatenateUnaryStrings(rightNode.getChildren());
 
-            if (strval.equals("true") || strval.equals("TRUE")) { //$NON-NLS-1$ //$NON-NLS-2$
+            if (strval.equals(CTFStrings.TRUE) || strval.equals(CTFStrings.TRUE2)) {
                 ret = true;
-            } else if (strval.equals("false") || strval.equals("FALSE")) { //$NON-NLS-1$ //$NON-NLS-2$
+            } else if (strval.equals(CTFStrings.FALSE) || strval.equals(CTFStrings.FALSE2)) {
                 ret = false;
             } else {
                 throw new ParseException("Invalid boolean value " //$NON-NLS-1$
@@ -2502,11 +2496,11 @@ public class IOStructGen {
         if (isUnaryString(firstChild)) {
             String strval = concatenateUnaryStrings(rightNode.getChildren());
 
-            if (strval.equals("le")) { //$NON-NLS-1$
+            if (strval.equals(CTFStrings.LE)) {
                 return ByteOrder.LITTLE_ENDIAN;
-            } else if (strval.equals("be") || strval.equals("network")) { //$NON-NLS-1$ //$NON-NLS-2$
+            } else if (strval.equals(CTFStrings.BE) || strval.equals(CTFStrings.NETWORK)) {
                 return ByteOrder.BIG_ENDIAN;
-            } else if (strval.equals("native")) { //$NON-NLS-1$
+            } else if (strval.equals(CTFStrings.NATIVE)) {
                 return trace.getByteOrder();
             } else {
                 throw new ParseException("Invalid value for byte order"); //$NON-NLS-1$
@@ -2618,18 +2612,18 @@ public class IOStructGen {
         } else if (isUnaryString(firstChild)) {
             String strval = concatenateUnaryStrings(rightNode.getChildren());
 
-            if (strval.equals("decimal") || strval.equals("dec") //$NON-NLS-1$ //$NON-NLS-2$
-                    || strval.equals("d") || strval.equals("i") //$NON-NLS-1$ //$NON-NLS-2$
-                    || strval.equals("u")) { //$NON-NLS-1$
+            if (strval.equals(CTFStrings.DECIMAL) || strval.equals(CTFStrings.DEC)
+                    || strval.equals(CTFStrings.DEC_CTE) || strval.equals(CTFStrings.INT_MOD)
+                    || strval.equals(CTFStrings.UNSIGNED_CTE)) {
                 return 10;
-            } else if (strval.equals("hexadecimal") || strval.equals("hex") //$NON-NLS-1$ //$NON-NLS-2$
-                    || strval.equals("x") || strval.equals("X") //$NON-NLS-1$ //$NON-NLS-2$
-                    || strval.equals("p")) { //$NON-NLS-1$
+            } else if (strval.equals(CTFStrings.HEXADECIMAL) || strval.equals(CTFStrings.HEX)
+                    || strval.equals(CTFStrings.X) || strval.equals(CTFStrings.X2)
+                    || strval.equals(CTFStrings.POINTER)) {
                 return 16;
-            } else if (strval.equals("octal") || strval.equals("oct") //$NON-NLS-1$ //$NON-NLS-2$
-                    || strval.equals("o")) { //$NON-NLS-1$
+            } else if (strval.equals(CTFStrings.OCTAL) || strval.equals(CTFStrings.OCT)
+                    || strval.equals(CTFStrings.OCTAL_CTE)) {
                 return 8;
-            } else if (strval.equals("binary") || strval.equals("b")) { //$NON-NLS-1$ //$NON-NLS-2$
+            } else if (strval.equals(CTFStrings.BINARY) || strval.equals(CTFStrings.BIN)) {
                 return 2;
             } else {
                 throw new ParseException("Invalid value for base"); //$NON-NLS-1$
@@ -2656,11 +2650,11 @@ public class IOStructGen {
         if (isUnaryString(firstChild)) {
             String strval = concatenateUnaryStrings(rightNode.getChildren());
 
-            if (strval.equals("UTF8")) { //$NON-NLS-1$
+            if (strval.equals(CTFStrings.UTF8)) {
                 return Encoding.UTF8;
-            } else if (strval.equals("ASCII")) { //$NON-NLS-1$
+            } else if (strval.equals(CTFStrings.ASCII)) {
                 return Encoding.ASCII;
-            } else if (strval.equals("none")) { //$NON-NLS-1$
+            } else if (strval.equals(CTFStrings.NONE)) {
                 return Encoding.NONE;
             } else {
                 throw new ParseException("Invalid value for encoding"); //$NON-NLS-1$
index bcbabefccbc4b459411b74f57dbac11a7b4a4cc0..b2093c0d14a57998560f2765f12f47249194d0d7 100644 (file)
@@ -133,7 +133,7 @@ public class CtfTmfEventFieldTest {
         IntegerDeclaration intDec = new IntegerDeclaration(8, false, 8,
                 ByteOrder.BIG_ENDIAN, Encoding.NONE, null, 8);
         FloatDeclaration flDec = new FloatDeclaration(8, 24,
-                ByteOrder.BIG_ENDIAN, Encoding.NONE, 8);
+                ByteOrder.BIG_ENDIAN, 8);
         ArrayDeclaration arrDec = new ArrayDeclaration(2, intDec);
         SequenceDeclaration seqDec = new SequenceDeclaration(LEN, intDec);
         sDec.addField(INT, intDec);
This page took 0.058072 seconds and 5 git commands to generate.