public Object literal(String value) { return new Constant(value); }
/** * Processes a Constant expression. * @param constant the constant * @return the constant expression * @throws XPathException for any errors */ XPathExpression processConstant(Constant constant) throws XPathException { Object value = constant.computeValue(null); XPathExpression xpexpr; if (value instanceof String) { xpexpr = AbstractXPathModelHelper.getInstance().newXPathStringLiteral((String) value); } else if (value instanceof Number) { xpexpr = AbstractXPathModelHelper.getInstance().newXPathNumericLiteral((Number) value); } else { XPathException xpe = new XPathException( mMsgMgr.getString("Invalid_XPath_Constant", value)); mLogger.log(Level.FINEST, "processConstant", xpe); throw xpe; } mLogger.finer("constant=" + constant + " value=" + value); return xpexpr; }
public Object number(String value) { return new Constant(new Double(value)); }
/** * overriden this method to create * appropriate Long or Double as the value stored in * Constant. */ public Object number(String value) { //distinguish between Long and Double try { long intVal = Long.parseLong(value); return new Constant(new Long(value)); } catch(NumberFormatException ex) { //Do Nothing } return new Constant(new Double(value)); } }