List of usage examples for org.eclipse.jdt.internal.compiler.impl Constant booleanValue
public boolean booleanValue()
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(); }/* w ww. j a v a2 s. c om*/ 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). *//*from w ww . ja va2 s . c o 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; }/* www. j a v a 2 s . com*/ 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.google.gwt.dev.jjs.impl.GenerateJavaAST.java
License:Apache License
/** * Returns <code>true</code> if JDT optimized the condition to * <code>false</code>.// www . j a va2 s . co m */ private static boolean isOptimizedFalse(Expression condition) { if (condition != null) { Constant cst = condition.optimizedBooleanConstant(); if (cst != Constant.NotAConstant) { if (cst.booleanValue() == false) { return true; } } } return false; }
From source file:com.google.gwt.dev.jjs.impl.GenerateJavaAST.java
License:Apache License
/** * Returns <code>true</code> if JDT optimized the condition to * <code>true</code>./* w ww .j a va2 s . co m*/ */ private static boolean isOptimizedTrue(Expression condition) { if (condition != null) { Constant cst = condition.optimizedBooleanConstant(); if (cst != Constant.NotAConstant) { if (cst.booleanValue()) { return true; } } } return false; }
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 . ja va 2 s . c om*/ 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()); }//from w w w . jav a2s . 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());/*from w w w .java2 s .co m*/ 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()); } }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
public static JsonElement toJsonConstant(Constant constant) { if (constant == null) return JsonNull.INSTANCE; JsonObject con = new JsonObject(); con.addProperty("typeId", constant.typeID()); JsonElement val; switch (constant.typeID()) { case T_int: val = new JsonPrimitive(constant.intValue()); break;/*from w w w.ja va 2s . c o m*/ case T_byte: val = new JsonPrimitive(constant.byteValue()); break; case T_short: val = new JsonPrimitive(constant.shortValue()); break; case T_char: val = new JsonPrimitive(constant.charValue()); break; case T_float: val = new JsonPrimitive(String.valueOf(constant.floatValue())); break; case T_double: if (Constant.NotAConstant.equals(constant)) { val = new JsonPrimitive("NaN"); con.addProperty("NotAConstant", 1); } else { val = new JsonPrimitive(constant.stringValue()); } break; case T_boolean: val = new JsonPrimitive(constant.booleanValue()); break; case T_long: val = new JsonPrimitive(String.valueOf(constant.longValue())); break; case T_JavaLangString: val = new JsonPrimitive(constant.stringValue()); break; default: val = JsonNull.INSTANCE; } con.add("value", val); return con; }