/*******************************************************************************
- * 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>
*
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()) {
return -1;
}
- if (this.getType() != 0) { /* 0 = int type */
+ if (this.getType() != Type.INTEGER) {
throw new StateValueTypeException();
}
return (Integer) this.getValue();
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();
+ }
}