Package org.openrdf.model

Examples of org.openrdf.model.Literal


   * datatypes were to be sorted alphabetically.
   */
  public void testOrder3()
    throws Exception
  {
    Literal year1234 = vf.createLiteral("1234", XMLSchema.GYEAR);
    Literal float2000 = vf.createLiteral(2000f);
    Literal int1000 = vf.createLiteral(1000);

    List<Literal> valueList = Arrays.asList(year1234, float2000, int1000);
    Collections.sort(valueList, cmp);
    assertTrue(valueList.indexOf(int1000) < valueList.indexOf(float2000));
  }
View Full Code Here


  }

  public void testOrder()
    throws Exception
  {
    Literal en4 = vf.createLiteral("4", "en");
    Literal nine = vf.createLiteral(9);
    List<Literal> list = new ArrayList<Literal>();
    list.add(ten);
    list.add(en4);
    list.add(nine);
    Collections.sort(list, cmp);
View Full Code Here

      // FIXME: handle case where 'values' is empty
      double min = Double.POSITIVE_INFINITY;
      for (Value v : values) {
        if (v instanceof Literal) {
          Literal l = (Literal)v;
          try {
            min = Math.min(min, Double.parseDouble(l.getLabel()));
          }
          catch (NumberFormatException e) {
            // ignore
          }
        }
      }

      return new LiteralImpl(Double.toString(min), XMLSchema.DOUBLE);
    }
    else if (operator instanceof Max) {
      Max maxOp = (Max)operator;

      Set<Value> values = makeValueSet(strategy, maxOp.getArg(), bindingSets);

      // FIXME: handle case where 'values' is empty
      double max = Double.NEGATIVE_INFINITY;
      for (Value v : values) {
        if (v instanceof Literal) {
          Literal l = (Literal)v;
          try {
            max = Math.max(max, Double.parseDouble(l.getLabel()));
          }
          catch (NumberFormatException e) {
            // ignore
          }
        }
View Full Code Here

    Resource repImplNode = super.export(model);

    ValueFactory vf = ValueFactoryImpl.getInstance();

    if (includeInferred != null) {
      Literal bool = vf.createLiteral(includeInferred);
      model.add(repImplNode, INCLUDE_INFERRED, bool);
    }
    if (maxQueryTime > 0) {
      model.add(repImplNode, MAX_QUERY_TIME, vf.createLiteral(maxQueryTime));
    }
View Full Code Here

    throws StoreConfigException
  {
    super.parse(model, implNode);

    try {
      Literal includeInferred = model.filter(implNode, INCLUDE_INFERRED, null).objectLiteral();
      if (includeInferred != null) {
        setIncludeInferred(includeInferred.booleanValue());
      }
      Literal maxQueryTime = model.filter(implNode, MAX_QUERY_TIME, null).objectLiteral();
      if (maxQueryTime != null) {
        setMaxQueryTime(maxQueryTime.intValue());
      }
      Literal queryResultLimit = model.filter(implNode, QUERY_RESULT_LIMIT, null).objectLiteral();
      if (queryResultLimit != null) {
        setQueryResultLimit(queryResultLimit.intValue());
      }
      Literal queryLanguage = model.filter(implNode, QUERY_LANGUAGE, null).objectLiteral();
      if (queryLanguage != null) {
        setQueryLanguage(QueryLanguage.valueOf(queryLanguage.getLabel()));
      }

      Set<Value> objects = model.filter(implNode, READ_CONTEXT, null).objects();
      setReadContexts(objects.toArray(new URI[objects.size()]));
View Full Code Here

  public Model getConfig(String repositoryID)
    throws StoreConfigException
  {
    Model model = getSystemModel();
    Literal id = vf.createLiteral(repositoryID);
    for (Statement idStatement : model.filter(null, REPOSITORYID, id)) {
      Resource context = idStatement.getContext();

      if (context == null) {
        throw new StoreConfigException("No configuration context for repository " + repositoryID);
View Full Code Here

    boolean isRemoved = false;

    Model model = getSystemModel();

    // clear existing context
    Literal id = vf.createLiteral(repositoryID);
    for (Resource ctx : model.filter(null, REPOSITORYID, id).contexts()) {
      clearSystemModel(ctx);
      isRemoved = true;
    }
View Full Code Here

    }
    else if (dtNode != null) {
      throw new IllegalArgumentException("Unexpected datatype type: " + dtNode.getClass());
    }

    Literal literal;
    if (datatype != null) {
      literal = valueFactory.createLiteral(litNode.getLabel(), datatype);
    }
    else if (litNode.hasLang()) {
      literal = valueFactory.createLiteral(litNode.getLabel(), litNode.getLang());
View Full Code Here

    if (argValue instanceof URI) {
      return tripleSource.getValueFactory().createLiteral(argValue.toString());
    }
    else if (argValue instanceof Literal) {
      Literal literal = (Literal)argValue;

      if (QueryEvaluationUtil.isSimpleLiteral(literal)) {
        return literal;
      }
      else {
        return tripleSource.getValueFactory().createLiteral(literal.getLabel());
      }
    }
    else {
      throw new ValueExprEvaluationException();
    }
View Full Code Here

  {
    // FIXME: deprecate Label in favour of Str(?)
    Value argValue = evaluate(node.getArg(), bindings);

    if (argValue instanceof Literal) {
      Literal literal = (Literal)argValue;

      if (QueryEvaluationUtil.isSimpleLiteral(literal)) {
        return literal;
      }
      else {
        return tripleSource.getValueFactory().createLiteral(literal.getLabel());
      }
    }
    else {
      throw new ValueExprEvaluationException();
    }
View Full Code Here

TOP

Related Classes of org.openrdf.model.Literal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.