Package com.hp.hpl.jena.ontology

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


    }
    return false
  }
 
  public static Resource toList(OntModel ont, String type, String itemType) {
    OntClass c = ont.createClass(type);
    Resource i = ont.getResource(itemType);
    c.addSuperClass(RDF.List);     
    c.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.first,i));
    c.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.rest,c));
    return c;   
  }
View Full Code Here


      OntResource r = p.getRange();
      p.removeRange(r);
      Vector<Resource> v = new Vector<Resource>();
      v.add(RDF.nil);
      RDFList nil = ont.createList(v.iterator());
      OntClass c = ont.createEnumeratedClass(null,nil);
      if (rest!=null) rest.addRange(uri,c);
      Vector<Resource> u = new Vector<Resource>();
      u.add(r); u.add(c);
      p.addRange(ont.createUnionClass(null,ont.createList(u.iterator())));
    }
View Full Code Here

  }
 
  /** a list type */
 
  public Resource toOWL(OntModel ont, String uri, boolean createAnon, Context ctx) {
    OntClass cls = null;
   
    // try to establish the list member type (may be anonymous)
    String type = expandQName(ctx.getDefaultNS(),itemType, ont);
   
    // we don't like anonymous lists
    if (uri==null || (type!=null && type.startsWith(schema.XSD_URI) && !schema.isValidDatatype(type))) {
      // pass over anonymous simple types
      if (uri!=null) {
        cls = ont.createClass(uri);
        cls.addSuperClass(RDF.List);   
        return cls;
      } else return RDF.List;
    }
   
    // the type may be null for embedded simpleType
    Resource first = null;
    if (type==null) {
      simpleType t = get_type(ctx);
      first = t.toOWL(ctx);
    }
    else first = schema.toOWL(ont,type);
   
    if (uri!=null || createAnon) {
      cls = ont.createClass(uri);
      if (uri!=null) ctx.putOntClass(uri, cls);
      cls.addSuperClass(RDF.List);   
      if (first!=null) {
        // add the item type as range of rdf:first
        cls.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.first,first));
        // add the class itself as the range of rdf:rest
        cls.addSuperClass(ont.createAllValuesFromRestriction(null,RDF.rest,cls));
      }
    }
    return cls;
  }
View Full Code Here

      // use data-range in the context of a property definition
      if (schema.isValidDatatype(base) && uri==null)
        return enumeration.toOWL(xs.ont,base,_enumeration);
      // in OWL full a datarange is a class
      else if (schema.isValidDatatype(base)) {
        OntClass c = xs.ont.createClass(uri);
        DataRange e = enumeration.toOWL(xs.ont,base,_enumeration);
        // assert equivalence with the anonymous datarange
        c.addEquivalentClass(e);
        return c;
      }
      // declare enumerated complex type
      else {
        RDFList e = enumeration.toOWL(xs.ont, _enumeration, _node, ctx);
        return xs.ont.createEnumeratedClass(uri,e);
      }
    }

    if (base!=null) {
      if (schema.isValidDatatype(base)) {
        // pass over anonymous simple types
        if (uri==null) return xs.ont.getResource(base);
        OntClass cls = xs.ont.createClass(uri);
        cls.addSuperClass(xs.ont.getResource(base));
        return cls;
       
      }
      else return null;
    }

    OntClass cls = null;   
    ctx.putOntClass(uri, cls = xs.ont.createClass(uri));
    if (base!=null) cls.addSuperClass(xs.ont.getResource(base));   
    subClassSimpleType(cls,ctx);
    return cls;
  }
View Full Code Here

   
    // add the named classes:
    {
      ExtendedIterator<OntClass> namedClasses = ontModel.listNamedClasses();
      while ( namedClasses.hasNext() ) {
        OntClass clazz = namedClasses.next();
        _putClazz(clazz);
      }
    }
   
    StmtIterator iter = ontModel.listStatements();
View Full Code Here

      String entityUri = ind.getURI();
      if ( entityUri == null ) {
        continue;
      }
     
      OntClass ontClass;
     
      // 280: "Error getting entities" (reported by Roy L.)
      // The stack trace in the orr.log was:
//      com.hp.hpl.jena.ontology.ConversionException: Cannot convert node http://www.w3.org/2002/07/owl#Class to OntClass: it does not have rdf:type owl:Class or equivalent
//        at com.hp.hpl.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:82)
//        at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:142)
//        at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:22)
//        at com.hp.hpl.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:54)
//        at com.hp.hpl.jena.enhanced.EnhNode.as(EnhNode.java:97)
//        at com.hp.hpl.jena.ontology.impl.IndividualImpl.getOntClass(IndividualImpl.java:175)
//      Note that ConversionException extends RuntimeException
      try {
        ontClass = ind.getOntClass(true);
        if ( ontClass == null || ! ontClass.isURIResource() ) {
          continue;
        }
      }
      catch ( RuntimeException ex ) {
        // 280: log the exception and continue.
        if ( log.isWarnEnabled() ) {
          log.warn("Ignoring runtime exception while getting individual's OntClass: " +entityUri, ex);
        }
        continue;       
      }
     
      String classUri = ontClass.getURI();

       
      IndividualInfo entityInfo = new IndividualInfo();
      entityInfo.setUri(entityUri);
      entityInfo.setClassUri(classUri);
View Full Code Here

    public Set<OntClass> listarClasses(){
        //Criar um iterador com as classes da ontologia
        ExtendedIterator<OntClass> classIterator = ontologia.listClasses();
        Set<OntClass> classes = new HashSet<OntClass>();
        //Objeto auxiliar para verificar se eh uma classe anonima
        OntClass aux = null;
        //para cada passo do iterador recupera-se a classe apontada e lista-se
        while (classIterator.hasNext()){
            aux = (OntClass) classIterator.next();
            if(aux.isAnon() == false){
                classes.add(aux);
            }
        }
       
        return classes;
View Full Code Here

          continue;
        }
       
        //Itera os axiomas subclassOf da classe
      ExtendedIterator<OntClass> it = c.listSuperClasses(true);
            OntClass aux = null;
            while(it.hasNext()){
                aux = it.next();
               
                //se tem LocalName definido, entao eh utilizado para referenciar superclasse
                if(aux.getLocalName() != null){
                    //Se TRUE entao a classe eh filha da classe informada como parametro.
                  if(aux.getLocalName().equals(classe.getLocalName())){
                      subclasses.add(c);
                    }
                }
            }
      }
View Full Code Here

        //Cria um iterador para o Set
        Iterator<OntClass> classesIterator = classes.iterator();

        //Para cada classe recuperar a lista de suas instancias
        while(classesIterator.hasNext()){
            OntClass classe = (OntClass)classesIterator.next();
            ExtendedIterator<? extends OntResource> individuals = classe.listInstances();
            //adicionar cada instancia ao conjunto a ser retornado
            while (individuals.hasNext()){
                Individual thisInstance = (Individual) individuals.next();
                instancias.add(thisInstance);
          }
View Full Code Here

                //recuperar um iterador sobre o conjunto
                UnionClass uniao = datatype.getDomain().asClass().asUnionClass();
                ExtendedIterator<? extends OntClass> iterador = uniao.listOperands();
                //verifica se a classe passada é uma das classes do conjunto
                while(iterador.hasNext()){
                    OntClass classe = (OntClass) iterador.next();
                    //Se a classe passada faz parte do conjunto adicionar ao conjunto de retorno
                    if(classe.getLocalName().equals(ontClass.getLocalName())){
                        conjuntoSaida.add(datatype);
                    }
                }
            }else{
                //Não é usado por múltiplas classes
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.OntClass

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.