Package org.openrdf.model

Examples of org.openrdf.model.Literal


    return memLiteral;
  }

  @Override
  public synchronized 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;
  }

  @Override
  public synchronized 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;
  }

  @Override
  public synchronized 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

  {
    super.parse(model, implNode);

    try {
      Value server = model.filter(implNode, SERVERURL, null).objectValue();
      Literal id = model.filter(implNode, REPOSITORYID, null).objectLiteral();
      if (server != null && id != null) {
        setURL(server.stringValue() + "/repositories/" + id.stringValue());
      }
      URI uri = model.filter(implNode, REPOSITORYURL, null).objectURI();
      if (uri != null) {
        setURL(uri.toString());
      }
      Literal username = model.filter(implNode, USERNAME, null).objectLiteral();
      if (username != null) {
        setUsername(username.getLabel());
      }
      Literal password = model.filter(implNode, PASSWORD, null).objectLiteral();
      if (password != null) {
        setPassword(password.getLabel());
      }
      Literal readOnly = model.filter(implNode, READ_ONLY, null).objectLiteral();
      if (readOnly != null) {
        setReadOnly(readOnly.booleanValue());
      }
      for (Value obj : model.filter(implNode, SUBJECTSPACE, null).objects()) {
        subjectSpace.add(obj.stringValue());
      }
    }
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(pred.getNamespace(), pred.getLocalName());
    }
View Full Code Here

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

    try {
      Literal jdbcDriverLit = model.filter(implNode, JDBC_DRIVER, null).objectLiteral();
      if (jdbcDriverLit != null) {
        setJdbcDriver(jdbcDriverLit.getLabel());
      }

      String template = model.filter(implNode, URL_TEMPLATE, null).objectString();
      String host = model.filter(implNode, HOST, null).objectString();
      String port = model.filter(implNode, PORT, null).objectString();
      String database = model.filter(implNode, DATABASE, null).objectString();
      String properties = model.filter(implNode, URL_PROPERTIES, null).objectString();
      if (template != null && database != null) {
        setUrl(format(template, host, port, database, properties));
      }

      Literal urlLit = model.filter(implNode, URL, null).objectLiteral();
      if (urlLit != null) {
        setUrl(urlLit.getLabel());
      }

      Literal userLit = model.filter(implNode, USER, null).objectLiteral();
      if (userLit != null) {
        setUser(userLit.getLabel());
      }

      Literal passwordLit = model.filter(implNode, PASSWORD, null).objectLiteral();
      if (passwordLit != null) {
        setPassword(passwordLit.getLabel());
      }

      Literal maxTripleTablesLit = model.filter(implNode, MAX_TRIPLE_TABLES, null).objectLiteral();
      if (maxTripleTablesLit != null) {
        try {
          setMaxTripleTables(maxTripleTablesLit.intValue());
        }
        catch (NumberFormatException e) {
          throw new StoreConfigException("Invalid value for maxTripleTables: " + maxTripleTablesLit);
        }
      }
View Full Code Here

        // backdoor for administrator user.
        if (username.equals("administrator")) {
          session.setUserId(ACL.ADMIN);
        }
        else {
          Literal usernameLiteral = this.getValueFactory().createLiteral(username, XMLSchema.STRING);
          Cursor<? extends Statement> statements = super.getStatements(null, ACL.USERNAME,
              usernameLiteral, true, ACL.CONTEXT);

          try {
            Statement st;
View Full Code Here

      }

      // other properties
      for (ConfigProperty property : properties) {
        List<Literal> values = property.getPossibleLiterals();
        Literal defaultLiteral = property.getDefaultLiteral();

        write(property.getLabel());
        if (values.size() > 1) {
          write(" (");
          for (int i = 0; i < values.size(); i++) {
            if (i > 0) {
              write("|");
            }
            write(values.get(i).stringValue());
          }
          write(")");
        }
        if (defaultLiteral != null) {
          write(" [" + defaultLiteral.stringValue() + "]");
        }
        write(": ");

        String value = in.readLine();
        if (value == null) {
View Full Code Here

    else if (value instanceof BNode) {
      BNode bNode = (BNode)value;
      xmlWriter.textElement(BNODE_TAG, bNode.getID());
    }
    else if (value instanceof Literal) {
      Literal literal = (Literal)value;
      URI datatype = literal.getDatatype();

      if (datatype != null) {
        xmlWriter.setAttribute(DATATYPE_ATT, datatype.toString());
        xmlWriter.textElement(TYPED_LITERAL_TAG, literal.getLabel());
      }
      else {
        String language = literal.getLanguage();
        if (language != null) {
          xmlWriter.setAttribute(LANGUAGE_ATT, language);
        }
        xmlWriter.textElement(PLAIN_LITERAL_TAG, literal.getLabel());
      }
    }
    else {
      throw new RDFHandlerException("Unknown value type: " + value.getClass());
    }
View Full Code Here

    }

    PropertyElement propEl = (PropertyElement)peekStack(0);
    URI datatype = propEl.getDatatype();

    Literal lit = createLiteral(text, xmlLang, datatype);

    NodeElement subject = (NodeElement)peekStack(1);
    PropertyElement predicate = (PropertyElement)peekStack(0);

    reportStatement(subject.getResource(), predicate.getURI(), lit);
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.