/** Add the property value, checking that it is supported in the profile */ protected void addPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); addProperty( p, value ); }
/** Add the property value, checking that it is supported in the profile */ protected void addPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); addProperty( p, value ); }
/** * <p> * Set the value of the given property of this ontology resource to the given * value, encoded as an RDFNode. Maintains the invariant that there is * at most one value of the property for a given resource, so existing * property values are first removed. To add multiple properties, use * {@link #addProperty( Property, RDFNode ) addProperty}. * </p> * * @param property The property to update * @param value The new value of the property as an RDFNode, or null to * effectively remove this property. */ @Override public void setPropertyValue( Property property, RDFNode value ) { // if there is an existing property, remove it removeAll( property ); // now set the new value if (value != null) { addProperty( property, value ); } }
/** * <p> * Set the value of the given property of this ontology resource to the given * value, encoded as an RDFNode. Maintains the invariant that there is * at most one value of the property for a given resource, so existing * property values are first removed. To add multiple properties, use * {@link #addProperty( Property, RDFNode ) addProperty}. * </p> * * @param property The property to update * @param value The new value of the property as an RDFNode, or null to * effectively remove this property. */ @Override public void setPropertyValue( Property property, RDFNode value ) { // if there is an existing property, remove it removeAll( property ); // now set the new value if (value != null) { addProperty( property, value ); } }
/** Set the property value, checking that it is supported in the profile */ protected void setPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); removeAll( p ); addProperty( p, value ); }
/** Set the property value, checking that it is supported in the profile */ protected void setPropertyValue( Property p, String name, RDFNode value ) { checkProfile( p, name ); removeAll( p ); addProperty( p, value ); }
/** Convert this resource to the facet denoted by cls, by adding rdf:type type if necessary */ protected <T extends RDFNode> T convertToType( Resource type, String name, Class<T> cls ) { checkProfile( type, name ); if (canAs( cls )) { // don't need to update the model, we already can do the given facet return as( cls ); } // we're told that adding this rdf:type will make the as() possible - let's see addProperty( RDF.type, type ); return as( cls ); }
/** Convert this resource to the facet denoted by cls, by adding rdf:type type if necessary */ protected <T extends RDFNode> T convertToType( Resource type, String name, Class<T> cls ) { checkProfile( type, name ); if (canAs( cls )) { // don't need to update the model, we already can do the given facet return as( cls ); } // we're told that adding this rdf:type will make the as() possible - let's see addProperty( RDF.type, type ); return as( cls ); }
/** * <p>Add the given comment to this resource.</p> * @param comment The literal comment * @exception ProfileException If the {@link Profile#COMMENT()} property is not supported in the current language profile. */ @Override public void addComment( Literal comment ) { checkProfile( getProfile().COMMENT(), "COMMENT" ); addProperty( getProfile().COMMENT(), comment ); }
/** * <p>Add the given comment to this resource.</p> * @param comment The literal comment * @exception ProfileException If the {@link Profile#COMMENT()} property is not supported in the current language profile. */ @Override public void addComment( Literal comment ) { checkProfile( getProfile().COMMENT(), "COMMENT" ); addProperty( getProfile().COMMENT(), comment ); }
/** * <p>Add the given version information to this resource.</p> * @param info A version information string for this resource * @exception ProfileException If the {@link Profile#VERSION_INFO()} property is not supported in the current language profile. */ @Override public void addVersionInfo( String info ) { checkProfile( getProfile().VERSION_INFO(), "VERSION_INFO" ); addProperty( getProfile().VERSION_INFO(), getModel().createLiteral( info ) ); }
/** * <p>Add the given version information to this resource.</p> * @param info A version information string for this resource * @exception ProfileException If the {@link Profile#VERSION_INFO()} property is not supported in the current language profile. */ @Override public void addVersionInfo( String info ) { checkProfile( getProfile().VERSION_INFO(), "VERSION_INFO" ); addProperty( getProfile().VERSION_INFO(), getModel().createLiteral( info ) ); }
/** 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} ) ); } }
/** 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} ) ); } }