Codota Logo
ValueFactory
Code IndexAdd Codota to your IDE (free)

How to use
ValueFactory
in
org.eclipse.rdf4j.model

Best Java code snippets using org.eclipse.rdf4j.model.ValueFactory (Showing top 20 results out of 918)

Refine searchRefine arrow

  • RDFHandler
  • Literal
  • Model
  • ByteArrayInputStream
  • ByteArrayOutputStream
  • IRI
  • Common ways to obtain ValueFactory
private void myMethod () {
ValueFactory v =
  • Codota IconSimpleValueFactory.getInstance()
  • Codota IconRepositoryConnection conn;conn.getValueFactory()
  • Codota IconRepository repository;repository.getValueFactory()
  • Smart code suggestions by Codota
}
origin: HuygensING/timbuctoo

@Override
public void addValue(String subject, String predicate, String value, String dataType, String graph)
 throws RdfProcessingFailedException {
 try {
  if (Objects.equals(subject, baseUri) && isDescriptionPredicate(predicate)) {
   ValueFactory vf = SimpleValueFactory.getInstance();
   model.add(vf.createIRI(subject), vf.createIRI(predicate), vf.createLiteral(value));
  }
 } catch (Exception e) {
  throw new RdfProcessingFailedException(e);
 }
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private void flushPendingStatement()
  throws RDFHandlerException
{
  if (predicate != null) {
    Resource res = valueFactory.createBNode();
    handler.handleStatement(valueFactory.createStatement(subject, predicate, res));
    subject = res;
  }
}
origin: jbarrasa/neosemantics

private Resource getResource(String s, ValueFactory vf) {
  // taken from org.eclipse.rdf4j.model.impl.SimpleIRI
  // explicit storage of blank nodes in the graph to be considered
  if(s.indexOf(58) >= 0){
    return vf.createIRI(s);
  } else{
    return vf.createBNode(s);
  }
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-inferencer

  private void addQueryNode(Model m, Resource implNode, IRI predicate, String queryText) {
    if (null != queryText) {
      ValueFactory factory = SimpleValueFactory.getInstance();
      BNode queryNode = factory.createBNode();
      m.add(implNode, predicate, queryNode);
      m.add(queryNode, RDF.TYPE, SP.CONSTRUCT_CLASS);
      m.add(queryNode, SP.TEXT_PROPERTY, factory.createLiteral(queryText));
    }
  }
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

public Literal evaluate(ValueFactory valueFactory, Value... args)
  throws ValueExprEvaluationException
{
  if (args.length != 1) {
    throw new ValueExprEvaluationException("UCASE requires exactly 1 argument, got " + args.length);
  }
  if (args[0] instanceof Literal) {
    Literal literal = (Literal)args[0];
    // UpperCase function accepts only string literal
    if (QueryEvaluationUtil.isStringLiteral(literal)) {
      String lexicalValue = literal.getLabel().toUpperCase();
      Optional<String> language = literal.getLanguage();
      if (language.isPresent()) {
        return valueFactory.createLiteral(lexicalValue, language.get());
      }
      else if (XMLSchema.STRING.equals(literal.getDatatype())) {
        return valueFactory.createLiteral(lexicalValue, XMLSchema.STRING);
      }
      else {
        return valueFactory.createLiteral(lexicalValue);
      }
    }
    else {
      throw new ValueExprEvaluationException("unexpected input value for function: " + args[0]);
    }
  }
  else {
    throw new ValueExprEvaluationException("unexpected input value for function: " + args[0]);
  }
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-queryalgebra-evaluation

protected Literal convert(ValueFactory valueFactory, Value value)
  throws ValueExprEvaluationException
{
  if (value instanceof Literal) {
    Literal literal = (Literal)value;
    IRI datatype = literal.getDatatype();
    if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
      // FIXME: doubles must be processed separately, see
      // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
      try {
        double doubleValue = literal.doubleValue();
        return valueFactory.createLiteral(doubleValue);
      }
      catch (NumberFormatException e) {
        throw new ValueExprEvaluationException(e.getMessage(), e);
      }
    }
    else if (datatype.equals(XMLSchema.BOOLEAN)) {
      try {
        return valueFactory.createLiteral(literal.booleanValue() ? 1.0 : 0.0);
      }
      catch (IllegalArgumentException e) {
        throw typeError(literal, e);
      }
    }
  }
  throw typeError(value, null);
}
origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

protected Literal convert(ValueFactory valueFactory, Value value)
  throws ValueExprEvaluationException
{
  if (value instanceof Literal) {
    Literal literal = (Literal)value;
    IRI datatype = literal.getDatatype();
    if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
      // FIXME: floats and doubles must be processed separately, see
      // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
      try {
        BigDecimal decimalValue = literal.decimalValue();
        return valueFactory.createLiteral(decimalValue.toPlainString(), XMLSchema.DECIMAL);
      }
      catch (NumberFormatException e) {
        throw typeError(literal, e);
      }
    }
    else if (datatype.equals(XMLSchema.BOOLEAN)) {
      try {
        return valueFactory.createLiteral(literal.booleanValue() ? "1.0" : "0.0",
            XMLSchema.DECIMAL);
      }
      catch (IllegalArgumentException e) {
        throw typeError(literal, e);
      }
    }
  }
  throw typeError(value, null);
}
origin: org.apache.any23/apache-any23-core

/**
 * Creates a {@link Literal}.
 * @param f float representation of the {@link org.eclipse.rdf4j.model.Literal}
 * @return valid {@link org.eclipse.rdf4j.model.Literal}
 */
public static Literal literal(float f) {
  return valueFactory.createLiteral(f);
}
origin: org.eclipse.rdf4j/rdf4j-query

private void reportStatement(Resource subject, IRI predicate, Value object)
  throws RDFHandlerException
{
  rdfHandler.handleStatement(vf.createStatement(subject, predicate, object));
}
origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

protected Literal convert(ValueFactory valueFactory, Value value)
  throws ValueExprEvaluationException
{
  if (value instanceof Literal) {
    Literal literal = (Literal)value;
    IRI datatype = literal.getDatatype();
    if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
      // FIXME: doubles must be processed separately, see
      // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive
      try {
        float floatValue = literal.floatValue();
        return valueFactory.createLiteral(floatValue);
      }
      catch (NumberFormatException e) {
        throw typeError(literal, e);
      }
    }
    else if (datatype.equals(XMLSchema.BOOLEAN)) {
      try {
        return valueFactory.createLiteral(literal.booleanValue() ? 1f : 0f);
      }
      catch (IllegalArgumentException e) {
        throw typeError(literal, e);
      }
    }
  }
  throw typeError(value, null);
}
origin: apache/incubator-rya

