expr = XPath.parseExpr(value, getNamespaceContext());
return _gen.addXPathExpr(expr);
}
Expr expr = _gen.genExpr(value);
if (expr.isConstant()) {
try {
if (expr.evalObject(null) != null) {
}
else if (Character.class.isAssignableFrom(type)) {
// jsp/18s0
return "new Character((char) 0)";
}
else if (Boolean.class.isAssignableFrom(type)) {
// jsp/18s1
return "Boolean.FALSE";
}
else if (String.class.isAssignableFrom(type)) {
// jsp/18s2
return "\"\"";
}
else if (BigInteger.class.isAssignableFrom(type)) {
return "java.math.BigInteger.ZERO";
}
else if (BigDecimal.class.isAssignableFrom(type)) {
return "java.math.BigDecimal.ZERO";
}
else if (Number.class.isAssignableFrom(type)) {
// jsp/18s6
return "new " + type.getName() + "((byte) 0)";
}
else if (Object.class.isAssignableFrom(type))
return "null";
if (boolean.class.equals(type))
return expr.evalBoolean(null) ? "true" : "false";
else if (Boolean.class.equals(type))
return expr.evalBoolean(null) ? "java.lang.Boolean.TRUE" : "java.lang.Boolean.FALSE";
else if (byte.class.equals(type))
return "(byte) " + expr.evalLong(null);
else if (Byte.class.equals(type))
return "new java.lang.Byte((byte) " + expr.evalLong(null) + "L)";
else if (short.class.equals(type))
return "(short) " + expr.evalLong(null);
else if (Short.class.equals(type))
return "new java.lang.Short((short) " + expr.evalLong(null) + "L)";
else if (int.class.equals(type))
return "(int) " + expr.evalLong(null);
else if (Integer.class.equals(type))
return "new java.lang.Integer((int) " + expr.evalLong(null) + "L)";
else if (long.class.equals(type))
return "" + expr.evalLong(null) + "L";
else if (Long.class.equals(type))
return "new java.lang.Long(" + expr.evalLong(null) + "L)";
else if (float.class.equals(type))
return "(float) " + expr.evalDouble(null);
else if (Float.class.equals(type))
return "new java.lang.Float((float) " + expr.evalDouble(null) + ")";
else if (double.class.equals(type)) {
double v = expr.evalDouble(null);
if (Double.isNaN(v))
return "Double.NaN";
else
return "" + v;
}
else if (Double.class.equals(type)) {
double v = expr.evalDouble(null);
if (Double.isNaN(v))
return "new Double(Double.NaN)";
else
return "new java.lang.Double(" + v + ")";
}
else if (char.class.equals(type))
return "((char) " + (int) expr.evalCharacter(null) + ")";
else if (Character.class.equals(type)) {
// jsp/18s0
return "new Character((char) " + (int) expr.evalCharacter(null) + ")";
}
else if (String.class.equals(type))
return "\"" + escapeJavaString(expr.evalString(null)) + "\"";
else if (BigInteger.class.equals(type)) {
String v = expr.evalBigInteger(null).toString();
// 18s3
if (v.equals("") || v.equals("0"))
return "java.math.BigInteger.ZERO";
else
return "new java.math.BigInteger(\"" + v + "\")";
}
else if (BigDecimal.class.equals(type)) {
String v = expr.evalBigDecimal(null).toString();
// 18s4
if (v.equals("") || v.equals("0.0"))
return "java.math.BigDecimal.ZERO";
else
return "new java.math.BigDecimal(\"" + v + "\")";
}
else if (Object.class.equals(type)) {
Object cValue = expr.evalObject(null);
String result = generateObject(cValue);
if (result != null)
return result;
}
else {
Object cValue = expr.evalObject(null);
// jsp/184t
if ("".equals(cValue))
return "null";
}