List of usage examples for org.eclipse.jdt.internal.compiler.impl Constant doubleValue
public double doubleValue()
From source file:com.android.tools.lint.psi.EcjPsiManager.java
License:Apache License
@Nullable static Object getConstantValue(@Nullable Constant value) { if (value == null || value == Constant.NotAConstant) { return null; } else if (value instanceof StringConstant) { return value.stringValue(); } else if (value instanceof IntConstant) { return value.intValue(); } else if (value instanceof BooleanConstant) { return value.booleanValue(); } else if (value instanceof FloatConstant) { return value.floatValue(); } else if (value instanceof LongConstant) { return value.longValue(); } else if (value instanceof DoubleConstant) { return value.doubleValue(); } else if (value instanceof ShortConstant) { return value.shortValue(); } else if (value instanceof CharConstant) { return value.charValue(); } else if (value instanceof ByteConstant) { return value.byteValue(); }//from ww w . j a v a2s . com return null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.Member.java
License:Open Source License
/** * Converts a field constant from the compiler's representation * to the Java Model constant representation (Number or String). */// w ww .j a v a 2 s. co m protected static Object convertConstant(Constant constant) { if (constant == null) return null; if (constant == Constant.NotAConstant) { return null; } switch (constant.typeID()) { case TypeIds.T_boolean: return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE; case TypeIds.T_byte: return new Byte(constant.byteValue()); case TypeIds.T_char: return new Character(constant.charValue()); case TypeIds.T_double: return new Double(constant.doubleValue()); case TypeIds.T_float: return new Float(constant.floatValue()); case TypeIds.T_int: return new Integer(constant.intValue()); case TypeIds.T_long: return new Long(constant.longValue()); case TypeIds.T_short: return new Short(constant.shortValue()); case TypeIds.T_JavaLangString: return constant.stringValue(); default: return null; } }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.Util.java
License:Open Source License
public static Object getAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) { if (constant == null) { memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; }/*w ww . j a v a2s . co m*/ switch (constant.typeID()) { case TypeIds.T_int: memberValuePair.valueKind = IMemberValuePair.K_INT; return new Integer(constant.intValue()); case TypeIds.T_byte: memberValuePair.valueKind = IMemberValuePair.K_BYTE; return new Byte(constant.byteValue()); case TypeIds.T_short: memberValuePair.valueKind = IMemberValuePair.K_SHORT; return new Short(constant.shortValue()); case TypeIds.T_char: memberValuePair.valueKind = IMemberValuePair.K_CHAR; return new Character(constant.charValue()); case TypeIds.T_float: memberValuePair.valueKind = IMemberValuePair.K_FLOAT; return new Float(constant.floatValue()); case TypeIds.T_double: memberValuePair.valueKind = IMemberValuePair.K_DOUBLE; return new Double(constant.doubleValue()); case TypeIds.T_boolean: memberValuePair.valueKind = IMemberValuePair.K_BOOLEAN; return Boolean.valueOf(constant.booleanValue()); case TypeIds.T_long: memberValuePair.valueKind = IMemberValuePair.K_LONG; return new Long(constant.longValue()); case TypeIds.T_JavaLangString: memberValuePair.valueKind = IMemberValuePair.K_STRING; return constant.stringValue(); default: memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; } }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.Util.java
License:Open Source License
public static Object getNegativeAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) { if (constant == null) { memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; }//from ww w .ja v a2s.c o m switch (constant.typeID()) { case TypeIds.T_int: memberValuePair.valueKind = IMemberValuePair.K_INT; return new Integer(constant.intValue() * -1); case TypeIds.T_float: memberValuePair.valueKind = IMemberValuePair.K_FLOAT; return new Float(constant.floatValue() * -1.0f); case TypeIds.T_double: memberValuePair.valueKind = IMemberValuePair.K_DOUBLE; return new Double(constant.doubleValue() * -1.0); case TypeIds.T_long: memberValuePair.valueKind = IMemberValuePair.K_LONG; return new Long(constant.longValue() * -1L); default: memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN; return null; } }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTUtils.java
License:Open Source License
public static Object fromConstant(Constant constant) { switch (constant.typeID()) { case Constant.T_boolean: return new Boolean(constant.booleanValue()); case Constant.T_byte: return new Byte(constant.byteValue()); case Constant.T_char: return new Character(constant.charValue()); case Constant.T_double: return new Double(constant.doubleValue()); case Constant.T_float: return new Float(constant.floatValue()); case Constant.T_int: return new Integer(constant.intValue()); case Constant.T_JavaLangString: return new String(constant.stringValue()); }//from w ww. j av a2s. c o m return null; }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTUtils.java
License:Open Source License
public static Object fromConstant(Constant constant) { switch (constant.typeID()) { case Constant.T_boolean: return new Boolean(constant.booleanValue()); case Constant.T_byte: return new Byte(constant.byteValue()); case Constant.T_char: return new Character(constant.charValue()); case Constant.T_double: return new Double(constant.doubleValue()); case Constant.T_float: return new Float(constant.floatValue()); case Constant.T_int: return new Integer(constant.intValue()); case Constant.T_short: return new Short(constant.shortValue()); case Constant.T_long: return new Long(constant.longValue()); case Constant.T_JavaLangString: return new String(constant.stringValue()); }/* ww w .java 2s . c o m*/ return null; }
From source file:io.takari.maven.plugins.compile.jdt.ClassfileDigester.java
License:Open Source License
private void updateConstant(Constant constant) { updateInt(constant.typeID());/* w ww . jav a2 s .com*/ updateString(constant.getClass().getName()); switch (constant.typeID()) { case TypeIds.T_int: updateInt(constant.intValue()); break; case TypeIds.T_byte: updateByte(constant.byteValue()); break; case TypeIds.T_short: updateShort(constant.shortValue()); break; case TypeIds.T_char: updateChar(constant.charValue()); break; case TypeIds.T_long: updateLong(constant.longValue()); break; case TypeIds.T_float: updateFloat(constant.floatValue()); break; case TypeIds.T_double: updateDouble(constant.doubleValue()); break; case TypeIds.T_boolean: updateBoolean(constant.booleanValue()); break; case TypeIds.T_JavaLangString: updateString(constant.stringValue()); break; default: throw new IllegalArgumentException("Unexpected constant typeID=" + constant.typeID()); } }