Tabnine Logo
NodeFactoryExtra
Code IndexAdd Tabnine to your IDE (free)

How to use
NodeFactoryExtra
in
org.apache.jena.sparql.util

Best Java code snippets using org.apache.jena.sparql.util.NodeFactoryExtra (Showing top 20 results out of 315)

origin: apache/jena

/**
 * 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) ;
}
origin: apache/jena

/**
 * 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));
}
origin: apache/jena

/**
 * 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);
  }
}
origin: apache/jena

      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()));
origin: apache/jena

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 ;
}

origin: apache/jena

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())) ;
origin: apache/jena

  private Node entryToNode(String v) {
    // TEMP
    return NodeFactoryExtra.createLiteralNode(v, null, null) ;
  }
}
origin: apache/jena

/**
 * 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));
}
origin: apache/jena

@Override
public void setDouble(int parameterIndex, double value) throws SQLException {
  this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode(value));
}
origin: apache/jena

@Override
public void setDate(int parameterIndex, Date value) throws SQLException {
  Calendar c = Calendar.getInstance();
  c.setTimeInMillis(value.getTime());
  this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c));
}
origin: org.apache.jena/jena-jdbc-core

      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()));
origin: apache/jena

  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 ; 
  }
}
origin: apache/jena

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())) ;
origin: org.apache.jena/jena-text

  private Node entryToNode(String v) {
    // TEMP
    return NodeFactoryExtra.createLiteralNode(v, null, null) ;
  }
}
origin: apache/jena

/**
 * 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));
}
origin: org.apache.jena/jena-jdbc-core

@Override
public void setDouble(int parameterIndex, double value) throws SQLException {
  this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode(value));
}
origin: org.apache.jena/jena-jdbc-core

@Override
public void setDate(int parameterIndex, Date value) throws SQLException {
  Calendar c = Calendar.getInstance();
  c.setTimeInMillis(value.getTime());
  this.setParameter(parameterIndex, NodeFactoryExtra.dateTimeToNode(c));
}
origin: apache/jena

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) {
origin: apache/jena

public static NodeValue parseNodeValue(String s)
{
  Node n = NodeFactoryExtra.parseNode(s) ;
  NodeValue nv = NodeValue.makeNode(n) ;
  return nv ;
}

origin: apache/jena

/**
 * 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));
}
org.apache.jena.sparql.utilNodeFactoryExtra

Javadoc

Various convenience helper methods for converting to and from nodes

Most used methods

  • nowAsDateTime
  • parseNode
  • intToNode
  • nodeToInt
  • floatToNode
  • createLiteralNode
  • doubleToNode
  • dateTimeToNode
  • timeToNode
  • dateToNode
    Calendar to xsd:date Node
  • nodeToDouble
  • nodeToFloat
  • nodeToDouble,
  • nodeToFloat,
  • nodeToLong,
  • todayAsDate

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Collectors (java.util.stream)
  • Runner (org.openjdk.jmh.runner)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now