Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.LiteralImpl


    for (int i=0;i<512;i++) {
      sb.append(Character.toChars('A' + (i%26)));
    }
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    Literal obj = new LiteralImpl("guernica" + sb.toString(), "es");

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here


      ValueExpr arg = countOp.getArg();

      if (arg != null) {
        Set<Value> values = makeValueSet(arg, bindingSets);
        return new LiteralImpl(Integer.toString(values.size()), XMLSchema.INTEGER);
      }
      else {
        return new LiteralImpl(Integer.toString(bindingSets.size()), XMLSchema.INTEGER);
      }
    }
    else if (operator instanceof Min) {
      Min minOp = (Min)operator;

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

      // 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(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
          }
        }
      }

      return new LiteralImpl(Double.toString(max), XMLSchema.DOUBLE);
    }

    return null;
  }
View Full Code Here

      try {
        while (iter.hasNext()) {
          Namespace ns = iter.next();

          Literal prefix = new LiteralImpl(ns.getPrefix());
          Literal namespace = new LiteralImpl(ns.getName());

          BindingSet bindingSet = new ListBindingSet(columnNames, prefix, namespace);
          namespaces.add(bindingSet);
        }
      }
View Full Code Here

    List<String> bindingNames = Arrays.asList("a", "b", "c");

    MapBindingSet solution1 = new MapBindingSet(bindingNames.size());
    solution1.addBinding("a", new URIImpl("foo:bar"));
    solution1.addBinding("b", new BNodeImpl("bnode"));
    solution1.addBinding("c", new LiteralImpl("baz"));

    MapBindingSet solution2 = new MapBindingSet(bindingNames.size());
    solution2.addBinding("a", new LiteralImpl("1", XMLSchema.INTEGER));
    solution2.addBinding("c", new LiteralImpl("Hello World!", "en"));

    List<? extends BindingSet> bindingSetList = Arrays.asList(solution1, solution2);

    TupleQueryResultImpl result = new TupleQueryResultImpl(bindingNames, bindingSetList);
View Full Code Here

    return memBNode;
  }

  public Literal createLiteral(String value) {
    Literal tempLiteral = new LiteralImpl(value);
    MemLiteral memLiteral = literalRegistry.get(tempLiteral);

    if (memLiteral == null) {
      memLiteral = createMemLiteral(tempLiteral);
    }
View Full Code Here

    return memLiteral;
  }

  public Literal createLiteral(String value, String language) {
    Literal tempLiteral = new LiteralImpl(value, language);
    MemLiteral memLiteral = literalRegistry.get(tempLiteral);

    if (memLiteral == null) {
      memLiteral = createMemLiteral(tempLiteral);
    }
View Full Code Here

    return memLiteral;
  }

  public Literal createLiteral(String value, URI datatype) {
    Literal tempLiteral = new LiteralImpl(value, datatype);
    MemLiteral memLiteral = literalRegistry.get(tempLiteral);

    if (memLiteral == null) {
      memLiteral = createMemLiteral(tempLiteral);
    }
View Full Code Here

   * @param v A <code>Value</code>
   * @return A copy of the original <code>Value</code>
   */
  public static Value dupValue(Value v) {
    if (v instanceof Literal)
      return new LiteralImpl(((Literal) v).getLabel(), ((Literal) v).getDatatype());
   
    return dupResource((Resource) v);
  }
View Full Code Here

                NoSuchPropertyResult nspr = new NoSuchPropertyResult(FresnelUtilities.dupURI(predicate), selector, r);
                nspr.setTitle(resolveLabel(in, predicate));
                r.addProperty(nspr);
                this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), nspr);
                RepositoryConnection nconn = this._notModel.getConnection();
                nconn.add(FresnelUtilities.dupResource(focus), FresnelUtilities.dupURI(predicate), new LiteralImpl("empty"));
                nconn.close();
              } // if it's not null, there's nothing to do
            } else {
              Iterator<Statement> pi = ((PropertyDescription) selector).getProperty().selectStatements(in, focus);
              if (pi.hasNext()) {
                URI predicate = pi.next().getPredicate();
                PropertyResult pr = r.getProperties().lookup(predicate);
                if (null == pr) {
                  NoSuchPropertyResult nspr = new NoSuchPropertyResult(FresnelUtilities.dupURI(predicate), selector, r);
                  nspr.setTitle(resolveLabel(in, predicate));
                  r.addProperty(nspr);
                  this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), nspr);
                  RepositoryConnection nconn = this._notModel.getConnection();
                  nconn.add(FresnelUtilities.dupResource(focus), FresnelUtilities.dupURI(predicate), new LiteralImpl("empty"));
                  nconn.close();
                } // if it's not null, there's nothing to do
              }
            }
          }
View Full Code Here

      Resource resource = (Resource)value;
      return getResource(resource);
    } else if (value instanceof Literal) {
      Literal literal = (Literal)value;
      if (literal.getLanguage() != null) {
        return new LiteralImpl(literal.getLabel(), literal.getLanguage());
      } else if (literal.getDatatype() != null) {
        return new LiteralImpl(literal.getLabel(), new org.openrdf.model.impl.URIImpl(literal.getDatatype().getURI()));
      } else if (literal.getLabel() != null){//XXX
        return new LiteralImpl(literal.getLabel());
      } else
        return null;
    } else {
      return null;
    }
View Full Code Here

TOP

Related Classes of org.openrdf.model.impl.LiteralImpl

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.