Package com.stardog.stark
Interface Literal
- All Superinterfaces:
Serializable,Value
- All Known Implementing Classes:
ArrayLiteral
A literal value in an RDF graph
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanSystem setting that controls whether the casting methods ofLiteralsuch asintValue(Literal)are strict about the conversion. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbooleanValue(Literal theLiteral) Get the value of theLiteralas a `boolean`.static bytestatic XMLGregorianCalendarcalendarValue(Literal theLiteral) datatype()The datatype of the `Literal`.default IRIThe IRI of theDatatypeof the `Literal`.static BigDecimaldecimalValue(Literal theLiteral) Get the value of theLiteralas aBigDecimal.static doubledoubleValue(Literal theLiteral) Get the value of theLiteralas a `double`.static DurationdurationValue(Literal theLiteral) static floatfloatValue(Literal theLiteral) Get the value of theLiteralas a `float`.static BigIntegerintegerValue(Literal theLiteral) Get the value of theLiteralas aBigInteger.static intstatic booleanisLanguageLiteral(Literal theLiteral) Sugar for `Literal.lang().isPresent()`label()The lexical value of the literallang()Optionally, the language of the lexical value of the `Literal`.static longstatic intshortValue(Literal theLiteral) static StringReturn the `String` serialization of theLiteralstatic XMLCalendarxmlCalendarValue(Literal theLiteral)
-
Field Details
-
STRICT_TYPES
static final boolean STRICT_TYPESSystem setting that controls whether the casting methods ofLiteralsuch asintValue(Literal)are strict about the conversion. When `true`, if you try to get the `int` value of `"5"^^xsd:string` it will throw aNumberFormatExceptionbecause the datatype of the `Literal` is incompatible with `int`. If `false` thelabel()will be used and passed to, in this example, `Integer.parseInt(String)which still may throw a `NumberFormatException` if the value of the `Literal` is not a valid numeric value. The default value is `false`.
-
-
Method Details
-
label
The lexical value of the literal- Returns:
- the lexical value
-
lang
Optionally, the language of the lexical value of the `Literal`. When present, thedatatype()isRDF.LANG_STRING.- Returns:
- the language of the literal
- See Also:
-
datatypeIRI
The IRI of theDatatypeof the `Literal`. Often, this is syntactic sugar for `datatype().iri()` however, in the case where it is a user defined datatype, egDatatype.UDFthis will return the specific IRI of the datatype.- Returns:
- the datatype IRI of the lexical value
-
datatype
The datatype of the `Literal`. Some serializations of RDF use a "simple literal" which is a literal with no explicit datatype. That is just syntactic sugar for `xsd:string` typed literals.- Returns:
- the Datatype
-
str
Return the `String` serialization of theLiteral- Parameters:
theLiteral- the `Literal` to serialize- Returns:
- the serialized `Literal`
-
isLanguageLiteral
Sugar for `Literal.lang().isPresent()`- Parameters:
theLiteral- the literal- Returns:
- whether it's a language tagged literal
-
booleanValue
Get the value of theLiteralas a `boolean`.- Parameters:
theLiteral- the literal- Returns:
- the value
- See Also:
-
calendarValue
- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
IllegalArgumentException- if the literal is not a calendar datatype- See Also:
-
xmlCalendarValue
- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
IllegalArgumentException- if the literal is not a calendar datatype- See Also:
-
intValue
-
byteValue
-
shortValue
-
longValue
-
durationValue
-
floatValue
Get the value of theLiteralas a `float`.- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
NumberFormatException- if the literal is not a numeric datatype
-
doubleValue
Get the value of theLiteralas a `double`.- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
NumberFormatException- if the literal is not a numeric datatype
-
integerValue
Get the value of theLiteralas aBigInteger.- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
NumberFormatException- if the literal is not a numeric datatype
-
decimalValue
Get the value of theLiteralas aBigDecimal.- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
NumberFormatException- if the literal is not a numeric datatype
-