tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / statevalue / TmfStateValue.java
index cf7175c377bbf80bb0a125b351e6227bd27ae4c5..b2405ed54d0300a93807402f89b60616573ebcb3 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  * Copyright (c) 2010, 2011 École Polytechnique de Montréal
  * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
  *
@@ -138,6 +138,20 @@ public abstract class TmfStateValue implements ITmfStateValue {
         return new StringStateValue(strValue);
     }
 
+    /**
+     * Factory constructor for Long state values
+     *
+     * @param longValue The long value to contain
+     * @return The newly-create TmfStateValue object
+     * @since 2.0
+     */
+    public static TmfStateValue newValueLong(long longValue) {
+        if (longValue == -1) {
+            return nullValue();
+        }
+        return new LongStateValue(longValue);
+    }
+
     @Override
     public int unboxInt() throws StateValueTypeException {
         if (this.isNull()) {
@@ -145,7 +159,7 @@ public abstract class TmfStateValue implements ITmfStateValue {
             return -1;
         }
 
-        if (this.getType() != 0) { /* 0 = int type */
+        if (this.getType() != Type.INTEGER) {
             throw new StateValueTypeException();
         }
         return (Integer) this.getValue();
@@ -158,9 +172,25 @@ public abstract class TmfStateValue implements ITmfStateValue {
             return "nullValue"; //$NON-NLS-1$
         }
 
-        if (this.getType() != 1) { /* 1 = string type */
+        if (this.getType() != Type.STRING) {
             throw new StateValueTypeException();
         }
         return (String) this.getValue();
     }
+
+    /**
+     * @since 2.0
+     */
+    @Override
+    public long unboxLong() throws StateValueTypeException {
+        if (this.isNull()) {
+            /* Long value expected, return "-1" instead */
+            return -1;
+        }
+
+        if (this.getType() != Type.LONG) {
+            throw new StateValueTypeException();
+        }
+        return (Long) this.getValue();
+    }
 }
This page took 0.025082 seconds and 5 git commands to generate.