public Object visit(OWLDatatypeRestriction object) { if (!(object.getDatatype().isOWLDatatype())) throw new IllegalArgumentException("Datatype restrictions are supported only on OWL datatypes."); String datatypeURI=object.getDatatype().getIRI().toString(); if (InternalDatatype.RDFS_LITERAL.getIRI().equals(datatypeURI)) { if (!object.getFacetRestrictions().isEmpty()) throw new IllegalArgumentException("rdfs:Literal does not support any facets."); return InternalDatatype.RDFS_LITERAL; } String[] facetURIs=new String[object.getFacetRestrictions().size()]; Constant[] facetValues=new Constant[object.getFacetRestrictions().size()]; int index=0; for (OWLFacetRestriction facet : object.getFacetRestrictions()) { facetURIs[index]=facet.getFacet().getIRI().toURI().toString(); facetValues[index]=(Constant)facet.getFacetValue().accept(this); index++; } DatatypeRestriction datatype=DatatypeRestriction.create(datatypeURI,facetURIs,facetValues); DatatypeRegistry.validateDatatypeRestriction(datatype); return datatype; }
@Override public void addToOntology() { OWLDatatype datatype = factory.getOWLDatatype(":DatatypeRestrictionDatatype", pm); OWLFacetRestriction fr1 = factory.getOWLFacetRestriction(OWLFacet.MIN_LENGTH, 10); OWLLiteral patternLiteral = factory.getOWLLiteral("DatatypeRestrictionLiteral"); OWLFacetRestriction fr2 = factory.getOWLFacetRestriction(OWLFacet.PATTERN, patternLiteral); OWLDatatypeRestriction restriction = factory.getOWLDatatypeRestriction(datatype, fr1, fr2); OWLDataProperty property = factory.getOWLDataProperty(":datatypeRestrictionProperty", pm); addToGenericDomainAndNewRange(property, restriction); }
Set<OWLFacetRestriction> toFacetRestrictionSet( List<? extends ElkFacetRestriction> input) { Set<OWLFacetRestriction> result = new HashSet<OWLFacetRestriction>( input.size()); for (ElkFacetRestriction next : input) { result.add(convert(next)); } return result; }
@Override public List<? extends ElkFacetRestriction> getFacetRestrictions() { List<ElkFacetRestriction> result = new ArrayList<ElkFacetRestriction>(); for (OWLFacetRestriction frstr : this.owlObject.getFacetRestrictions()) { result.add(converter.convert(frstr)); } return result; }
@Override public OWLFacetRestriction convert(ElkFacetRestriction input) { if (input instanceof ElkFacetRestrictionWrap<?>) { return ((ElkFacetRestrictionWrap<?>) input).getOwlObject(); } // else return visit(input); }
@Override public void visit(@Nonnull OWLDatatypeRestriction node) { node.getDatatype().accept(this); for (OWLFacetRestriction facetRestriction : node.getFacetRestrictions()) { facetRestriction.accept(this); } }
@Override protected OWLFacetRestriction readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { int facetIndex = inputStream.readInt(); OWLFacet facet = getFacet(facetIndex); OWLLiteral literal = inputStream.readOWLObject(); return inputStream.getDataFactory().getOWLFacetRestriction(facet, literal); }
public OWLDataRange visit(OWLFacetRestriction node) { throw new IllegalStateException("Internal error: We shouldn't visit facet restrictions during normalization. "); }
public OWLDataRange visit(OWLFacetRestriction node) { return null; }
public OWLDataRange visit(OWLFacetRestriction o) { return null; }
public void visit(OWLFacetRestriction node) { throw new IllegalStateException("Internal error: Invalid normal form. "); }
public Object visit(OWLFacetRestriction object) { throw new IllegalStateException("Internal error: should not get in here."); }
@Override public OWLFacetRestriction visit(ElkFacetRestriction restriction) { return owlFactory_.getOWLFacetRestriction( OWLFacet.getFacet(convert(restriction.getConstrainingFacet())), convert(restriction.getRestrictionValue())); }
@SuppressWarnings("static-method") public ElkFacetRestriction convert( OWLFacetRestriction owlFacetRestriction) { return new ElkFacetRestrictionWrap<OWLFacetRestriction>( owlFacetRestriction); }
public static OWLDatatypeRestrictionImpl instantiate(SerializationStreamReader streamReader) throws SerializationException { OWLDatatype datatype = (OWLDatatype) streamReader.readObject(); Set<OWLFacetRestriction> facetRestrictions = CustomFieldSerializerUtil.deserializeSet(streamReader); return new OWLDatatypeRestrictionImpl(datatype, facetRestrictions); }
@Override public O visit(OWLFacetRestriction node) { return doDefault(node); }
@Override public void visit(OWLFacetRestriction node) { handleDefault(node); }
@Override public void visit(OWLFacetRestriction node) { type = DATA_TYPE_INDEX_BASE + 7; }
@Override public void visit(OWLFacetRestriction node) { hashCode = primes[59]; hashCode = hashCode * MULT + node.getFacet().hashCode(); hashCode = hashCode * MULT + node.getFacetValue().hashCode(); }
@Override public void visit(@Nonnull OWLFacetRestriction node) { node.getFacetValue().accept(this); }
@Override protected void writeObject(OWLFacetRestriction object, BinaryOWLOutputStream outputStream) throws IOException { int facetMarker = getFacetMarker(object.getFacet()); outputStream.writeInt(facetMarker); outputStream.writeOWLObject(object.getFacetValue()); }
@Override protected OWLDatatypeRestriction readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { OWLDatatype datatype = inputStream.readOWLObject(); Set<OWLFacetRestriction> facetRestrictions = inputStream.readOWLObjects(); return inputStream.getDataFactory().getOWLDatatypeRestriction(datatype, facetRestrictions); }
abstract OWLFacetRestriction convert(ElkFacetRestriction input);