Class AbstractLiteral
- java.lang.Object
-
- org.eclipse.rdf4j.model.base.AbstractLiteral
-
- Direct Known Subclasses:
AbstractLiteral.BooleanLiteral,AbstractLiteral.CalendarLiteral,AbstractLiteral.NumberLiteral,AbstractLiteral.TaggedLiteral,AbstractLiteral.TemporalAccessorLiteral,AbstractLiteral.TemporalAmountLiteral,AbstractLiteral.TypedLiteral,NumericLiteral,SimpleLiteral
public abstract class AbstractLiteral extends java.lang.Object implements Literal
Base class forLiteral, offering common functionality.- Since:
- 3.5.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAbstractLiteral.BooleanLiteral(package private) static classAbstractLiteral.CalendarLiteral(package private) static classAbstractLiteral.DecimalLiteral(package private) static classAbstractLiteral.IntegerLiteral(package private) static classAbstractLiteral.NumberLiteral(package private) static classAbstractLiteral.TaggedLiteral(package private) static classAbstractLiteral.TemporalAccessorLiteral(package private) static classAbstractLiteral.TemporalAmountLiteral(package private) static classAbstractLiteral.TypedLiteral
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description AbstractLiteral()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbooleanValue()Returns the boolean value of this literal.bytebyteValue()Returns the byte value of this literal.javax.xml.datatype.XMLGregorianCalendarcalendarValue()Returns theXMLGregorianCalendarvalue of this literal.java.math.BigDecimaldecimalValue()Returns the decimal value of this literal.doubledoubleValue()Returns the double value of this literal.booleanequals(java.lang.Object o)Compares this literal to another object.private booleanequals(java.util.Optional<java.lang.String> x, java.util.Optional<java.lang.String> y)floatfloatValue()Returns the float value of this literal.inthashCode()Computes the hash code of this literal.java.math.BigIntegerintegerValue()Returns the integer value of this literal.intintValue()Returns the int value of this literal.longlongValue()Returns the long value of this literal.(package private) static booleanreserved(CoreDatatype datatype)(package private) static booleanreserved(IRI datatype)shortshortValue()Returns the short value of this literal.java.lang.StringstringValue()Returns the String-value of a Value object.java.time.temporal.TemporalAccessortemporalAccessorValue()Retrieves thetemporal accessorvalue of this literal.java.time.temporal.TemporalAmounttemporalAmountValue()Retrieves thetemporal amountvalue of this literal.java.lang.StringtoString()private <V> Vvalue(java.util.function.Function<java.lang.String,V> mapper)Converts this literal to a value.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.model.Literal
getCoreDatatype, getDatatype, getLabel, getLanguage, isLiteral
-
Methods inherited from interface org.eclipse.rdf4j.model.Value
isBNode, isIRI, isResource, isTriple
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
reserved
static boolean reserved(IRI datatype)
-
reserved
static boolean reserved(CoreDatatype datatype)
-
value
private <V> V value(java.util.function.Function<java.lang.String,V> mapper)
Converts this literal to a value.- Type Parameters:
V- the expected value type- Parameters:
mapper- a function mapping from the label of this literal to its value; returns anullvalue or throws anIllegalArgumentExceptionif the label of this literal doesn't represent a value of the expected type- Returns:
- the value returned by
mapper - Throws:
java.lang.NullPointerException- ifmapperisnull
-
stringValue
public java.lang.String stringValue()
Description copied from interface:ValueReturns the String-value of a Value object. This returns either aLiteral's label, aIRI's URI or aBNode's ID.- Specified by:
stringValuein interfaceValue
-
booleanValue
public boolean booleanValue()
Description copied from interface:LiteralReturns the boolean value of this literal.- Specified by:
booleanValuein interfaceLiteral- Returns:
- The boolean value of the literal.
-
byteValue
public byte byteValue()
Description copied from interface:LiteralReturns the byte value of this literal.
-
shortValue
public short shortValue()
Description copied from interface:LiteralReturns the short value of this literal.- Specified by:
shortValuein interfaceLiteral- Returns:
- The short value of the literal.
-
intValue
public int intValue()
Description copied from interface:LiteralReturns the int value of this literal.
-
longValue
public long longValue()
Description copied from interface:LiteralReturns the long value of this literal.
-
floatValue
public float floatValue()
Description copied from interface:LiteralReturns the float value of this literal.- Specified by:
floatValuein interfaceLiteral- Returns:
- The float value of the literal.
-
doubleValue
public double doubleValue()
Description copied from interface:LiteralReturns the double value of this literal.- Specified by:
doubleValuein interfaceLiteral- Returns:
- The double value of the literal.
-
integerValue
public java.math.BigInteger integerValue()
Description copied from interface:LiteralReturns the integer value of this literal.- Specified by:
integerValuein interfaceLiteral- Returns:
- The integer value of the literal.
-
decimalValue
public java.math.BigDecimal decimalValue()
Description copied from interface:LiteralReturns the decimal value of this literal.- Specified by:
decimalValuein interfaceLiteral- Returns:
- The decimal value of the literal.
-
temporalAccessorValue
public java.time.temporal.TemporalAccessor temporalAccessorValue() throws java.time.DateTimeExceptionDescription copied from interface:LiteralRetrieves thetemporal accessorvalue of this literal.A temporal accessor representation can be given for literals whose label conforms to the syntax of the following XML Schema 1.1 date/time datatypes:
Temporal accessor representations may be converted to specific
java.timevalues likeOffsetDateTimeusing target static factory methods, for instanceOffsetDateTime.from(literal.temporalAccessorValue()).Note however that
java.timedoesn't include dedicated classes for some legal XML Schema date/time values, like offset dates (for instance,2020-11-16+01:00) andxsd:gDay(for instance,---16).- Specified by:
temporalAccessorValuein interfaceLiteral- Returns:
- the temporal accessor value of this literal
- Throws:
java.time.DateTimeException- if this literal cannot be represented by aTemporalAccessorvalue- See Also:
- The Java™ Tutorials – Trail: Date Time
-
temporalAmountValue
public java.time.temporal.TemporalAmount temporalAmountValue() throws java.time.DateTimeExceptionDescription copied from interface:LiteralRetrieves thetemporal amountvalue of this literal.A temporal amount representation can be given for literals whose label conforms to the syntax of the XML Schema 2 xsd:duration datatype.
The adoption of the XML Schema 2 definition is a known deviation from the RDF 1.1 standard; well-formedness rules are relaxed to consider all duration components as optional and freely mixable.
Temporal amount representations may be converted to specific
java.timevalues likeDurationusing target static factory methods, for instanceDuration.from(literal.temporalAmountValue()).Note however that
java.timedoesn't include dedicated classes for legal XML Schema duration values including both date and time components (for instance,P1YT23H).- Specified by:
temporalAmountValuein interfaceLiteral- Returns:
- the temporal amount value of this literal
- Throws:
java.time.DateTimeException- if this literal cannot be represented by aTemporalAmountvalue- See Also:
- The Java™ Tutorials – Trail: Date Time
-
calendarValue
public javax.xml.datatype.XMLGregorianCalendar calendarValue()
Description copied from interface:LiteralReturns theXMLGregorianCalendarvalue of this literal. A calendar representation can be given for literals whose label conforms to the syntax of the following XML Schema datatypes: dateTime, time, date, gYearMonth, gMonthDay, gYear, gMonth or gDay.- Specified by:
calendarValuein interfaceLiteral- Returns:
- The calendar value of the literal.
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:LiteralCompares this literal to another object.- Specified by:
equalsin interfaceLiteral- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the object to compare this literal to- Returns:
true, if the other object is an instance ofLiteraland if their labels, language tags and datatypes are equal
-
hashCode
public int hashCode()
Description copied from interface:LiteralComputes the hash code of this literal.- Specified by:
hashCodein interfaceLiteral- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code for this literal computed as
Literal.getLabel().hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
private boolean equals(java.util.Optional<java.lang.String> x, java.util.Optional<java.lang.String> y)
-
-