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 BNode
bnode()
Creates a newBNode
static BNode
Creates a newBNode
with the supplied node identifier.static BNode
bnode
(ValueFactory vf) Creates a newBNode
static BNode
bnode
(ValueFactory vf, String nodeId) Creates a newBNode
with the supplied node identifier.static ValueFactory
Get aValueFactory
.static IRI
Create a newIRI
from a supplied prefixed name, using the suppliednamespaces
static IRI
Create a newIRI
using the supplied iri stringstatic IRI
Create a newIRI
using the supplied namespace name and local namestatic IRI
static IRI
iri
(ValueFactory vf, String iri) Create a newIRI
using the supplied iri stringstatic IRI
iri
(ValueFactory vf, String namespace, String localName) Create a newIRI
using the supplied namespace and local namestatic Literal
literal
(boolean booleanValue) Creates a newLiteral
with the supplied boolean valuestatic Literal
literal
(byte byteValue) Creates a newLiteral
with the supplied byte valuestatic Literal
literal
(double doubleValue) Creates a newLiteral
with the supplied double valuestatic Literal
literal
(float floatValue) Creates a newLiteral
with the supplied float valuestatic Literal
literal
(int intValue) Creates a newLiteral
with the supplied int valuestatic Literal
literal
(long longValue) Creates a newLiteral
with the supplied long valuestatic Literal
literal
(short shortValue) Creates a newLiteral
with the supplied short valuestatic Literal
static Literal
static Literal
Creates a newLiteral
with the supplied lexical value.static Literal
Creates a newLiteral
with the supplied lexical value.static Literal
literal
(String lexicalValue, CoreDatatype datatype) Creates a newLiteral
with the supplied lexical value and datatype.static Literal
Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal
(BigDecimal bigDecimal) Creates a newLiteral
with the suppliedBigDecimal
valuestatic Literal
literal
(BigInteger bigInteger) Creates a newLiteral
with the suppliedBigInteger
valuestatic Literal
literal
(TemporalAccessor value) Creates a newLiteral
with the suppliedTemporalAccessor
valuestatic Literal
literal
(ValueFactory vf, boolean booleanValue) Creates a newLiteral
with the supplied boolean valuestatic Literal
literal
(ValueFactory vf, byte byteValue) Creates a newLiteral
with the supplied byte valuestatic Literal
literal
(ValueFactory vf, double doubleValue) Creates a newLiteral
with the supplied double valuestatic Literal
literal
(ValueFactory vf, float floatValue) Creates a newLiteral
with the supplied float valuestatic Literal
literal
(ValueFactory vf, int intValue) Creates a newLiteral
with the supplied int valuestatic Literal
literal
(ValueFactory vf, long longValue) Creates a newLiteral
with the supplied long valuestatic Literal
literal
(ValueFactory vf, short shortValue) Creates a newLiteral
with the supplied short valuestatic Literal
literal
(ValueFactory vf, Object object, boolean failOnUnknownType) static Literal
literal
(ValueFactory vf, String lexicalValue) Creates a newLiteral
with the supplied lexical value.static Literal
literal
(ValueFactory vf, String lexicalValue, String languageTag) Creates a newLiteral
with the supplied lexical value.static Literal
literal
(ValueFactory vf, String lexicalValue, CoreDatatype datatype) Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal
(ValueFactory vf, String lexicalValue, IRI datatype) Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal
(ValueFactory vf, BigDecimal bigDecimal) Creates a newLiteral
with the suppliedBigDecimal
valuestatic Literal
literal
(ValueFactory vf, BigInteger bigInteger) Creates a newLiteral
with the suppliedBigInteger
valuestatic Literal
literal
(ValueFactory vf, TemporalAccessor value) Creates a newLiteral
with the suppliedTemporalAccessor
valuestatic Namespace
Create a newNamespace
object.static Triple
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.static Triple
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.static Triple
triple
(ValueFactory vf, Resource subject, IRI predicate, Value object) Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.static Triple
triple
(ValueFactory vf, Statement statement) Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.
-
Method Details
-
iri
Create a newIRI
using the supplied iri string- Parameters:
iri
- a string representing a valid (absolute) iri- Returns:
- an
IRI
object for the supplied iri string. - Throws:
NullPointerException
- if the suppplied iri isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI.
-
iri
Create a newIRI
using the supplied iri string- Parameters:
vf
- theValueFactory
to use for creation of the IRI.iri
- a string representing a valid (absolute) iri- Returns:
- an
IRI
object for the supplied iri string. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI by the suppliedValueFactory
.
-
iri
Create a newIRI
using the supplied namespace name and local name- Parameters:
namespace
- the IRI's namespace namelocalName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace name and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI.
-
iri
- Parameters:
namespace
- the IRI'sNamespace
localName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- 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 newIRI
from 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:type
is a prefixed name whererdf
is the prefix. If the correctNamespace
definition 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
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- 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 newIRI
using the supplied namespace and local name- Parameters:
vf
- theValueFactory
to use for creation of the IRI.namespace
- the IRI's namespacelocalName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- 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
- theValueFactory
to use for creation of theBNode
- Returns:
- a new
BNode
- Throws:
NullPointerException
- if any of the input parameters isnull
-
bnode
Creates a newBNode
with 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 newBNode
with the supplied node identifier.- Parameters:
vf
- theValueFactory
to use for creation of theBNode
nodeId
- the node identifier- Returns:
- a new
BNode
- Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied node identifier is not valid
-
literal
Creates a newLiteral
with the supplied lexical value.- Parameters:
lexicalValue
- the lexical value for the literal- Returns:
- a new
Literal
of typeXSD.STRING
- Throws:
NullPointerException
- if the supplied lexical value isnull
.
-
literal
Creates a newLiteral
with the supplied lexical value.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literal- Returns:
- a new
Literal
of typeXSD.STRING
- Throws:
NullPointerException
- if any of the input parameters isnull
-
literal
Creates a newLiteral
with the supplied lexical value.- Parameters:
lexicalValue
- the lexical value for the literallanguageTag
- the language tag for the literal.- Returns:
- a new
Literal
of typeRDF.LANGSTRING
- Throws:
NullPointerException
- if the supplied lexical value or language tag isnull
.
-
literal
Creates a newLiteral
with the supplied lexical value.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literallanguageTag
- the language tag for the literal.- Returns:
- a new
Literal
of typeRDF.LANGSTRING
- Throws:
NullPointerException
- if any of the input parameters isnull
-
literal
Creates a newLiteral
with the supplied lexical value and datatype.- Parameters:
lexicalValue
- the lexical value for the literaldatatype
- the datatype IRI- Returns:
- a new
Literal
with 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 newLiteral
with the supplied lexical value and datatype.- Parameters:
lexicalValue
- the lexical value for the literaldatatype
- the CoreDatatype- Returns:
- a new
Literal
with 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 newLiteral
with the supplied lexical value and datatype.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literaldatatype
- the datatype IRI- Returns:
- a new
Literal
with 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 newLiteral
with the supplied lexical value and datatype.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literaldatatype
- the CoreDatatype- Returns:
- a new
Literal
with 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 newLiteral
with the supplied boolean value- Parameters:
booleanValue
- a boolean value- Returns:
- a
Literal
of typeXSD.BOOLEAN
with the supplied value
-
literal
Creates a newLiteral
with the supplied boolean value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
booleanValue
- a boolean value- Returns:
- a
Literal
of typeXSD.BOOLEAN
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied byte value -
literal
Creates a newLiteral
with the supplied byte value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
byteValue
- a byte value- Returns:
- a
Literal
of typeXSD.BYTE
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied short value -
literal
Creates a newLiteral
with the supplied short value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
shortValue
- a short value- Returns:
- a
Literal
of typeXSD.SHORT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied int value -
literal
Creates a newLiteral
with the supplied int value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
intValue
- an int value- Returns:
- a
Literal
of typeXSD.INT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied long value -
literal
Creates a newLiteral
with the supplied long value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
longValue
- a long value- Returns:
- a
Literal
of typeXSD.LONG
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied float value -
literal
Creates a newLiteral
with the supplied float value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
floatValue
- a float value- Returns:
- a
Literal
of typeXSD.FLOAT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the supplied double value- Parameters:
doubleValue
- a double value- Returns:
- a
Literal
of typeXSD.DOUBLE
with the supplied value
-
literal
Creates a newLiteral
with the supplied double value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
doubleValue
- a double value- Returns:
- a
Literal
of typeXSD.DOUBLE
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the suppliedBigDecimal
value- Parameters:
bigDecimal
- aBigDecimal
value- Returns:
- a
Literal
of typeXSD.DECIMAL
with the supplied value - Throws:
NullPointerException
- if the supplied bigDecimal isnull
.
-
literal
Creates a newLiteral
with the suppliedBigDecimal
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
bigDecimal
- aBigDecimal
value- Returns:
- a
Literal
of typeXSD.DECIMAL
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the suppliedBigInteger
value- Parameters:
bigInteger
- aBigInteger
value- Returns:
- a
Literal
of typeXSD.INTEGER
with the supplied value - Throws:
NullPointerException
- if the supplied bigInteger isnull
.
-
literal
Creates a newLiteral
with the suppliedBigInteger
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
bigInteger
- aBigInteger
value- Returns:
- a
Literal
of typeXSD.INTEGER
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
Creates a newLiteral
with the suppliedTemporalAccessor
value- Parameters:
value
- aTemporalAccessor
value.- Returns:
- a
Literal
with the supplied calendar value and the appropriateXSD
date/time datatype for the specific value. - Throws:
NullPointerException
- if the suppliedTemporalAccessor
value 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 newLiteral
with the suppliedTemporalAccessor
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
value
- aTemporalAccessor
value.- Returns:
- a
Literal
with the supplied calendar value and the appropriateXSD
date/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 typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype. If no mapping is available, the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,Integer
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
andDate
.- 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 typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,BigDecimal
,Integer
,BigInteger
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
,invalid @link
TemporalAmpount
Date
.- Parameters:
object
- an object to be converted to a typed literal.failOnUnknownType
- If no mapping is available andfailOnUnknownType
isfalse
the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype. If set totrue
the method throws anIllegalArgumentException
if no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException
- if the input parameter isnull
..
-
literal
Creates a new typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,Integer
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
andDate
.- Parameters:
valueFactory
- theValueFactory
to use for creation of theLiteral
object
- an object to be converted to a typed literal.failOnUnknownType
- If no mapping is available andfailOnUnknownType
isfalse
the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype. If set totrue
the method throws anIllegalArgumentException
if no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException
- if any of the input parameters isnull
.IllegalArgumentException
- iffailOnUnknownType
is set totrue
and the runtime type of the supplied object could not be mapped.
-
triple
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.- Parameters:
subject
- the Triple subjectpredicate
- the Triple predicateobject
- the Triple object- Returns:
- a
Triple
with the supplied subject, predicate, and object. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
triple
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.- Parameters:
vf
- theValueFactory
to use for creation of theTriple
subject
- the Triple subjectpredicate
- the Triple predicateobject
- the Triple object- Returns:
- a
Triple
with the supplied subject, predicate, and object. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
triple
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.- Parameters:
statement
- theStatement
from which to construct aTriple
- Returns:
- a
Triple
with the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException
- if statement isnull
.
-
triple
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.- Parameters:
vf
- theValueFactory
to use for creation of theTriple
statement
- theStatement
from which to construct aTriple
- Returns:
- a
Triple
with the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
namespace
Create a newNamespace
object.- Parameters:
prefix
- the prefix associated with the namespacename
- the namespace name (typically an IRI) for the namespace.- Returns:
- a
Namespace
object. - Since:
- 3.6.0
-
getValueFactory
Get aValueFactory
.- Returns:
- a
ValueFactory
.
-