Package org.openrdf.model

Examples of org.openrdf.model.URI


  public List<ConfigProperty> getProperties(Locale locale)
    throws IOException
  {
    List<ConfigProperty> properties = new ArrayList<ConfigProperty>();
    for (Statement st : statements) {
      URI pred = st.getPredicate();
      if (schema.contains(pred, null, null)) {
        properties.add(new ConfigProperty(pred, st.getObject(), locale, schema));
      }
    }
    return properties;
View Full Code Here


    }

    int result = 0;

    // Sort by datatype first, plain literals come before datatyped literals
    URI leftDatatype = leftLit.getDatatype();
    URI rightDatatype = rightLit.getDatatype();

    if (leftDatatype != null) {
      if (rightDatatype != null) {
        // Both literals have datatypes
        result = compareDatatypes(leftDatatype, rightDatatype);
View Full Code Here

  @Override
  public Object visit(ASTFunctionCall node, Object data)
    throws VisitorException
  {
    ValueConstant uriNode = (ValueConstant)node.jjtGetChild(0).jjtAccept(this, null);
    URI functionURI = (URI)uriNode.getValue();

    FunctionCall functionCall = new FunctionCall(functionURI.toString());

    for (int i = 1; i < node.jjtGetNumChildren(); i++) {
      Node argNode = node.jjtGetChild(i);
      functionCall.addArg((ValueExpr)argNode.jjtAccept(this, null));
    }
View Full Code Here

    int idx = 0;
    Model model = new LinkedHashModel();
    model.getNamespaces().putAll(statements.getNamespaces());
    for (Statement st : statements) {
      Resource subj = st.getSubject();
      URI pred = st.getPredicate();
      if (schema.contains(pred, null, null) && properties != null) {
        if (!properties.get(idx).getPredicate().equals(pred)) {
          throw new IllegalArgumentException("Invalid properties");
        }
        model.add(subj, pred, properties.get(idx++).getValue());
View Full Code Here

  @Override
  public ValueConstant visit(ASTIRI node, Object data)
    throws VisitorException
  {
    URI uri;
    try {
      uri = valueFactory.createURI(node.getValue());
    }
    catch (IllegalArgumentException e) {
      // invalid URI
View Full Code Here

    String lang = node.getLang();
    ASTIRI datatypeNode = node.getDatatype();

    Literal literal;
    if (datatypeNode != null) {
      URI datatype;
      try {
        datatype = valueFactory.createURI(datatypeNode.getValue());
      }
      catch (IllegalArgumentException e) {
        // invalid URI
View Full Code Here

    throws ValueExprEvaluationException
  {
    if (value instanceof Literal) {
      Literal literal = (Literal)value;
      String label = literal.getLabel();
      URI datatype = literal.getDatatype();

      if (datatype == null || datatype.equals(XMLSchema.STRING)) {
        return label.length() > 0;
      }
      else if (datatype.equals(XMLSchema.BOOLEAN)) {
        if ("true".equals(label) || "1".equals(label)) {
          return true;
        }
        else {
          // also false for illegal values
          return false;
        }
      }
      else if (datatype.equals(XMLSchema.DECIMAL)) {
        try {
          String normDec = XMLDatatypeUtil.normalizeDecimal(label);
          return !normDec.equals("0.0");
        }
        catch (IllegalArgumentException e) {
View Full Code Here

    // - xsd:boolean
    // - xsd:dateTime
    // - xsd:string
    // - RDF term (equal and unequal only)

    URI leftDatatype = leftLit.getDatatype();
    URI rightDatatype = rightLit.getDatatype();

    Integer compareResult = null;

    if (QueryEvaluationUtil.isStringLiteral(leftLit) && QueryEvaluationUtil.isStringLiteral(rightLit)) {
      compareResult = leftLit.getLabel().compareTo(rightLit.getLabel());
    }
    else if (leftDatatype != null && rightDatatype != null) {
      URI commonDatatype = null;

      if (leftDatatype.equals(rightDatatype)) {
        commonDatatype = leftDatatype;
      }
      else if (XMLDatatypeUtil.isNumericDatatype(leftDatatype)
          && XMLDatatypeUtil.isNumericDatatype(rightDatatype))
      {
        // left and right arguments have different datatypes, try to find a
        // more general, shared datatype
        if (leftDatatype.equals(XMLSchema.DOUBLE) || rightDatatype.equals(XMLSchema.DOUBLE)) {
          commonDatatype = XMLSchema.DOUBLE;
        }
        else if (leftDatatype.equals(XMLSchema.FLOAT) || rightDatatype.equals(XMLSchema.FLOAT)) {
          commonDatatype = XMLSchema.FLOAT;
        }
        else if (leftDatatype.equals(XMLSchema.DECIMAL) || rightDatatype.equals(XMLSchema.DECIMAL)) {
          commonDatatype = XMLSchema.DECIMAL;
        }
        else {
          commonDatatype = XMLSchema.INTEGER;
        }
      }

      if (commonDatatype != null) {
        try {
          if (commonDatatype.equals(XMLSchema.DOUBLE)) {
            compareResult = Double.compare(leftLit.doubleValue(), rightLit.doubleValue());
          }
          else if (commonDatatype.equals(XMLSchema.FLOAT)) {
            compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
          }
          else if (commonDatatype.equals(XMLSchema.DECIMAL)) {
            compareResult = leftLit.decimalValue().compareTo(rightLit.decimalValue());
          }
          else if (XMLDatatypeUtil.isIntegerDatatype(commonDatatype)) {
            compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
          }
          else if (commonDatatype.equals(XMLSchema.BOOLEAN)) {
            Boolean leftBool = Boolean.valueOf(leftLit.booleanValue());
            Boolean rightBool = Boolean.valueOf(rightLit.booleanValue());
            compareResult = leftBool.compareTo(rightBool);
          }
          else if (XMLDatatypeUtil.isCalendarDatatype(commonDatatype)) {
            XMLGregorianCalendar left = leftLit.calendarValue();
            XMLGregorianCalendar right = rightLit.calendarValue();

            compareResult = left.compare(right);

            // Note: XMLGregorianCalendar.compare() returns compatible
            // values
            // (-1, 0, 1) but INDETERMINATE needs special treatment
            if (compareResult == DatatypeConstants.INDETERMINATE) {
              throw new ValueExprEvaluationException("Indeterminate result for date/time comparison");
            }
          }
          else if (commonDatatype.equals(XMLSchema.STRING)) {
            compareResult = leftLit.getLabel().compareTo(rightLit.getLabel());
          }
        }
        catch (IllegalArgumentException e) {
          // One of the basic-type method calls failed, try syntactic match
View Full Code Here

   * Checks whether the supplied literal is a "string literal". A "string
   * literal" is either a {@link #isSimpleLiteral(Literal) simple literal} or a
   * literal with datatype {@link XMLSchema#STRING xsd:string}.
   */
  public static boolean isStringLiteral(Literal l) {
    URI datatype = l.getDatatype();

    if (datatype == null) {
      return l.getLanguage() == null;
    }
    else {
      return datatype.equals(XMLSchema.STRING);
    }
  }
View Full Code Here

  @Override
  public void handleStatement(Statement st)
    throws RDFHandlerException
  {
    Resource subj = st.getSubject();
    URI pred = st.getPredicate();
    Value obj = st.getObject();
    Resource ctxt = st.getContext();

    if (!preserveBNodeIDs) {
      if (subj instanceof BNode) {
View Full Code Here

TOP

Related Classes of org.openrdf.model.URI

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.