Package com.stardog.stark

# Class Values

java.lang.Object
com.stardog.stark.Values

public final class Values extends Object

Utility functions for creating and working with RDF values

Since:
  1.0
Version:
  1.0
Author:
  Michael Grove

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final IRI`
  `ALL_GRAPHS`
  Special IRI representing the union of the local and virtual graphs
  `static final DatatypeFactory`
  `DATATYPE_FACTORY`
  Datatype factory that will be used for date/time literals.
  `static final IRI`
  `DEFAULT_GRAPH`
  Special IRI representing the default (no) context.
  `static final IRI`
  `LOCAL_GRAPHS`
  Special IRI representing the union of the local (non-virtual) default graph and all local named graphs
  `static final IRI`
  `NAMED_GRAPHS`
  Special IRI representing only local named graphs; this excludes the default graph
  `static final IRI`
  `VIRTUAL_GRAPHS`
  Special IRI representing the union of the virtual graphs
  `static final String`
  `VIRTUAL_NAMESPACE`
  Namespace reserved for virtual graph names

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static BNode`
  `bnode()`
  Create a new `BNode`
  `static BNode`
  `bnode(String theId)`
  Create a new `BNode`
  `static boolean`
  `containsInvalidIRICharacters(String theIRI)`
  `static boolean`
  `containsLeadingOrTrailingWhitespace(String theIRI)`
  `static IRI`
  `iri(String theIRI)`
  Create a new `IRI`
  `static IRI`
  `iri(String theNS, String theLocalName)`
  Create a new `IRI` from a namespace and a local name
  `static boolean`
  `isAll(Resource theContext)`
  Return whether or not the resource represents the meta-context `ALL_GRAPHS`
  `static boolean`
  `isDefaultGraph(Resource theContext)`
  Return whether or not the given `Resource` denotes the default graph
  `static boolean`
  `isInDefaultGraph(Statement theStmt)`
  Return whether or not the given `Statement` is in the default graph
  `static boolean`
  `isLocal(Resource theContext)`
  `static boolean`
  `isNamed(Resource theContext)`
  Return whether or not the resource represents the meta-context `NAMED_GRAPHS`
  `static boolean`
  `isValid(IRI theIRI)`
  Verifies that the given IRI is valid.
  `static boolean`
  `isValid(Literal theLiteral)`
  Verifies that the given literal is valid.
  `static boolean`
  `isValid(Value theValue)`
  Verifies that the given value is valid.
  `static boolean`
  `isVirtual(Resource theContext)`
  Return whether the resource represents a virtual graph (starts with `VIRTUAL_NAMESPACE`
  `static Literal`
  `literal(boolean theValue)`
  Create a new `xsd:boolean` `Literal`
  `static Literal`
  `literal(byte theValue)`
  Create a new `xsd:byte` `Literal`
  `static Literal`
  `literal(double theValue)`
  Create a new `xsd:double` `Literal`
  `static Literal`
  `literal(float theValue)`
  Create a new `xsd:float` `Literal`
  `static Literal`
  `literal(int theValue)`
  Create a new `xsd:int` `Literal`
  `static Literal`
  `literal(int theLabel, Datatype theDatatype)`
  Create a new `Literal`
  `static Literal`
  `literal(long theValue)`
  Create a new `xsd:long` `Literal`
  `static Literal`
  `literal(long theLabel, Datatype theDatatype)`
  Create a new `Literal`
  `static Literal`
  `literal(short theValue)`
  Create a new `xsd:short` `Literal`
  `static Literal`
  `literal(Number theNumber)`
  `static Literal`
  `literal(String theLabel)`
  Create a new `xsd:string` `Literal`
  `static Literal`
  `literal(String theLabel, Datatype theDatatype)`
  Create a new `Literal`
  `static Literal`
  `literal(String theLabel, IRI theDatatype)`
  Create a new typed `Literal`
  `static Literal`
  `literal(String theLabel, String theLanguage)`
  Create a new language `Literal`
  `static Literal`
  `literal(BigDecimal theBigDecimal)`
  `static Literal`
  `literal(BigInteger theInt)`
  `static Literal`
  `literal(Date theDate)`
  Create a new `Literal` for the given `Date` value.
  `static Literal`
  `literal(GregorianCalendar theDate)`
  Create a new `calendar` based `Literal`.
  `static Literal`
  `literal(Duration theDuration)`
  Create a Duration typed literal.
  `static Literal`
  `literal(Duration theDuration, Datatype theDatatype)`
  `static Literal`
  `literal(Duration theDuration, IRI theDurationType)`
  Create a Duration typed literal.
  `static Literal`
  `literal(XMLGregorianCalendar theCalendar)`
  Create a new `calendar` based `Literal`.
  `static Literal`
  `literal(XMLGregorianCalendar theCalendar, Datatype theDatatype)`
  `static Namespace`
  `namespace(String thePrefix, String theIRI)`
  Create a `Namespace`
  `static Resource`
  `resource(String id)`
  Treats IDs starting with "_:" as stable bnodes and creates `BNode` objects for them, otherwise creates IRIs.
  `static Statement`
  `statement(Resource theSubject, IRI thePredicate, Value theObject)`
  Create a new `Statement` in the `default graph`
  `static Statement`
  `statement(Resource theSubject, IRI thePredicate, Value theObject, Resource theContext)`
  Create a new `Statement`
  `static IRI`
  `uniqueIri(String prefix)`
  Create a new `IRI` that is guaranteed to be unique.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_GRAPH

    public static final IRI DEFAULT_GRAPH
    Special IRI representing the default (no) context.

  - ### LOCAL_GRAPHS

    public static final IRI LOCAL_GRAPHS
    Special IRI representing the union of the local (non-virtual) default graph and all local named graphs

  - ### NAMED_GRAPHS

    public static final IRI NAMED_GRAPHS
    Special IRI representing only local named graphs; this excludes the default graph

  - ### ALL_GRAPHS

    public static final IRI ALL_GRAPHS
    Special IRI representing the union of the local and virtual graphs

  - ### VIRTUAL_GRAPHS

    public static final IRI VIRTUAL_GRAPHS
    Special IRI representing the union of the virtual graphs

  - ### DATATYPE_FACTORY

    public static final DatatypeFactory DATATYPE_FACTORY
    Datatype factory that will be used for date/time literals. Cached to boost performance.

  - ### VIRTUAL_NAMESPACE

    public static final String VIRTUAL_NAMESPACE
    Namespace reserved for virtual graph names
    See Also:
      - Constant Field Values

- ## Method Details

  - ### namespace

    @Nonnull public static Namespace namespace(@Nonnull String thePrefix, @Nonnull String theIRI)
    Create a `Namespace`
    Parameters:
      `thePrefix` - the prefix
      `theIRI` - the IRI
    Returns:
      the new `Namespace`

  - ### iri

    @Nonnull public static IRI iri(@Nonnull String theNS, @Nonnull String theLocalName)
    Create a new `IRI` from a namespace and a local name
    Parameters:
      `theNS` - the namespace IRI
      `theLocalName` - the local name
    Returns:
      the new `IRI`

  - ### iri

    @Nonnull public static IRI iri(@Nonnull String theIRI)
    Create a new `IRI`
    Parameters:
      `theIRI` - the IRI string
    Returns:
      the new `IRI`

  - ### uniqueIri

    public static IRI uniqueIri(String prefix)
    Create a new `IRI` that is guaranteed to be unique.
    Parameters:
      `prefix` - Prefix to begin the IRI with. Must contain a colon not as the first character.
    Returns:
      the new `IRI`

  - ### bnode

    @Nonnull public static BNode bnode()
    Create a new `BNode`
    Returns:
      the new `BNode`

  - ### bnode

    @Nonnull public static BNode bnode(@Nonnull String theId)
    Create a new `BNode`
    Parameters:
      `theId` - the id of the bnode
    Returns:
      the new `BNode`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull String theLabel)
    Create a new `xsd:string` `Literal`
    Parameters:
      `theLabel` - the label
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(boolean theValue)
    Create a new `xsd:boolean` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(int theValue)
    Create a new `xsd:int` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(long theValue)
    Create a new `xsd:long` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(float theValue)
    Create a new `xsd:float` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(double theValue)
    Create a new `xsd:double` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(short theValue)
    Create a new `xsd:short` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(byte theValue)
    Create a new `xsd:byte` `Literal`
    Parameters:
      `theValue` - the value
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull String theLabel, @Nonnull IRI theDatatype)
    Create a new typed `Literal`
    Parameters:
      `theLabel` - the label of the literal
      `theDatatype` - the datatype
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull String theLabel, @Nonnull String theLanguage)
    Create a new language `Literal`
    Parameters:
      `theLabel` - the label of the literal
      `theLanguage` - the language of the literal
    Returns:
      the new `Literal`

  - ### literal

    @Nonnull public static Literal literal(int theLabel, @Nonnull Datatype theDatatype)
    Create a new `Literal`
    Parameters:
      `theLabel` - the label of the literal value
      `theDatatype` - the datatype
    Returns:
      the literal
    Throws:
      `IllegalArgumentException` - if the provided value `theLabel` is not syntactically correct wrt to its Datatype

  - ### literal

    @Nonnull public static Literal literal(long theLabel, @Nonnull Datatype theDatatype)
    Create a new `Literal`
    Parameters:
      `theLabel` - the label of the literal value
      `theDatatype` - the datatype
    Returns:
      the literal
    Throws:
      `IllegalArgumentException` - if the provided value `theLabel` is not syntactically correct wrt to its Datatype

  - ### literal

    @Nonnull public static Literal literal(@Nonnull Number theNumber)

  - ### literal

    @Nonnull public static Literal literal(@Nonnull String theLabel, @Nonnull Datatype theDatatype)
    Create a new `Literal`
    Parameters:
      `theLabel` - the label of the literal value
      `theDatatype` - the datatype
    Returns:
      the literal
    Throws:
      `NumberFormatException` - if the literal is declared as a number, such as an `int` but is not syntactically correct.
      `IllegalArgumentException` - if the provided value `theLabel` is not syntactically correct wrt to its Datatype

  - ### literal

    @Nonnull public static Literal literal(@Nonnull Date theDate)
    Create a new `Literal` for the given `Date` value.
    Parameters:
      `theDate` - the value of the literal
    Returns:
      the new literal
    See Also:
      - `CalendarLiteral`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull GregorianCalendar theDate)
    Create a new `calendar` based `Literal`.
    Parameters:
      `theDate` - the value of the literal
    Returns:
      the new literal
    See Also:
      - `CalendarLiteral`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull Duration theDuration)
    Create a Duration typed literal.
    Parameters:
      `theDuration` - the duration
    Returns:
      the new duration literal

  - ### literal

    @Nonnull public static Literal literal(@Nonnull Duration theDuration, @Nonnull IRI theDurationType)
    Create a Duration typed literal. Uses the datatype specified in the method; care should be used to ensure that it's one of the xsd duration types. If not, comparison results could be indeterminate or incorrect.
    Parameters:
      `theDuration` - the duration
      `theDurationType` - the duration datatype
    Returns:
      the new duration literal

  - ### literal

    @Nonnull public static Literal literal(@Nonnull XMLGregorianCalendar theCalendar)
    Create a new `calendar` based `Literal`.
    Parameters:
      `theCalendar` - the value of the literal
    Returns:
      the new literal
    See Also:
      - `CalendarLiteral`

  - ### literal

    @Nonnull public static Literal literal(@Nonnull XMLGregorianCalendar theCalendar, @Nonnull Datatype theDatatype)

  - ### literal

    @Nonnull public static Literal literal(@Nonnull Duration theDuration, @Nonnull Datatype theDatatype)

  - ### literal

    @Nonnull public static Literal literal(@Nonnull BigDecimal theBigDecimal)

  - ### literal

    @Nonnull public static Literal literal(@Nonnull BigInteger theInt)

  - ### statement

    @Nonnull public static Statement statement(@Nonnull Resource theSubject, @Nonnull IRI thePredicate, @Nonnull Value theObject)
    Create a new `Statement` in the `default graph`
    Parameters:
      `theSubject` - the subject of the statement
      `thePredicate` - the predicate of the statement
      `theObject` - the object of the statement
    Returns:
      the new `Statement`

  - ### isValid

    public static boolean isValid(Literal theLiteral)
    Verifies that the given literal is valid. Checks if the supplied lexical value is valid for the given datatype. For language literals, it is checked if the language tag conforms to the RFC3066 spec.
    Parameters:
      `theLiteral` - the literal to validate
    Returns:
      true if it is a valid literal, false otherwise

  - ### isValid

    public static boolean isValid(IRI theIRI)
    Verifies that the given IRI is valid.
    Parameters:
      `theIRI` - the IRI to validate
    Returns:
      true if it is a valid IRI, false otherwise

  - ### containsInvalidIRICharacters

    public static boolean containsInvalidIRICharacters(String theIRI)

  - ### containsLeadingOrTrailingWhitespace

    public static boolean containsLeadingOrTrailingWhitespace(String theIRI)

  - ### isValid

    public static boolean isValid(Value theValue)
    Verifies that the given value is valid.
    Parameters:
      `theValue` - the value to validate
    Returns:
      true if it is a valid value, false otherwise

  - ### statement

    @Nonnull public static Statement statement(@Nonnull Resource theSubject, @Nonnull IRI thePredicate, @Nonnull Value theObject, Resource theContext)
    Create a new `Statement`
    Parameters:
      `theSubject` - the subject of the statement
      `thePredicate` - the predicate of the statement
      `theObject` - the object of the statement
      `theContext` - the context of the statement. if the statement is intended to be in the default graph, `DEFAULT_GRAPH` should be used.
    Returns:
      the new `Statement`

  - ### isDefaultGraph

    public static boolean isDefaultGraph(Resource theContext)
    Return whether or not the given `Resource` denotes the default graph
    Parameters:
      `theContext` - the graph
    Returns:
      `true` if the default graph, false otherwise

  - ### isVirtual

    public static boolean isVirtual(Resource theContext)
    Return whether the resource represents a virtual graph (starts with `VIRTUAL_NAMESPACE`

  - ### isInDefaultGraph

    public static boolean isInDefaultGraph(@Nonnull Statement theStmt)
    Return whether or not the given `Statement` is in the default graph
    Parameters:
      `theStmt` - the graph
    Returns:
      `true` if the default graph, false otherwise

  - ### isAll

    public static boolean isAll(@Nonnull Resource theContext)
    Return whether or not the resource represents the meta-context `ALL_GRAPHS`
    Parameters:
      `theContext` - the context
    Returns:
      true if its `ALL`, false otherwise

  - ### isLocal

    public static boolean isLocal(@Nonnull Resource theContext)

  - ### isNamed

    public static boolean isNamed(@Nonnull Resource theContext)
    Return whether or not the resource represents the meta-context `NAMED_GRAPHS`
    Parameters:
      `theContext` - the context
    Returns:
      true if its `NAMED`, false otherwise

  - ### resource

    public static Resource resource(String id)
    Treats IDs starting with "_:" as stable bnodes and creates `BNode` objects for them, otherwise creates IRIs.
    Parameters:
      `id` - resource ID
    Returns:
      IRI or bnode