Package org.eclipse.rdf4j.model.util
Class Values
java.lang.Object
org.eclipse.rdf4j.model.util.Values
Factory methods to quickly create
Value objects ( IRI, Literal, BNode, and
Triple) without having to create a ValueFactory first.
Example usage:
import static org.eclipse.rdf4j.model.util.Values.iri;
...
IRI foo = iri("http://example.org/foo");
- Since:
- 3.5.0
- Author:
- Jeen Broekstra
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BNodebnode()Creates a newBNodestatic BNodeCreates a newBNodewith the supplied node identifier.static BNodebnode(ValueFactory vf) Creates a newBNodestatic BNodebnode(ValueFactory vf, String nodeId) Creates a newBNodewith the supplied node identifier.static ValueFactoryGet aValueFactory.static IRICreate a newIRIfrom a supplied prefixed name, using the suppliednamespacesstatic IRICreate a newIRIusing the supplied iri stringstatic IRICreate a newIRIusing the supplied namespace name and local namestatic IRIstatic IRIiri(ValueFactory vf, String iri) Create a newIRIusing the supplied iri stringstatic IRIiri(ValueFactory vf, String namespace, String localName) Create a newIRIusing the supplied namespace and local namestatic Literalliteral(boolean booleanValue) Creates a newLiteralwith the supplied boolean valuestatic Literalliteral(byte byteValue) Creates a newLiteralwith the supplied byte valuestatic Literalliteral(double doubleValue) Creates a newLiteralwith the supplied double valuestatic Literalliteral(float floatValue) Creates a newLiteralwith the supplied float valuestatic Literalliteral(int intValue) Creates a newLiteralwith the supplied int valuestatic Literalliteral(long longValue) Creates a newLiteralwith the supplied long valuestatic Literalliteral(short shortValue) Creates a newLiteralwith the supplied short valuestatic Literalstatic Literalstatic LiteralCreates a newLiteralwith the supplied lexical value.static LiteralCreates a newLiteralwith the supplied lexical value.static Literalliteral(String lexicalValue, CoreDatatype datatype) Creates a newLiteralwith the supplied lexical value and datatype.static LiteralCreates a newLiteralwith the supplied lexical value and datatype.static Literalliteral(BigDecimal bigDecimal) Creates a newLiteralwith the suppliedBigDecimalvaluestatic Literalliteral(BigInteger bigInteger) Creates a newLiteralwith the suppliedBigIntegervaluestatic Literalliteral(TemporalAccessor value) Creates a newLiteralwith the suppliedTemporalAccessorvaluestatic Literalliteral(ValueFactory vf, boolean booleanValue) Creates a newLiteralwith the supplied boolean valuestatic Literalliteral(ValueFactory vf, byte byteValue) Creates a newLiteralwith the supplied byte valuestatic Literalliteral(ValueFactory vf, double doubleValue) Creates a newLiteralwith the supplied double valuestatic Literalliteral(ValueFactory vf, float floatValue) Creates a newLiteralwith the supplied float valuestatic Literalliteral(ValueFactory vf, int intValue) Creates a newLiteralwith the supplied int valuestatic Literalliteral(ValueFactory vf, long longValue) Creates a newLiteralwith the supplied long valuestatic Literalliteral(ValueFactory vf, short shortValue) Creates a newLiteralwith the supplied short valuestatic Literalliteral(ValueFactory vf, Object object, boolean failOnUnknownType) static Literalliteral(ValueFactory vf, String lexicalValue) Creates a newLiteralwith the supplied lexical value.static Literalliteral(ValueFactory vf, String lexicalValue, String languageTag) Creates a newLiteralwith the supplied lexical value.static Literalliteral(ValueFactory vf, String lexicalValue, CoreDatatype datatype) Creates a newLiteralwith the supplied lexical value and datatype.static Literalliteral(ValueFactory vf, String lexicalValue, IRI datatype) Creates a newLiteralwith the supplied lexical value and datatype.static Literalliteral(ValueFactory vf, BigDecimal bigDecimal) Creates a newLiteralwith the suppliedBigDecimalvaluestatic Literalliteral(ValueFactory vf, BigInteger bigInteger) Creates a newLiteralwith the suppliedBigIntegervaluestatic Literalliteral(ValueFactory vf, TemporalAccessor value) Creates a newLiteralwith the suppliedTemporalAccessorvaluestatic NamespaceCreate a newNamespaceobject.static TripleCreates a newRDF-star embedded triplewith the supplied subject, predicate, and object.static TripleCreates a newRDF-star embedded tripleusing the subject, predicate and object from the suppliedStatement.static Tripletriple(ValueFactory vf, Resource subject, IRI predicate, Value object) Creates a newRDF-star embedded triplewith the supplied subject, predicate, and object.static Tripletriple(ValueFactory vf, Statement statement) Creates a newRDF-star embedded tripleusing the subject, predicate and object from the suppliedStatement.
-
Method Details
-
iri
Create a newIRIusing the supplied iri string- Parameters:
iri- a string representing a valid (absolute) iri- Returns:
- an
IRIobject for the supplied iri string. - Throws:
NullPointerException- if the suppplied iri isnullIllegalArgumentException- if the supplied iri string can not be parsed as a legal IRI.
-
iri
Create a newIRIusing the supplied iri string- Parameters:
vf- theValueFactoryto use for creation of the IRI.iri- a string representing a valid (absolute) iri- Returns:
- an
IRIobject for the supplied iri string. - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied iri string can not be parsed as a legal IRI by the suppliedValueFactory.
-
iri
Create a newIRIusing the supplied namespace name and local name- Parameters:
namespace- the IRI's namespace namelocalName- the IRI's local name- Returns:
- an
IRIobject for the supplied IRI namespace name and localName. - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied iri string can not be parsed as a legal IRI.
-
iri
- Parameters:
namespace- the IRI'sNamespacelocalName- the IRI's local name- Returns:
- an
IRIobject for the supplied IRI namespace and localName. - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied iri string can not be parsed as a legal IRI.- Since:
- 3.6.0
-
iri
public static IRI iri(Iterable<Namespace> namespaces, String prefixedName) throws IllegalArgumentException Create a newIRIfrom a supplied prefixed name, using the suppliednamespaces- Parameters:
namespaces- the Namespaces from which to find the correct namespace to map the prefixed name toprefixedName- a prefixed name that is a shorthand for a full iri, using syntax formprefix:localName. For example,rdf:typeis a prefixed name whererdfis the prefix. If the correctNamespacedefinition is also supplied this expands to the full namespace namehttp://www.w3.org/1999/02/22-rdf-syntax-ns#, leading to a full IRIhttp://www.w3.org/1999/02/22-rdf-syntax-ns#type.- Returns:
- an
IRIobject for the supplied IRI namespace and localName. - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied prefixed name can not be transformed to a legal IRI.- Since:
- 3.6.0
-
iri
public static IRI iri(ValueFactory vf, String namespace, String localName) throws IllegalArgumentException Create a newIRIusing the supplied namespace and local name- Parameters:
vf- theValueFactoryto use for creation of the IRI.namespace- the IRI's namespacelocalName- the IRI's local name- Returns:
- an
IRIobject for the supplied IRI namespace and localName. - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied iri string can not be parsed as a legal IRI by the suppliedValueFactory
-
bnode
Creates a newBNode- Returns:
- a new
BNode
-
bnode
Creates a newBNode- Parameters:
vf- theValueFactoryto use for creation of theBNode- Returns:
- a new
BNode - Throws:
NullPointerException- if any of the input parameters isnull
-
bnode
Creates a newBNodewith the supplied node identifier.- Parameters:
nodeId- the node identifier- Returns:
- a new
BNode - Throws:
NullPointerException- if the supplied node identifier isnull.IllegalArgumentException- if the supplied node identifier is not valid
-
bnode
Creates a newBNodewith the supplied node identifier.- Parameters:
vf- theValueFactoryto use for creation of theBNodenodeId- the node identifier- Returns:
- a new
BNode - Throws:
NullPointerException- if any of the input parameters isnullIllegalArgumentException- if the supplied node identifier is not valid
-
literal
Creates a newLiteralwith the supplied lexical value.- Parameters:
lexicalValue- the lexical value for the literal- Returns:
- a new
Literalof typeXSD.STRING - Throws:
NullPointerException- if the supplied lexical value isnull.
-
literal
Creates a newLiteralwith the supplied lexical value.- Parameters:
vf- theValueFactoryto use for creation of theLiterallexicalValue- the lexical value for the literal- Returns:
- a new
Literalof typeXSD.STRING - Throws:
NullPointerException- if any of the input parameters isnull
-
literal
Creates a newLiteralwith the supplied lexical value.- Parameters:
lexicalValue- the lexical value for the literallanguageTag- the language tag for the literal.- Returns:
- a new
Literalof typeRDF.LANGSTRING - Throws:
NullPointerException- if the supplied lexical value or language tag isnull.
-
literal
Creates a newLiteralwith the supplied lexical value.- Parameters:
vf- theValueFactoryto use for creation of theLiterallexicalValue- the lexical value for the literallanguageTag- the language tag for the literal.- Returns:
- a new
Literalof typeRDF.LANGSTRING - Throws:
NullPointerException- if any of the input parameters isnull
-
literal
Creates a newLiteralwith the supplied lexical value and datatype.- Parameters:
lexicalValue- the lexical value for the literaldatatype- the datatype IRI- Returns:
- a new
Literalwith the supplied lexical value and datatype - Throws:
NullPointerException- if the supplied lexical value or datatype isnull.IllegalArgumentException- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(String lexicalValue, CoreDatatype datatype) throws IllegalArgumentException Creates a newLiteralwith the supplied lexical value and datatype.- Parameters:
lexicalValue- the lexical value for the literaldatatype- the CoreDatatype- Returns:
- a new
Literalwith the supplied lexical value and datatype - Throws:
NullPointerException- if the supplied lexical value or datatype isnull.IllegalArgumentException- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue, IRI datatype) throws IllegalArgumentException Creates a newLiteralwith the supplied lexical value and datatype.- Parameters:
vf- theValueFactoryto use for creation of theLiterallexicalValue- the lexical value for the literaldatatype- the datatype IRI- Returns:
- a new
Literalwith the supplied lexical value and datatype - Throws:
NullPointerException- if any of the input parameters isnull.IllegalArgumentException- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue, CoreDatatype datatype) throws IllegalArgumentException Creates a newLiteralwith the supplied lexical value and datatype.- Parameters:
vf- theValueFactoryto use for creation of theLiterallexicalValue- the lexical value for the literaldatatype- the CoreDatatype- Returns:
- a new
Literalwith the supplied lexical value and datatype - Throws:
NullPointerException- if any of the input parameters isnull.IllegalArgumentException- if the supplied lexical value is not valid for the given datatype
-
literal
Creates a newLiteralwith the supplied boolean value- Parameters:
booleanValue- a boolean value- Returns:
- a
Literalof typeXSD.BOOLEANwith the supplied value
-
literal
Creates a newLiteralwith the supplied boolean value- Parameters:
vf- theValueFactoryto use for creation of theLiteralbooleanValue- a boolean value- Returns:
- a
Literalof typeXSD.BOOLEANwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied byte value -
literal
Creates a newLiteralwith the supplied byte value- Parameters:
vf- theValueFactoryto use for creation of theLiteralbyteValue- a byte value- Returns:
- a
Literalof typeXSD.BYTEwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied short value -
literal
Creates a newLiteralwith the supplied short value- Parameters:
vf- theValueFactoryto use for creation of theLiteralshortValue- a short value- Returns:
- a
Literalof typeXSD.SHORTwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied int value -
literal
Creates a newLiteralwith the supplied int value- Parameters:
vf- theValueFactoryto use for creation of theLiteralintValue- an int value- Returns:
- a
Literalof typeXSD.INTwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied long value -
literal
Creates a newLiteralwith the supplied long value- Parameters:
vf- theValueFactoryto use for creation of theLiterallongValue- a long value- Returns:
- a
Literalof typeXSD.LONGwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied float value -
literal
Creates a newLiteralwith the supplied float value- Parameters:
vf- theValueFactoryto use for creation of theLiteralfloatValue- a float value- Returns:
- a
Literalof typeXSD.FLOATwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the supplied double value- Parameters:
doubleValue- a double value- Returns:
- a
Literalof typeXSD.DOUBLEwith the supplied value
-
literal
Creates a newLiteralwith the supplied double value- Parameters:
vf- theValueFactoryto use for creation of theLiteraldoubleValue- a double value- Returns:
- a
Literalof typeXSD.DOUBLEwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the suppliedBigDecimalvalue- Parameters:
bigDecimal- aBigDecimalvalue- Returns:
- a
Literalof typeXSD.DECIMALwith the supplied value - Throws:
NullPointerException- if the supplied bigDecimal isnull.
-
literal
Creates a newLiteralwith the suppliedBigDecimalvalue- Parameters:
vf- theValueFactoryto use for creation of theLiteralbigDecimal- aBigDecimalvalue- Returns:
- a
Literalof typeXSD.DECIMALwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the suppliedBigIntegervalue- Parameters:
bigInteger- aBigIntegervalue- Returns:
- a
Literalof typeXSD.INTEGERwith the supplied value - Throws:
NullPointerException- if the supplied bigInteger isnull.
-
literal
Creates a newLiteralwith the suppliedBigIntegervalue- Parameters:
vf- theValueFactoryto use for creation of theLiteralbigInteger- aBigIntegervalue- Returns:
- a
Literalof typeXSD.INTEGERwith the supplied value - Throws:
NullPointerException- if any of the input parameters isnull.
-
literal
Creates a newLiteralwith the suppliedTemporalAccessorvalue- Parameters:
value- aTemporalAccessorvalue.- Returns:
- a
Literalwith the supplied calendar value and the appropriateXSDdate/time datatype for the specific value. - Throws:
NullPointerException- if the suppliedTemporalAccessorvalue isnull.IllegalArgumentException- if value cannot be represented by an XML Schema date/time datatype
-
literal
public static Literal literal(ValueFactory vf, TemporalAccessor value) throws IllegalArgumentException Creates a newLiteralwith the suppliedTemporalAccessorvalue- Parameters:
vf- theValueFactoryto use for creation of theLiteralvalue- aTemporalAccessorvalue.- Returns:
- a
Literalwith the supplied calendar value and the appropriateXSDdate/time datatype for the specific value. - Throws:
NullPointerException- if any of the input parameters isnull..IllegalArgumentException- if value cannot be represented by an XML Schema date/time datatype
-
literal
Creates a new typedLiteralout of the supplied object, mapping the runtime type of the object to the appropriateXSDdatatype. If no mapping is available, the method returns a literal with the string representation of the supplied object as the value, andXSD.STRINGas the datatype.Recognized types are
Boolean,Byte,Double,Float,Integer,Long,Short,XMLGregorianCalendar,TemporalAccessorandDate.- Parameters:
object- an object to be converted to a typed literal.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException- if the input parameter isnull..
-
literal
Creates a new typedLiteralout of the supplied object, mapping the runtime type of the object to the appropriateXSDdatatype.Recognized types are
Boolean,Byte,Double,Float,BigDecimal,Integer,BigInteger,Long,Short,XMLGregorianCalendar,TemporalAccessor,TemporalAmpountandDate.- Parameters:
object- an object to be converted to a typed literal.failOnUnknownType- If no mapping is available andfailOnUnknownTypeisfalsethe method returns a literal with the string representation of the supplied object as the value, andXSD.STRINGas the datatype. If set totruethe method throws anIllegalArgumentExceptionif no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException- if the input parameter isnull..
-
literal
Creates a new typedLiteralout of the supplied object, mapping the runtime type of the object to the appropriateXSDdatatype.Recognized types are
Boolean,Byte,Double,Float,Integer,Long,Short,XMLGregorianCalendar,TemporalAccessorandDate.- Parameters:
valueFactory- theValueFactoryto use for creation of theLiteralobject- an object to be converted to a typed literal.failOnUnknownType- If no mapping is available andfailOnUnknownTypeisfalsethe method returns a literal with the string representation of the supplied object as the value, andXSD.STRINGas the datatype. If set totruethe method throws anIllegalArgumentExceptionif no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException- if any of the input parameters isnull.IllegalArgumentException- iffailOnUnknownTypeis set totrueand the runtime type of the supplied object could not be mapped.
-
triple
Creates a newRDF-star embedded triplewith the supplied subject, predicate, and object.- Parameters:
subject- the Triple subjectpredicate- the Triple predicateobject- the Triple object- Returns:
- a
Triplewith the supplied subject, predicate, and object. - Throws:
NullPointerException- if any of the supplied input parameters isnull.
-
triple
Creates a newRDF-star embedded triplewith the supplied subject, predicate, and object.- Parameters:
vf- theValueFactoryto use for creation of theTriplesubject- the Triple subjectpredicate- the Triple predicateobject- the Triple object- Returns:
- a
Triplewith the supplied subject, predicate, and object. - Throws:
NullPointerException- if any of the supplied input parameters isnull.
-
triple
Creates a newRDF-star embedded tripleusing the subject, predicate and object from the suppliedStatement.- Parameters:
statement- theStatementfrom which to construct aTriple- Returns:
- a
Triplewith the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException- if statement isnull.
-
triple
Creates a newRDF-star embedded tripleusing the subject, predicate and object from the suppliedStatement.- Parameters:
vf- theValueFactoryto use for creation of theTriplestatement- theStatementfrom which to construct aTriple- Returns:
- a
Triplewith the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException- if any of the supplied input parameters isnull.
-
namespace
Create a newNamespaceobject.- Parameters:
prefix- the prefix associated with the namespacename- the namespace name (typically an IRI) for the namespace.- Returns:
- a
Namespaceobject. - Since:
- 3.6.0
-
getValueFactory
Get aValueFactory.- Returns:
- a
ValueFactory.
-