Package org.ontoware.rdf2go.model.node

Examples of org.ontoware.rdf2go.model.node.Node


   * @throws ModelRuntimeException
   *             if object could not be converted to an RDF object
   */
  public boolean containsValue(Object value) {
    try {
      Node node = TypeUtils.toNode(value);
      // if no exception, node not null
      assert node != null;
      return this.model.contains(this.id, Variable.ANY, node);
    } catch (ModelRuntimeException e) {
      log.debug("an instance of " + value.getClass()
View Full Code Here


            Variable.ANY);
    try {
      StringBuffer lBuf = new StringBuffer();
      while(queryC.hasNext()) {
        Statement answer = queryC.next();
        Node vl = answer.getObject();
        lBuf.append(vl.toString().concat(" "));
      }
      String l = lBuf.toString();
      if(l.length() > 0)
        this.outP.println("     * Label: " + l);
    } finally {
      queryC.close();
    }
   
    queryC = this.model.findStatements(uri, RDFS.comment, Variable.ANY);
    try {
      String l = "";
      while(queryC.hasNext()) {
        Statement answer = queryC.next();
        Node vl = answer.getObject();
        l += vl.toString() + " ";
      }
      if(l.length() > 0)
        this.outP.println("     * Comment: " + l);
    } finally {
      queryC.close();
    }
   
    queryC = this.model.findStatements(uri, RDFS.domain, Variable.ANY);
    try {
      String l = "";
      while(queryC.hasNext()) {
        Statement answer = queryC.next();
        Node vl = answer.getObject();
        l += vl.toString() + " ";
      }
      if(l.length() > 0)
        this.outP.println("     * Comment: " + l);
    } finally {
      queryC.close();
    }
   
    queryC = this.model.findStatements(uri, RDFS.range, Variable.ANY);
    try {
      String l = "";
      while(queryC.hasNext()) {
        Statement answer = queryC.next();
        Node vl = answer.getObject();
        l += vl.toString() + " ";
      }
      if(l.length() > 0)
        this.outP.println("     * Range: " + l);
    } finally {
      queryC.close();
View Full Code Here

    ClosableIterator<Statement> it = model.iterator();
    while(it.hasNext()) {
      Statement stmt = it.next();
      Resource s = stmt.getSubject();
      URI p = stmt.getPredicate();
      Node o = stmt.getObject();
     
      boolean match = false;
      if(s instanceof URI && s.asURI().toString().startsWith(searchURIPrefix)) {
        match = true;
        String sURI = s.asURI().toString().replace(searchURIPrefix, replaceURIPrefix);
        s = new URIImpl(sURI);
      }
      if(p.toString().startsWith(searchURIPrefix)) {
        match = true;
        String pURI = p.toString().replace(searchURIPrefix, replaceURIPrefix);
        p = new URIImpl(pURI);
       
      }
      if(o instanceof URI && o.asURI().toString().startsWith(searchURIPrefix)) {
        match = true;
        String oURI = o.asURI().toString().replace(searchURIPrefix, replaceURIPrefix);
        o = new URIImpl(oURI);
      }
     
      if(match) {
        remove.addStatement(stmt);
View Full Code Here

  public static String getGoodLabel(Node o, Model source) {
    if(o == null)
      return null;
    if(o instanceof Resource) {
      // resource
      Node rdfslabel = RDFTool.getSingleValue(source, (Resource)o, RDFS.label);
      if(rdfslabel != null) {
        if(rdfslabel instanceof Literal)
          return ((Literal)rdfslabel).getValue();
        // else
        return rdfslabel.toString();
      }
      // else
      return RDFTool.getShortName(o.toString());
    } else if(o instanceof Literal)
      return ((Literal)o).getValue();
View Full Code Here

   * @param pred the predicate to read
   * @return a string representation of the value, or null. Literals are
   *         returned using their Value (not toString()).
   */
  public static String getSingleValueString(Model m, Resource res, URI pred) {
    Node n = getSingleValue(m, res, pred);
    if(n == null)
      return null;
   
    if(n instanceof Literal)
      // Literal
      return ((Literal)n).getValue();
    return n.toString();
  }
View Full Code Here

   * @param pred the predicate to read
   * @return a string representation of the value, or null. Literals are
   *         returned using their Value (not toString()).
   */
  public static String getSingleValueString(ModelSet modelset, Resource res, URI pred) {
    Node n = getSingleValue(modelset, res, pred);
    if(n == null)
      return null;
   
    if(n instanceof Literal)
      // Literal
      return ((Literal)n).getValue();
    return n.toString();
  }
View Full Code Here

  }

  public String getLiteralValue(String varName)
    throws ModelRuntimeException
  {
    Node node = getValue(varName);
    if (node instanceof Literal) {
      return ((Literal)node).getValue();
    }
    else {
      throw new ModelRuntimeException("Node is not a literal: " + node);
View Full Code Here

   */
  @Patrolled
  public static boolean containsGivenValue(Model model, Resource resource,
      URI propertyURI, Object value) throws ModelRuntimeException {

    Node objectNode = RDFReactorRuntime.java2node(model, value);
    return model.contains(resource, propertyURI, objectNode);
  }
View Full Code Here

   */
  @Patrolled
  public static Object getValue(Model model, Resource resourceSubject,
      URI propertyURI, java.lang.Class<?> returnType)
      throws RDFDataException, ModelRuntimeException {
    Node node = ResourceUtils.getSingleValue(model, resourceSubject,
        propertyURI);
    return RDFReactorRuntime.node2javatype(model, node, returnType);
  }
View Full Code Here

    synchronized (model) {
      ClosableIterator<? extends Statement> it = model.findStatements(
          resource, propertyURI, Variable.ANY);
      Set<Object> result = new HashSet<Object>();
      while (it.hasNext()) {
        Node rdfnode = it.next().getObject();
        result.add(RDFReactorRuntime.node2javatype(model, rdfnode,
            returnType));
      }
      it.close();
      return result;
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.node.Node

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.