Examples of OntResource


Examples of com.hp.hpl.jena.ontology.OntResource

    String ns = r.getNameSpace();
    if (ns == null || ns.trim().length() == 0) ns = null;
    String prefix = ontModel.getNsURIPrefix(r.getNameSpace());
    if (prefix == null || prefix.trim().length() == 0) prefix = null;
   
    OntResource ontR = null;
    try { ontR = (OntResource)r;} catch(Exception e) {}
    if (ontR == null)
      return new Label(r.getURI(), ns, prefix);
   
    String rdfsLabel = ontR.getLabel(null);
    String rdfsComment = ontR.getComment(null);
   
    return new Label(r.getURI(), ns, prefix, rdfsLabel, rdfsComment);
  }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

      } catch (ConversionException e) {
        logger.debug(e.getMessage());
      }
            for (; i != null && i.hasNext();) {
               
              OntResource superP = i.next();
              //if (superP.a)
                if (superP.isURIResource()) {
                  resources.add(superP);
                  if (recursive)
                    getParents(superP, resources, recursive);
                }
//                else {
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

      // unionOf
      else if (c.isUnionClass()) { // in form of unionOf or intersectionOf
        UnionClass uc = c.asUnionClass();
          for (Iterator<? extends OntClass> i = uc.listOperands(); i.hasNext(); ) {
              try {
                OntResource op = i.next();
//                OntClass op = (OntClass) i.next();
                getMembers(op, resources, recursive);
              } catch (ConversionException e) {
                logger.error(e.getMessage());
              }
          }
     
      // intersectionOf
      } else if (c.isIntersectionClass()) {
        IntersectionClass ic = c.asIntersectionClass();
          for (Iterator<? extends OntClass> i = ic.listOperands(); i.hasNext(); ) {
              try {
                OntResource op = i.next();
//                OntClass op = (OntClass) i.next();
                getMembers(op, resources, recursive);
              } catch (ConversionException e) {
                logger.error(e.getMessage());
              }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

   * @return
   */
  public HashMap<String, Label> getSubClasses(String classUri, boolean recursive) {

    HashSet<OntResource> resources = new HashSet<OntResource>();
    OntResource r = ontModel.getOntClass(classUri);
    if (r == null) return new HashMap<String, Label>();
    getChildren(r, resources, recursive);
    return getResourcesLabels(resources);
  }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

   * @return
   */
  public HashMap<String, Label> getSuperClasses(String classUri, boolean recursive) {
   
    HashSet<OntResource> resources = new HashSet<OntResource>();
    OntResource r = ontModel.getOntClass(classUri);
    if (r == null) return new HashMap<String, Label>();
    getParents(r, resources, recursive);
    return getResourcesLabels(resources);
  }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

   * @return
   */
  public HashMap<String, Label> getSubProperties(String propertyUri, boolean recursive) {

    HashSet<OntResource> resources = new HashSet<OntResource>();
    OntResource r = ontModel.getOntProperty(propertyUri);
    if (r == null) return new HashMap<String, Label>();
    getChildren(r, resources, recursive);
    return getResourcesLabels(resources);
  }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

   * @return
   */
  public HashMap<String, Label> getSuperProperties(String propertyUri, boolean recursive) {

    HashSet<OntResource> resources = new HashSet<OntResource>();
    OntResource r = ontModel.getOntProperty(propertyUri);
    if (r == null) return new HashMap<String, Label>();
    getParents(r, resources, recursive);
    return getResourcesLabels(resources);
  }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

  public static ArrayList<Literal> getDeclaredValues(DatatypeProperty dp) {
    ArrayList<Literal> declaredValues = new ArrayList<Literal>();
    Iterator it = dp.listRange();

    while (it.hasNext()) {
      OntResource resource = (OntResource) it.next();

      if (resource.isDataRange()) {

        DataRange dr = resource.asDataRange();
        Iterator itoof = dr.listOneOf();
        while (itoof.hasNext()) {
          Literal literal = (Literal) itoof.next();
          declaredValues.add(literal);
        }
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

    else if (RDFS.range.getURI().equals(predicate) || "ֵ��".equals(p)
        || "range".equals(p)) {
      OntProperty s_p = this.getOntModel().getOntProperty(subject);
      if (s_p != null) {
        QueryResult qr = new QueryResult(OntologyElement.ONTCLASS);
        OntResource range = s_p.getRange();
        if (range != null) {
          qr.add(wrap(range.asClass()));
          return qr;
        }
        return null;
      }
      return null;
View Full Code Here

Examples of com.hp.hpl.jena.ontology.OntResource

    Map subclasses = new HashMap();
 
    Iterator iter = classMap.keySet().iterator();
    while (iter.hasNext()) {
      //OntClass resource = (OntClass) iter.next();
      OntResource resource = (OntResource) iter.next();
 
      if (resource instanceof OntClass) {
        //get subclasses
        for (Iterator i=((OntClass)resource).listSubClasses(); i.hasNext();) {
          OntResource subclass = (OntResource) i.next();
          for (Iterator j=subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }
        }
        //get individuals
        for (Iterator i=((OntClass)resource).listInstances(); i.hasNext();) {
          OntResource subclass = (OntResource) i.next();
          for (Iterator j=subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }
        }
      } else if (resource instanceof Individual) {
        for (Iterator i=resource.listSameAs(); i.hasNext();) { 
          OntResource subclass = (OntResource) i.next();
          for (Iterator j=subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }   
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.