Package org.openrdf.model

Examples of org.openrdf.model.Literal


    while (iter.hasNext()) {
      Att att = iter.next();

      URI predicate = createURI(att.getURI());
      Literal lit = createLiteral(att.getValue(), xmlLang, null);

      reportStatement(subject, predicate, lit);
    }
  }
View Full Code Here


        }

        if (isEmptyElt) {
          NodeElement subject = (NodeElement)peekStack(1);

          Literal lit = createLiteral("", null, RDF.XMLLITERAL);

          reportStatement(subject.getResource(), propURI, lit);

          handleReification(lit);
        }
        else {
          // The next string is an rdf:XMLLiteral
          predicate.setDatatype(RDF.XMLLITERAL);

          saxFilter.setParseLiteralMode();
        }
      }
    }
    // parseType == null
    else if (isEmptyElt) {
      // empty element without an rdf:parseType attribute

      // Note: we handle rdf:datatype attributes here to allow datatyped
      // empty strings in documents. The current spec does have a
      // production rule that matches this, which is likely to be an
      // omission on its part.
      Att datatype = atts.getAtt(RDF.NAMESPACE, "datatype");

      if (atts.size() == 0 || atts.size() == 1 && datatype != null) {
        // element had no attributes, or only the optional
        // rdf:ID and/or rdf:datatype attributes.
        NodeElement subject = (NodeElement)peekStack(1);

        URI dtURI = null;
        if (datatype != null) {
          dtURI = createURI(datatype.getValue());
        }

        Literal lit = createLiteral("", xmlLang, dtURI);

        reportStatement(subject.getResource(), propURI, lit);
        handleReification(lit);
      }
      else {
View Full Code Here

        }

        writeEndOfEmptyTag();
      }
      else if (obj instanceof Literal) {
        Literal objLit = (Literal)obj;

        // language attribute
        if (objLit.getLanguage() != null) {
          writeAttribute("xml:lang", objLit.getLanguage());
        }

        // datatype attribute
        boolean isXMLLiteral = false;
        URI datatype = objLit.getDatatype();
        if (datatype != null) {
          // Check if datatype is rdf:XMLLiteral
          isXMLLiteral = datatype.equals(RDF.XMLLITERAL);

          if (isXMLLiteral) {
            writeAttribute(RDF.NAMESPACE, "parseType", "Literal");
          }
          else {
            writeAttribute(RDF.NAMESPACE, "datatype", datatype.toString());
          }
        }

        writeEndOfStartTag();

        // label
        if (isXMLLiteral) {
          // Write XML literal as plain XML
          writer.write(objLit.getLabel());
        }
        else {
          writeCharacterData(objLit.getLabel());
        }

        writeEndTag(predNamespace, predLocalName);
      }
View Full Code Here

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

    try {
      Literal tripleIndexLit = model.filter(implNode, TRIPLE_INDEXES, null).objectLiteral();
      if (tripleIndexLit != null) {
        setTripleIndexes((tripleIndexLit).getLabel());
      }

      Literal forceSyncLit = model.filter(implNode, FORCE_SYNC, null).objectLiteral();
      if (forceSyncLit != null) {
        try {
          setForceSync(forceSyncLit.booleanValue());
        }
        catch (IllegalArgumentException e) {
          throw new StoreConfigException("Boolean value required for " + FORCE_SYNC
              + " property, found " + forceSyncLit);
        }
View Full Code Here

    else if (value instanceof BNode) {
      dataOut.writeByte(BNODE_MARKER);
      writeString(((BNode)value).getID(), dataOut);
    }
    else if (value instanceof Literal) {
      Literal lit = (Literal)value;

      String label = lit.getLabel();
      String language = lit.getLanguage();
      URI datatype = lit.getDatatype();

      if (datatype != null) {
        dataOut.writeByte(DATATYPE_LITERAL_MARKER);
        writeString(label, dataOut);
        writeValue(datatype, dataOut);
View Full Code Here

    for (Value space : model.filter(implNode, LOCALPROPERTYSPACE, null).objects()) {
      addLocalPropertySpace(space.stringValue());
    }

    try {
      Literal distinctLit = model.filter(implNode, DISTINCT, null).objectLiteral();
      if (distinctLit != null) {
        try {
          distinct = distinctLit.booleanValue();
        }
        catch (IllegalArgumentException e) {
          throw new StoreConfigException(
              "Invalid boolean value for <distinct> parameter in federation config: " + distinctLit);
        }
      }
    }
    catch (ModelException e) {
      throw new StoreConfigException("Invalid or inconsistent <distinct> parameter for federation config");
    }

    try {
      Literal readOnlyLit = model.filter(implNode, READ_ONLY, null).objectLiteral();
      if (readOnlyLit != null) {
        try {
          readOnly = readOnlyLit.booleanValue();
        }
        catch (IllegalArgumentException e) {
          throw new StoreConfigException(
              "Invalid boolean value for <readOnly> parameter in federation config: " + readOnlyLit);
        }
View Full Code Here

  {
    String label = (String)node.getLabel().jjtAccept(this, null);
    String lang = node.getLang();
    ASTIRI datatypeNode = node.getDatatype();

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

  }

  private Statement getIDStatement(RepositoryConnection con, String repositoryID)
    throws StoreException, StoreConfigException
  {
    Literal idLiteral = con.getValueFactory().createLiteral(repositoryID);
    List<Statement> idStatementList = con.match(null, REPOSITORYID, idLiteral, true).asList();

    if (idStatementList.size() == 1) {
      return idStatementList.get(0);
    }
View Full Code Here

   * types.
   */
  public void testOrder1()
    throws Exception
  {
    Literal en4 = vf.createLiteral("4", "en");
    Literal int10 = vf.createLiteral(10);
    Literal int9 = vf.createLiteral(9);

    List<Literal> valueList = Arrays.asList(en4, int10, int9);
    Collections.sort(valueList, cmp);

    assertTrue(valueList.indexOf(int9) < valueList.indexOf(int10));
View Full Code Here

   * value types.
   */
  public void testOrder2()
    throws Exception
  {
    Literal en4 = vf.createLiteral("4", "en");
    Literal int10 = vf.createLiteral(10);
    Literal int9 = vf.createLiteral(9);
    Literal plain9 = vf.createLiteral("9");
    Literal integer5 = vf.createLiteral("5", XMLSchema.INTEGER);
    Literal float9 = vf.createLiteral(9f);
    Literal plain4 = vf.createLiteral("4");
    Literal plain10 = vf.createLiteral("10");

    List<Literal> valueList = Arrays.asList(en4, int10, int9, plain9, integer5, float9, plain4, plain10);
    Collections.sort(valueList, cmp);

    assertTrue(valueList.indexOf(integer5) < valueList.indexOf(float9));
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.