/** * Parse a node - with convenience prefix mapping * <p> * Allows surrounding white space * </p> * * @param nodeString Node string to parse * */ public static Node parseNode(String nodeString) { return parseNode(nodeString, prefixMappingDefault) ; }
/** * Appends a long to the command text as a constant using appropriate * formatting * * @param l * Long to append */ public void appendLiteral(long l) { this.appendNode(NodeFactoryExtra.intToNode(l)); }
/** * Tries to convert a node to an integer * * @param n * Node * @return Integer * @throws SQLException * Thrown if the node cannot be converted */ public static int toInt(Node n) throws SQLException { try { if (n == null) return 0; if (n.isLiteral()) { return NodeFactoryExtra.nodeToInt(n); } else { throw new SQLException("Unable to marshal a non-literal to an integer"); } } catch (SQLException e) { // Throw as is throw e; } catch (Exception e) { // Wrap other exceptions throw new SQLException("Unable to marshal the value to an integer", e); } }
NodeFactory.createLiteral(Boolean.toString((Boolean) value), XSDDatatype.XSDboolean)); } else if (value instanceof Long) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((Long) value)); } else if (value instanceof Integer) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((Integer) value)); } else if (value instanceof Short) { this.setParameter(parameterIndex, NodeFactory.createLiteral(Short.toString((Short) value), XSDDatatype.XSDshort)); NodeFactory.createLiteral(((BigDecimal) value).toPlainString(), XSDDatatype.XSDdecimal)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float) value)); } else if (value instanceof Double) { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double) value)); } else if (value instanceof Date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Date) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); } else if (value instanceof Time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Time) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.timeToNode(c)); } else if (value instanceof Calendar) { this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode((Calendar) value)); } else if (value instanceof URL) { this.setParameter(parameterIndex, NodeFactory.createURI(value.toString()));
public static NodeValue eval(Expr expr, Binding binding) { Context context = ARQ.getContext().copy() ; context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; FunctionEnv env = new ExecutionContext(context, null, null, null) ; NodeValue r = expr.eval(binding, env) ; return r ; }
addPair(meta.getList(), "timestamp", NodeFactoryExtra.nowAsDateTime()) ; addPair(meta.getList(), "run@", DateTimeUtils.nowAsString()) ; if ( count >= 0 ) addPair(meta.getList(), StatsMatcher.COUNT, NodeFactoryExtra.intToNode((int)count)) ; statsList.add(meta) ; addTypeTriple(statsList, type, NodeFactoryExtra.intToNode(entry.getValue()) ) ; addPair(statsList, node, NodeFactoryExtra.intToNode(entry.getValue())) ;
private Node entryToNode(String v) { // TEMP return NodeFactoryExtra.createLiteralNode(v, null, null) ; } }
/** * Sets a positional parameter to a float literal * * @param index * Positional Index * @param f * Float value */ public void setLiteral(int index, float f) { this.setParam(index, NodeFactoryExtra.floatToNode(f)); }
@Override public void setDouble(int parameterIndex, double value) throws SQLException { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode(value)); }
@Override public void setDate(int parameterIndex, Date value) throws SQLException { Calendar c = Calendar.getInstance(); c.setTimeInMillis(value.getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); }
NodeFactory.createLiteral(Boolean.toString((Boolean) value), XSDDatatype.XSDboolean)); } else if (value instanceof Long) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((Long) value)); } else if (value instanceof Integer) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((Integer) value)); } else if (value instanceof Short) { this.setParameter(parameterIndex, NodeFactory.createLiteral(Short.toString((Short) value), XSDDatatype.XSDshort)); NodeFactory.createLiteral(((BigDecimal) value).toPlainString(), XSDDatatype.XSDdecimal)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float) value)); } else if (value instanceof Double) { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double) value)); } else if (value instanceof Date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Date) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); } else if (value instanceof Time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Time) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.timeToNode(c)); } else if (value instanceof Calendar) { this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode((Calendar) value)); } else if (value instanceof URL) { this.setParameter(parameterIndex, NodeFactory.createURI(value.toString()));
private static Context setupContext(Context context, DatasetGraph dataset) { // To many copies? if ( context == null ) // Copy of global context to protect against change. context = ARQ.getContext() ; context = context.copy() ; if ( dataset.getContext() != null ) context.putAll(dataset.getContext()) ; context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; return context ; } }
addPair(meta.getList(), "timestamp", NodeFactoryExtra.nowAsDateTime()) ; addPair(meta.getList(), "run@", DateTimeUtils.nowAsString()) ; if ( count >= 0 ) addPair(meta.getList(), StatsMatcher.COUNT, NodeFactoryExtra.intToNode((int)count)) ; statsList.add(meta) ; addTypeTriple(statsList, type, NodeFactoryExtra.intToNode(entry.getValue()) ) ; addPair(statsList, node, NodeFactoryExtra.intToNode(entry.getValue())) ;
private Node entryToNode(String v) { // TEMP return NodeFactoryExtra.createLiteralNode(v, null, null) ; } }
/** * Sets a variable parameter to a float literal * * @param var * Variable * @param f * Float value */ public void setLiteral(String var, float f) { this.setParam(var, NodeFactoryExtra.floatToNode(f)); }
@Override public void setDouble(int parameterIndex, double value) throws SQLException { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode(value)); }
@Override public void setDate(int parameterIndex, Date value) throws SQLException { Calendar c = Calendar.getInstance(); c.setTimeInMillis(value.getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); }
case Types.BIGINT: if (value instanceof Long) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((Long) value)); } else if (value instanceof Integer) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((long)(Integer)value)); } else if (value instanceof Short) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((long)(Short)value)); } else if (value instanceof Byte) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode((long)(Byte)value)); } else if (value instanceof Node) { long l = JdbcNodeUtils.toLong((Node) value); this.setParameter(parameterIndex, NodeFactoryExtra.intToNode(l)); } else if (value instanceof String) { this.setParameter(parameterIndex, NodeFactoryExtra.intToNode(Long.parseLong((String)value))); } else { throw new SQLException("The given value is not marshallable to the desired target type"); Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Date) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); } else if (value instanceof Node) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(JdbcNodeUtils.toDate((Node)value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c)); } else if (value instanceof Time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(((Time) value).getTime()); this.setParameter(parameterIndex, NodeFactoryExtra.timeToNode(c)); } else if (value instanceof Calendar) {
public static NodeValue parseNodeValue(String s) { Node n = NodeFactoryExtra.parseNode(s) ; NodeValue nv = NodeValue.makeNode(n) ; return nv ; }
/** * Sets a positional parameter to an integer literal * * @param index * Positional Index * @param l * Integer Value */ public void setLiteral(int index, long l) { this.setParam(index, NodeFactoryExtra.intToNode(l)); }