/**
 * Creates a copy tool parent time offset {@link RyaStatement} from the specified offset.
 * @param timeOffset the copy tool parent time offset. (in milliseconds).
 * @return the {@link RyaStatement} for the copy tool parent time offset.
 */
public static RyaStatement createTimeOffsetRyaStatement(final long timeOffset) {
  final Literal literal = VALUE_FACTORY.createLiteral(timeOffset);
  final RyaType timeObject = new RyaType(literal.getDatatype(), literal.stringValue());
  return new RyaStatement(RTS_SUBJECT_RYA, RTS_TIME_OFFSET_PREDICATE_RYA, timeObject);
}
origin: org.eclipse.rdf4j/rdf4j-sail-lucene-api

@Override
public Resource export(Model m) {
  Resource implNode = super.export(m);
  ValueFactory vf = SimpleValueFactory.getInstance();
  m.setNamespace("sl", LuceneSailConfigSchema.NAMESPACE);
  if (indexDir != null) {
    m.add(implNode, INDEX_DIR, SimpleValueFactory.getInstance().createLiteral(indexDir));
  }
  for (String key : getParameterNames()) {
    m.add(implNode, vf.createIRI(LuceneSailConfigSchema.NAMESPACE, key),
        vf.createLiteral(getParameter(key)));
  }
  return implNode;
}
origin: inception-project/inception

private Set<Statement> reifyQualifier(KnowledgeBase kb, KBQualifier aQualifier)
{
  Resource statementId = vf.createBNode(aQualifier.getKbStatement().getStatementId());
  KBHandle qualifierProperty = aQualifier.getKbProperty();
  IRI qualifierPredicate = vf.createIRI(qualifierProperty.getIdentifier());
  Value qualifierValue = valueMapper.mapQualifierValue(aQualifier, vf);
  Statement qualifierStatement = vf
    .createStatement(statementId, qualifierPredicate, qualifierValue);
  Set<Statement> originalStatements = new HashSet<>();
  originalStatements.add(qualifierStatement); //id P V
  return originalStatements;
}
origin: org.eclipse.rdf4j/rdf4j-repository-sparql

