public Object convert(OWLObject obj) { if (obj instanceof IRI) { return obj.toString(); } else if (obj instanceof OWLEntity) { return convert(((OWLEntity)obj).getIRI()); } else if (obj instanceof OWLClassExpression) { // {type: <Class|SomeValuesFrom|...>, args: [...] Map<String,Object> m = new HashMap<String,Object>(); m.put("type", ((OWLClassExpression) obj).getClassExpressionType().toString()); Object[] arr; if (obj instanceof OWLQuantifiedObjectRestriction) { OWLQuantifiedObjectRestriction r = (OWLQuantifiedObjectRestriction)obj; arr = new Object[] { convert(r.getProperty()), convert(r.getFiller()) }; // TODO: QCRs } else if (obj instanceof OWLNaryBooleanClassExpression) { arr = convertSet( ((OWLNaryBooleanClassExpression)obj).getOperands()); } else { arr = new Object[0]; // TODO } m.put("args", arr); return m; } else if (obj instanceof OWLLiteral) { return ((OWLLiteral)obj).getLiteral(); } else { return obj.toString(); // TODO } }
@Override public boolean equals(Object obj) { if (!(obj instanceof OWLNaryBooleanClassExpression)) { return false; } if (obj instanceof OWLNaryBooleanClassExpressionImpl) { return operands.equals(((OWLNaryBooleanClassExpressionImpl) obj).operands); } return ((OWLNaryBooleanClassExpression) obj).getOperands().equals( getOperands()); }
public void getProperties(OWLClassExpression desc, Set<Object> list, Set<Object> visited) throws OWLException { if (desc instanceof OWLRestriction) { //getProperties( (OWLRestriction)desc, list ); list.add(((OWLRestriction) desc).getProperty()); } else if (desc instanceof OWLClass) { getProperties((OWLClass) desc, list, visited); } else if (desc instanceof OWLNaryBooleanClassExpression) { for (Object d : ((OWLNaryBooleanClassExpression) desc).getOperands()) { getProperties((OWLClassExpression) d, list, visited); } //getProperties( (OWLNaryBooleanClassExpression)desc, list, visited ); } }
@Override protected int compareObjectOfSameType(OWLObject object) { return compareSets(operands, ((OWLNaryBooleanClassExpression) object).getOperands()); }
public void getProperties(OWLNaryBooleanClassExpression d, Set<Object> list, Set<Object> visited) throws OWLException { for (OWLClassExpression desc : d.getOperands()) { getProperties(desc, list, visited); } }
private void enrichSignature( Set<ATermAppl> classSet, Map<String, OWLClassExpression> nameMap, boolean removeAutoGenNames, KnowledgeBase kb) { nameMap = nameMap == null ? new HashMap<String, OWLClassExpression>() : nameMap; if( removeAutoGenNames ) { //Remove auto generated names from the signature for( Iterator<ATermAppl> classIter = classSet.iterator(); classIter.hasNext(); ) { ATermAppl clazz = classIter.next(); if( nameMap.containsKey( clazz.toString() ) ) classIter.remove(); } } //Add classes that appear in abbreviated expressions for (String name : nameMap.keySet()) { OWLClassExpression expr = nameMap.get( name ); switch (expr.getClassExpressionType()) { case OBJECT_UNION_OF: case OBJECT_INTERSECTION_OF: OWLNaryBooleanClassExpression nary = (OWLNaryBooleanClassExpression) expr; for (OWLClassExpression exprPart : nary.getOperands()) { classSet.add( convertToATerm(exprPart, kb) ); } default: classSet.add( convertToATerm(expr, kb) ); } } }