@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); for (Resource rdfType : rdfTypes) { if (individual.hasRDFType(rdfType)) return true; } } return false; } }
@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); for (Resource rdfType : rdfTypes) { if (!individual.hasRDFType(rdfType)) return false; } } return true; } }
@Override public boolean accept(T node) { if (node.canAs(Individual.class)) { Individual individual = node.as(Individual.class); if (individual.hasRDFType(rdfType)) { return true; } } return false; } }
/** If _n_ is a ReifiedStatement, create a local copy of it, which will force the underlying reifier to take note of the mapping. */ private void noteIfReified( RDFNode n ) { if (n.canAs( ReifiedStatement.class )) { ReifiedStatement rs = n.as( ReifiedStatement.class ); createReifiedStatement( rs.getURI(), rs.getStatement() ); } }
/** * Convert the given Jena node as a Sesame Value * @param theNode the Jena node to convert * @return the jena node as a Sesame Value */ public static Value asSesameValue(RDFNode theNode) { if (theNode == null) { return null; } else if (theNode.canAs(Literal.class)) { return asSesameLiteral(theNode.as(Literal.class)); } else { return asSesameResource(theNode.as(Resource.class)); } }
public Resource resource(String binding) { if(!this.solution.contains(binding)) { return null; } RDFNode node = this.solution.get(binding); if(!node.canAs(Resource.class)) { throw new IllegalStateException("Binding '"+binding+"' is not a resource"); } return node.asResource(); }
private MessagePart obtainMessagePart(RDFNode inputNode) throws URISyntaxException { MessagePart result = null; if (inputNode == null || !inputNode.canAs(Individual.class)) { return result; } Individual individual = inputNode.as(Individual.class); result = new MessagePart(new URI(individual.getURI())); setAnnotableResourceProperties(individual, result); // Process mandatory parts List<MessagePart> mps; mps = obtainParts(individual, MSM.hasMandatoryPart); result.setMandatoryParts(mps); // Process optional parts mps = obtainParts(individual, MSM.hasOptionalPart); result.setOptionalParts(mps); return result; }
public final Literal literal(String binding) { if(!this.solution.contains(binding)) { return null; } RDFNode node = this.solution.get(binding); if(!node.canAs(Literal.class)) { throw new IllegalStateException("Binding '"+binding+"' is not a literal"); } return node.asLiteral(); }
/** * <p>Answer the RDF value that all values of the restricted property must be equal to.</p> * @return An RDFNode that is the value of the restricted property * @exception OntProfileException If the {@link Profile#HAS_VALUE()} property is not supported in the current language profile. */ @Override public RDFNode getHasValue() { checkProfile( getProfile().HAS_VALUE(), "HAS_VALUE" ); RDFNode n = getPropertyValue( getProfile().HAS_VALUE() ); // map to an individual in the case of a resource value if (!(n instanceof Literal) && n.canAs( Individual.class )) { n = n.as( Individual.class ); } return n; }
private MessageContent obtainMessageContent(RDFNode inputNode) throws URISyntaxException { MessageContent result = null; if (inputNode == null || !inputNode.canAs(Individual.class)) { return result; } Individual individual = inputNode.as(Individual.class); result = new MessageContent(new URI(individual.getURI())); setAnnotableResourceProperties(individual, result); // Process mandatory parts List<MessagePart> mps; mps = obtainParts(individual, MSM.hasMandatoryPart); result.setMandatoryParts(mps); // Process optional parts mps = obtainParts(individual, MSM.hasOptionalPart); result.setOptionalParts(mps); // Process Lifting and Lowerings List<URI> mappings; mappings = obtainMappings(individual, SAWSDL.liftingSchemaMapping); result.setLiftingSchemaMappings(mappings); mappings = obtainMappings(individual, SAWSDL.loweringSchemaMapping); result.setLoweringSchemaMappings(mappings); return result; }
/** Add the given value to a list which is the value of the given property */ protected void addListPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); // get the list value if (hasProperty( p )) { RDFNode cur = getRequiredProperty( p ).getObject(); if (!cur.canAs( RDFList.class )) { throw new OntologyException( "Tried to add a value to a list-valued property " + p + " but the current value is not a list: " + cur ); } RDFList values = cur.as( RDFList.class ); // now add our value to the list if (!values.contains( value )){ RDFList newValues = values.with( value ); // if the previous values was nil, the return value will be a new list if (newValues != values) { removeAll( p ); addProperty( p, newValues ); } } } else { // create a new list to hold the only value we know so far addProperty( p, ((OntModel) getModel()).createList( new RDFNode[] {value} ) ); } }
if (value.canAs(Individual.class)) { individual = value.as(Individual.class); operation = new Operation(new URI(individual.getURI()));