Package org.eclipse.rdf4j.model.impl
Class SimpleValueFactory
- java.lang.Object
-
- org.eclipse.rdf4j.model.base.AbstractValueFactory
-
- org.eclipse.rdf4j.model.impl.SimpleValueFactory
-
- All Implemented Interfaces:
ValueFactory
- Direct Known Subclasses:
ValueStore
public class SimpleValueFactory extends AbstractValueFactory
Default implementation of theValueFactoryinterface.- Author:
- Arjohn Kampman
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleValueFactory()Hidden constructor to enforce singleton pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BNodecreateBNode()Creates a new bNode.BNodecreateBNode(String nodeID)Creates a new blank node with the given node identifier.protected LiteralcreateFPLiteral(Number value, IRI datatype)CallscreateNumericLiteral(Number, IRI)with the supplied value and datatype as parameters.protected LiteralcreateFPLiteral(Number value, XSD.Datatype datatype)protected LiteralcreateIntegerLiteral(Number value, IRI datatype)CallscreateNumericLiteral(Number, IRI)with the supplied value and datatype as parameters.protected LiteralcreateIntegerLiteral(Number value, XSD.Datatype datatype)IRIcreateIRI(String iri)Creates a new IRI from the supplied string-representation.IRIcreateIRI(String namespace, String localName)Creates a new IRI from the supplied namespace and local name.LiteralcreateLiteral(boolean b)Creates a new xsd:boolean-typed literal representing the specified value.LiteralcreateLiteral(byte value)CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.BYTEas parameters.LiteralcreateLiteral(double value)CallscreateFPLiteral(Number, IRI)with the supplied value andXSD.DOUBLEas parameters.LiteralcreateLiteral(float value)CallscreateFPLiteral(Number, IRI)with the supplied value andXSD.FLOATas parameters.LiteralcreateLiteral(int value)CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.INTas parameters.LiteralcreateLiteral(long value)CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.LONGas parameters.LiteralcreateLiteral(short value)CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.SHORTas parameters.LiteralcreateLiteral(String value)Creates a new literal with the supplied label.LiteralcreateLiteral(String value, String language)Creates a new literal with the supplied label and language attribute.LiteralcreateLiteral(String value, IRI datatype)Creates a new literal with the supplied label and datatype.LiteralcreateLiteral(BigDecimal bigDecimal)Creates a new literal representing the specified bigDecimal that is typed as an xsd:Decimal.LiteralcreateLiteral(BigInteger bigInteger)Creates a new literal representing the specified bigInteger that is typed as an xsd:Integer.LiteralcreateLiteral(Date date)Converts the suppliedDateto aXMLGregorianCalendar, then callsValueFactory.createLiteral(XMLGregorianCalendar).LiteralcreateLiteral(XMLGregorianCalendar calendar)CallsValueFactory.createLiteral(String, IRI)with the String-value of the supplied calendar and the appropriate datatype as parameters.protected LiteralcreateNumericLiteral(Number number, CoreDatatype datatype)protected LiteralcreateNumericLiteral(Number number, IRI datatype)Creates specific optimized subtypes of SimpleLiteral for numeric datatypes.protected LiteralcreateNumericLiteral(Number number, XSD.Datatype datatype)Deprecated, for removal: This API element is subject to removal in a future version.StatementcreateStatement(Resource subject, IRI predicate, Value object)Creates a new statement with the supplied subject, predicate and object.StatementcreateStatement(Resource subject, IRI predicate, Value object, Resource context)Creates a new statement with the supplied subject, predicate and object and associated context.TriplecreateTriple(Resource subject, IRI predicate, Value object)Creates a new RDF-star triple with the supplied subject, predicate and object.static SimpleValueFactorygetInstance()Provide a single shared instance of a SimpleValueFactory.protected voidinitBNodeParams()Generates a new bnode prefix and resets nextBNodeID to 1 .-
Methods inherited from class org.eclipse.rdf4j.model.base.AbstractValueFactory
createLiteral, createLiteral, createLiteral, createLiteral
-
-
-
-
Method Detail
-
getInstance
public static SimpleValueFactory getInstance()
Provide a single shared instance of a SimpleValueFactory.- Returns:
- a singleton instance of SimpleValueFactory.
-
createIRI
public IRI createIRI(String iri)
Description copied from interface:ValueFactoryCreates a new IRI from the supplied string-representation.- Specified by:
createIRIin interfaceValueFactory- Overrides:
createIRIin classAbstractValueFactory- Parameters:
iri- A string-representation of a IRI.- Returns:
- An object representing the IRI.
-
createIRI
public IRI createIRI(String namespace, String localName)
Description copied from interface:ValueFactoryCreates a new IRI from the supplied namespace and local name. Calling this method is funtionally equivalent to callingcreateIRI(namespace+localName), but allows the ValueFactory to reuse supplied namespace and local name strings whenever possible. Note that the values returned byIRI.getNamespace()andIRI.getLocalName()are not necessarily the same as the values that are supplied to this method.- Specified by:
createIRIin interfaceValueFactory- Overrides:
createIRIin classAbstractValueFactory- Parameters:
namespace- The IRI's namespace.localName- The IRI's local name.
-
createBNode
public BNode createBNode(String nodeID)
Description copied from interface:ValueFactoryCreates a new blank node with the given node identifier.- Specified by:
createBNodein interfaceValueFactory- Overrides:
createBNodein classAbstractValueFactory- Parameters:
nodeID- The blank node identifier.- Returns:
- An object representing the blank node.
-
createLiteral
public Literal createLiteral(String value)
Description copied from interface:ValueFactoryCreates a new literal with the supplied label. The return value ofLiteral.getDatatype()for the returned object must bexsd:string.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The literal's label, must not be null.
-
createLiteral
public Literal createLiteral(String value, String language)
Description copied from interface:ValueFactoryCreates a new literal with the supplied label and language attribute. The return value ofLiteral.getDatatype()for the returned object must berdf:langString.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The literal's label, must not be null.language- The literal's language attribute, must not be null.
-
createLiteral
public Literal createLiteral(boolean b)
Description copied from interface:ValueFactoryCreates a new xsd:boolean-typed literal representing the specified value.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
b- The value for the literal.- Returns:
- An xsd:boolean-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(String value, IRI datatype)
Description copied from interface:ValueFactoryCreates a new literal with the supplied label and datatype.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The literal's label, must not be null.datatype- The literal's datatype. If it is null, the datatypexsd:stringwill be assigned to this literal.
-
createStatement
public Statement createStatement(Resource subject, IRI predicate, Value object)
Description copied from interface:ValueFactoryCreates a new statement with the supplied subject, predicate and object.- Specified by:
createStatementin interfaceValueFactory- Overrides:
createStatementin classAbstractValueFactory- Parameters:
subject- The statement's subject.predicate- The statement's predicate.object- The statement's object.- Returns:
- The created statement.
-
createStatement
public Statement createStatement(Resource subject, IRI predicate, Value object, Resource context)
Description copied from interface:ValueFactoryCreates a new statement with the supplied subject, predicate and object and associated context.- Specified by:
createStatementin interfaceValueFactory- Overrides:
createStatementin classAbstractValueFactory- Parameters:
subject- The statement's subject.predicate- The statement's predicate.object- The statement's object.context- The statement's context.- Returns:
- The created statement.
-
createTriple
public Triple createTriple(Resource subject, IRI predicate, Value object)
Description copied from interface:ValueFactoryCreates a new RDF-star triple with the supplied subject, predicate and object.- Specified by:
createTriplein interfaceValueFactory- Overrides:
createTriplein classAbstractValueFactory- Parameters:
subject- The statement's subject.predicate- The statement's predicate.object- The statement's object.- Returns:
- The created triple.
-
initBNodeParams
protected void initBNodeParams()
Generates a new bnode prefix and resets nextBNodeID to 1 .
-
createBNode
public BNode createBNode()
Description copied from interface:ValueFactoryCreates a new bNode.- Specified by:
createBNodein interfaceValueFactory- Overrides:
createBNodein classAbstractValueFactory- Returns:
- An object representing the bNode.
-
createLiteral
public Literal createLiteral(byte value)
CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.BYTEas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:byte-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(short value)
CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.SHORTas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:short-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(int value)
CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.INTas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:int-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(long value)
CallscreateIntegerLiteral(Number, IRI)with the supplied value andXSD.LONGas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:long-typed literal for the specified value.
-
createIntegerLiteral
protected Literal createIntegerLiteral(Number value, IRI datatype)
CallscreateNumericLiteral(Number, IRI)with the supplied value and datatype as parameters.
-
createIntegerLiteral
protected Literal createIntegerLiteral(Number value, XSD.Datatype datatype)
-
createLiteral
public Literal createLiteral(float value)
CallscreateFPLiteral(Number, IRI)with the supplied value andXSD.FLOATas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:float-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(double value)
CallscreateFPLiteral(Number, IRI)with the supplied value andXSD.DOUBLEas parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
value- The value for the literal.- Returns:
- An xsd:double-typed literal for the specified value.
-
createLiteral
public Literal createLiteral(BigInteger bigInteger)
Description copied from interface:ValueFactoryCreates a new literal representing the specified bigInteger that is typed as an xsd:Integer.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory
-
createLiteral
public Literal createLiteral(BigDecimal bigDecimal)
Description copied from interface:ValueFactoryCreates a new literal representing the specified bigDecimal that is typed as an xsd:Decimal.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory
-
createFPLiteral
protected Literal createFPLiteral(Number value, IRI datatype)
CallscreateNumericLiteral(Number, IRI)with the supplied value and datatype as parameters.
-
createFPLiteral
protected Literal createFPLiteral(Number value, XSD.Datatype datatype)
-
createNumericLiteral
protected Literal createNumericLiteral(Number number, IRI datatype)
Creates specific optimized subtypes of SimpleLiteral for numeric datatypes.
-
createNumericLiteral
@Deprecated(since="4.0.0", forRemoval=true) protected Literal createNumericLiteral(Number number, XSD.Datatype datatype)
Deprecated, for removal: This API element is subject to removal in a future version.
-
createNumericLiteral
protected Literal createNumericLiteral(Number number, CoreDatatype datatype)
-
createLiteral
public Literal createLiteral(XMLGregorianCalendar calendar)
CallsValueFactory.createLiteral(String, IRI)with the String-value of the supplied calendar and the appropriate datatype as parameters.- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory- Parameters:
calendar- The value for the literal.- Returns:
- A typed literal for the specified calendar.
- See Also:
XMLGregorianCalendar.toXMLFormat(),XMLGregorianCalendar.getXMLSchemaType(),XMLDatatypeUtil.qnameToCoreDatatype(javax.xml.namespace.QName)
-
createLiteral
public Literal createLiteral(Date date)
Converts the suppliedDateto aXMLGregorianCalendar, then callsValueFactory.createLiteral(XMLGregorianCalendar).- Specified by:
createLiteralin interfaceValueFactory- Overrides:
createLiteralin classAbstractValueFactory
-
-