@Override
public Resource export(Model m) {
  Resource implNode = super.export(m);
  m.setNamespace("sparql", NAMESPACE);
  if (getQueryEndpointUrl() != null) {
    m.add(implNode, QUERY_ENDPOINT, vf.createIRI(getQueryEndpointUrl()));
  }
  if (getUpdateEndpointUrl() != null) {
    m.add(implNode, UPDATE_ENDPOINT, vf.createIRI(getUpdateEndpointUrl()));
  }
  return implNode;
}
origin: org.apache.any23/apache-any23-core

/**
 * Creates a {@link org.eclipse.rdf4j.model.IRI}.
 * @param namespace a base namespace for the {@link org.eclipse.rdf4j.model.IRI}
 * @param localName a local name to associate with the namespace
 * @return a valid {@link org.eclipse.rdf4j.model.IRI}
 */
public static org.eclipse.rdf4j.model.IRI iri(String namespace, String localName) {
  return valueFactory.createIRI(namespace, localName);
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

  @Override
  protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2)
    throws ValueExprEvaluationException
  {
    if (!(arg1 instanceof Literal)) {
      throw new ValueExprEvaluationException("First argument must be a literal");
    }
    if (!(arg2 instanceof IRI)) {
      throw new ValueExprEvaluationException("Second argument must be a datatype");
    }
    Literal value = (Literal)arg1;
    IRI targetDatatype = (IRI)arg2;
    Function func = FunctionRegistry.getInstance().get(targetDatatype.stringValue()).orElse(null);
    return (func != null) ? func.evaluate(valueFactory, value)
        : valueFactory.createLiteral(value.getLabel(), targetDatatype);
  }
}
origin: HuygensING/timbuctoo

@Override
public void delValue(String subject, String predicate, String value, String dataType, String graph)
 throws RdfProcessingFailedException {
 try {
  if (Objects.equals(subject, baseUri)) {
   ValueFactory vf = SimpleValueFactory.getInstance();
   model.remove(vf.createIRI(subject), vf.createIRI(predicate), vf.createLiteral(value));
  }
 } catch (Exception e) {
  throw new RdfProcessingFailedException(e);
 }
}
origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

public Value evaluate(Lang node, BindingSet bindings)
  throws ValueExprEvaluationException, QueryEvaluationException
{
  Value argValue = evaluate(node.getArg(), bindings);
  if (argValue instanceof Literal) {
    Literal literal = (Literal)argValue;
    return tripleSource.getValueFactory().createLiteral(literal.getLanguage().orElse(""));
  }
  throw new ValueExprEvaluationException();
}
origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

  @Override
  protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2)
    throws ValueExprEvaluationException
  {
    if (!(arg1 instanceof Literal) || !(arg2 instanceof Literal)) {
      throw new ValueExprEvaluationException("Both arguments must be literals");
    }
    Literal date = (Literal)arg1;
    Literal format = (Literal)arg2;

    SimpleDateFormat formatter = new SimpleDateFormat(format.getLabel());
    String value = formatter.format(date.calendarValue().toGregorianCalendar().getTime());
    return valueFactory.createLiteral(value);
  }
}
origin: apache/incubator-rya

@Test
public void periodicNodeNotPresentTest() throws Exception {
  
  List<ValueExpr> values = Arrays.asList(new Var("time"), new ValueConstant(VF.createLiteral(12.0)), new ValueConstant(VF.createLiteral(6.0)), new ValueConstant(VF.createIRI(PeriodicQueryUtil.temporalNameSpace + "hours")));
  FunctionCall func = new FunctionCall("uri:func", values);
  Optional<PeriodicQueryNode> node1 = PeriodicQueryUtil.getPeriodicQueryNode(func, new Join());
  Assert.assertEquals(false, node1.isPresent());
}
org.eclipse.rdf4j.modelValueFactory

Javadoc

A factory for creating IRI, BNode, Literal and Statement based on the RDF-1.1 Concepts and Abstract Syntax, a W3C Recommendation.

Most used methods

  • createIRI
    Creates a new IRI from the supplied namespace and local name. Calling this method is funtionally equ
  • createLiteral
  • createStatement
    Creates a new statement with the supplied subject, predicate and object and associated context.
  • createBNode
    Creates a new blank node with the given node identifier.
  • createURI
    Creates a new URI from the supplied namespace and local name.

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • requestLocationUpdates (LocationManager)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JButton (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now