org.eclipse.rdf4j.model.util

## Class Values

- java.lang.Object
- - org.eclipse.rdf4j.model.util.Values

-     public class Values
      extends Object

  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:
    `Statements`

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BNode` | `bnode()` Creates a new `BNode`
    `static BNode` | `bnode(String nodeId)` Creates a new `BNode` with the supplied node identifier.
    `static BNode` | `bnode(ValueFactory vf)` Creates a new `BNode`
    `static BNode` | `bnode(ValueFactory vf, String nodeId)` Creates a new `BNode` with the supplied node identifier.
    `static ValueFactory` | `getValueFactory()` Get a `ValueFactory`.
    `static IRI` | `iri(String iri)` Create a new `IRI` using the supplied iri string
    `static IRI` | `iri(String namespace, String localName)` Create a new `IRI` using the supplied namespace and local name
    `static IRI` | `iri(ValueFactory vf, String iri)` Create a new `IRI` using the supplied iri string
    `static IRI` | `iri(ValueFactory vf, String namespace, String localName)` Create a new `IRI` using the supplied namespace and local name
    `static Literal` | `literal(BigDecimal bigDecimal)` Creates a new `Literal` with the supplied `BigDecimal` value
    `static Literal` | `literal(BigInteger bigInteger)` Creates a new `Literal` with the supplied `BigInteger` value
    `static Literal` | `literal(boolean booleanValue)` Creates a new `Literal` with the supplied boolean value
    `static Literal` | `literal(byte byteValue)` Creates a new `Literal` with the supplied byte value
    `static Literal` | `literal(double doubleValue)` Creates a new `Literal` with the supplied double value
    `static Literal` | `literal(float floatValue)` Creates a new `Literal` with the supplied float value
    `static Literal` | `literal(int intValue)` Creates a new `Literal` with the supplied int value
    `static Literal` | `literal(long longValue)` Creates a new `Literal` with the supplied long value
    `static Literal` | `literal(Object object)` Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype.
    `static Literal` | `literal(Object object, boolean failOnUnknownType)` Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype.
    `static Literal` | `literal(short shortValue)` Creates a new `Literal` with the supplied short value
    `static Literal` | `literal(String lexicalValue)` Creates a new `Literal` with the supplied lexical value.
    `static Literal` | `literal(String lexicalValue, IRI datatype)` Creates a new `Literal` with the supplied lexical value and datatype.
    `static Literal` | `literal(java.time.temporal.TemporalAccessor value)` Creates a new `Literal` with the supplied `TemporalAccessor` value
    `static Literal` | `literal(ValueFactory vf, BigDecimal bigDecimal)` Creates a new `Literal` with the supplied `BigDecimal` value
    `static Literal` | `literal(ValueFactory vf, BigInteger bigInteger)` Creates a new `Literal` with the supplied `BigInteger` value
    `static Literal` | `literal(ValueFactory vf, boolean booleanValue)` Creates a new `Literal` with the supplied boolean value
    `static Literal` | `literal(ValueFactory vf, byte byteValue)` Creates a new `Literal` with the supplied byte value
    `static Literal` | `literal(ValueFactory vf, double doubleValue)` Creates a new `Literal` with the supplied double value
    `static Literal` | `literal(ValueFactory vf, float floatValue)` Creates a new `Literal` with the supplied float value
    `static Literal` | `literal(ValueFactory vf, int intValue)` Creates a new `Literal` with the supplied int value
    `static Literal` | `literal(ValueFactory vf, long longValue)` Creates a new `Literal` with the supplied long value
    `static Literal` | `literal(ValueFactory vf, Object object, boolean failOnUnknownType)` Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype.
    `static Literal` | `literal(ValueFactory vf, short shortValue)` Creates a new `Literal` with the supplied short value
    `static Literal` | `literal(ValueFactory vf, String lexicalValue)` Creates a new `Literal` with the supplied lexical value.
    `static Literal` | `literal(ValueFactory vf, String lexicalValue, IRI datatype)` Creates a new `Literal` with the supplied lexical value and datatype.
    `static Literal` | `literal(ValueFactory vf, java.time.temporal.TemporalAccessor value)` Creates a new `Literal` with the supplied `TemporalAccessor` value
    `static Triple` | `triple(Resource subject, IRI predicate, Value object)` Creates a new `RDF* embedded triple` with the supplied subject, predicate, and object.
    `static Triple` | `triple(Statement statement)` Creates a new `RDF* embedded triple` using the subject, predicate and object from the supplied `Statement`.
    `static Triple` | `triple(ValueFactory vf, Resource subject, IRI predicate, Value object)` Creates a new `RDF* embedded triple` with the supplied subject, predicate, and object.
    `static Triple` | `triple(ValueFactory vf, Statement statement)` Creates a new `RDF* embedded triple` using the subject, predicate and object from the supplied `Statement`.

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

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

- - ### Method Detail

    - #### iri

          public static IRI iri(String iri)
                         throws IllegalArgumentException

      Create a new `IRI` 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 is `null`
        `IllegalArgumentException` - if the supplied iri string can not be parsed as a legal IRI.

    - #### iri

          public static IRI iri(ValueFactory vf,
                                String iri)
                         throws IllegalArgumentException

      Create a new `IRI` using the supplied iri string
      Parameters:
        `vf` - the `ValueFactory` 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 is `null`
        `IllegalArgumentException` - if the supplied iri string can not be parsed as a legal IRI by the supplied `ValueFactory` .

    - #### iri

          public static IRI iri(String namespace,
                                String localName)
                         throws IllegalArgumentException

      Create a new `IRI` using the supplied namespace and local name
      Parameters:
        `namespace` - the IRI's namespace
        `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 is `null`
        `IllegalArgumentException` - if the supplied iri string can not be parsed as a legal IRI.

    - #### iri

          public static IRI iri(ValueFactory vf,
                                String namespace,
                                String localName)
                         throws IllegalArgumentException

      Create a new `IRI` using the supplied namespace and local name
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the IRI.
        `namespace` - the IRI's namespace
        `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 is `null`
        `IllegalArgumentException` - if the supplied iri string can not be parsed as a legal IRI by the supplied `ValueFactory`

    - #### bnode

          public static BNode bnode()

      Creates a new `BNode`
      Returns:
        a new `BNode`

    - #### bnode

          public static BNode bnode(ValueFactory vf)

      Creates a new `BNode`
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `BNode`
      Returns:
        a new `BNode`
      Throws:
        `NullPointerException` - if any of the input parameters is `null`

    - #### bnode

          public static BNode bnode(String nodeId)
                             throws IllegalArgumentException

      Creates a new `BNode` with the supplied node identifier.
      Parameters:
        `nodeId` - the node identifier
      Returns:
        a new `BNode`
      Throws:
        `NullPointerException` - if the supplied node identifier is `null`.
        `IllegalArgumentException` - if the supplied node identifier is not valid

    - #### bnode

          public static BNode bnode(ValueFactory vf,
                                    String nodeId)
                             throws IllegalArgumentException

      Creates a new `BNode` with the supplied node identifier.
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `BNode`
        `nodeId` - the node identifier
      Returns:
        a new `BNode`
      Throws:
        `NullPointerException` - if any of the input parameters is `null`
        `IllegalArgumentException` - if the supplied node identifier is not valid

    - #### literal

          public static Literal literal(String lexicalValue)

      Creates a new `Literal` with the supplied lexical value.
      Parameters:
        `lexicalValue` - the lexical value for the literal
      Returns:
        a new `Literal` of type `XSD.STRING`
      Throws:
        `NullPointerException` - if the supplied lexical value is `null`.

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        String lexicalValue)

      Creates a new `Literal` with the supplied lexical value.
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `lexicalValue` - the lexical value for the literal
      Returns:
        a new `Literal` of type `XSD.STRING`
      Throws:
        `NullPointerException` - if any of the input parameters is `null`

    - #### literal

          public static Literal literal(String lexicalValue,
                                        IRI datatype)
                                 throws IllegalArgumentException

      Creates a new `Literal` with the supplied lexical value and datatype.
      Parameters:
        `lexicalValue` - the lexical value for the literal
        `datatype` - the datatype URI
      Returns:
        a new `Literal` with the supplied lexical value and datatype
      Throws:
        `NullPointerException` - if the supplied lexical value or datatype is `null`.
        `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 new `Literal` with the supplied lexical value and datatype.
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `lexicalValue` - the lexical value for the literal
        `datatype` - the datatype URI
      Returns:
        a new `Literal` with the supplied lexical value and datatype
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.
        `IllegalArgumentException` - if the supplied lexical value is not valid for the given datatype

    - #### literal

          public static Literal literal(boolean booleanValue)

      Creates a new `Literal` with the supplied boolean value
      Parameters:
        `booleanValue` - a boolean value
      Returns:
        a `Literal` of type `XSD.BOOLEAN` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        boolean booleanValue)

      Creates a new `Literal` with the supplied boolean value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `booleanValue` - a boolean value
      Returns:
        a `Literal` of type `XSD.BOOLEAN` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(byte byteValue)

      Creates a new `Literal` with the supplied byte value
      Parameters:
        `byteValue` - a byte value
      Returns:
        a `Literal` of type `XSD.BYTE` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        byte byteValue)

      Creates a new `Literal` with the supplied byte value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `byteValue` - a byte value
      Returns:
        a `Literal` of type `XSD.BYTE` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(short shortValue)

      Creates a new `Literal` with the supplied short value
      Parameters:
        `shortValue` - a short value
      Returns:
        a `Literal` of type `XSD.SHORT` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        short shortValue)

      Creates a new `Literal` with the supplied short value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `shortValue` - a short value
      Returns:
        a `Literal` of type `XSD.SHORT` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(int intValue)

      Creates a new `Literal` with the supplied int value
      Parameters:
        `intValue` - an int value
      Returns:
        a `Literal` of type `XSD.INT` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        int intValue)

      Creates a new `Literal` with the supplied int value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `intValue` - an int value
      Returns:
        a `Literal` of type `XSD.INT` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(long longValue)

      Creates a new `Literal` with the supplied long value
      Parameters:
        `longValue` - a long value
      Returns:
        a `Literal` of type `XSD.LONG` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        long longValue)

      Creates a new `Literal` with the supplied long value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `longValue` - a long value
      Returns:
        a `Literal` of type `XSD.LONG` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(float floatValue)

      Creates a new `Literal` with the supplied float value
      Parameters:
        `floatValue` - a float value
      Returns:
        a `Literal` of type `XSD.FLOAT` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        float floatValue)

      Creates a new `Literal` with the supplied float value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `floatValue` - a float value
      Returns:
        a `Literal` of type `XSD.FLOAT` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(double doubleValue)

      Creates a new `Literal` with the supplied double value
      Parameters:
        `doubleValue` - a double value
      Returns:
        a `Literal` of type `XSD.DOUBLE` with the supplied value

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        double doubleValue)

      Creates a new `Literal` with the supplied double value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `doubleValue` - a double value
      Returns:
        a `Literal` of type `XSD.DOUBLE` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(BigDecimal bigDecimal)

      Creates a new `Literal` with the supplied `BigDecimal` value
      Parameters:
        `bigDecimal` - a `BigDecimal` value
      Returns:
        a `Literal` of type `XSD.DECIMAL` with the supplied value
      Throws:
        `NullPointerException` - if the supplied bigDecimal is `null`.

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        BigDecimal bigDecimal)

      Creates a new `Literal` with the supplied `BigDecimal` value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `bigDecimal` - a `BigDecimal` value
      Returns:
        a `Literal` of type `XSD.DECIMAL` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(BigInteger bigInteger)

      Creates a new `Literal` with the supplied `BigInteger` value
      Parameters:
        `bigInteger` - a `BigInteger` value
      Returns:
        a `Literal` of type `XSD.INTEGER` with the supplied value
      Throws:
        `NullPointerException` - if the supplied bigInteger is `null`.

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        BigInteger bigInteger)

      Creates a new `Literal` with the supplied `BigInteger` value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `bigInteger` - a `BigInteger` value
      Returns:
        a `Literal` of type `XSD.INTEGER` with the supplied value
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.

    - #### literal

          public static Literal literal(java.time.temporal.TemporalAccessor value)
                                 throws IllegalArgumentException

      Creates a new `Literal` with the supplied `TemporalAccessor` value
      Parameters:
        `value` - a `TemporalAccessor` value.
      Returns:
        a `Literal` with the supplied calendar value and the appropriate `XSD` date/time datatype for the specific value.
      Throws:
        `NullPointerException` - if the supplied `TemporalAccessor` value is `null`.
        `IllegalArgumentException` - if value cannot be represented by an XML Schema date/time datatype

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        java.time.temporal.TemporalAccessor value)
                                 throws IllegalArgumentException

      Creates a new `Literal` with the supplied `TemporalAccessor` value
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Literal`
        `value` - a `TemporalAccessor` value.
      Returns:
        a `Literal` with the supplied calendar value and the appropriate `XSD` date/time datatype for the specific value.
      Throws:
        `NullPointerException` - if any of the input parameters is `null`..
        `IllegalArgumentException` - if value cannot be represented by an XML Schema date/time datatype

    - #### literal

          public static Literal literal(Object object)

      Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype. If no mapping is available, the method returns a literal with the string representation of the supplied object as the value, and `XSD.STRING` as the datatype.

      Recognized types are `Boolean`, `Byte`, `Double`, `Float`, `Integer`, `Long`, `Short`, `XMLGregorianCalendar` , `TemporalAccessor` and `Date`.

      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 is `null`..

    - #### literal

          public static Literal literal(Object object,
                                        boolean failOnUnknownType)

      Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype.

      Recognized types are `Boolean`, `Byte`, `Double`, `Float`, `Integer`, `Long`, `Short`, `XMLGregorianCalendar` , `TemporalAccessor` and `Date`.

      Parameters:
        `object` - an object to be converted to a typed literal.
        `failOnUnknownType` - If no mapping is available and `failOnUnknownType` is `false` the method returns a literal with the string representation of the supplied object as the value, and `XSD.STRING` as the datatype. If set to `true` the method throws an `IllegalArgumentException` if no mapping available.
      Returns:
        a typed literal representation of the supplied object.
      Throws:
        `NullPointerException` - if the input parameter is `null`..

    - #### literal

          public static Literal literal(ValueFactory vf,
                                        Object object,
                                        boolean failOnUnknownType)

      Creates a new typed `Literal` out of the supplied object, mapping the runtime type of the object to the appropriate `XSD` datatype.

      Recognized types are `Boolean`, `Byte`, `Double`, `Float`, `Integer`, `Long`, `Short`, `XMLGregorianCalendar`, `TemporalAccessor` and `Date`.

      Parameters:
        `valueFactory` - the `ValueFactory`to use for creation of the `Literal`
        `object` - an object to be converted to a typed literal.
        `failOnUnknownType` - If no mapping is available and `failOnUnknownType` is `false` the method returns a literal with the string representation of the supplied object as the value, and `XSD.STRING` as the datatype. If set to `true` the method throws an `IllegalArgumentException` if no mapping available.
      Returns:
        a typed literal representation of the supplied object.
      Throws:
        `NullPointerException` - if any of the input parameters is `null`.
        `IllegalArgumentException` - if `failOnUnknownType` is set to `true` and the runtime type of the supplied object could not be mapped.

    - #### triple

          public static Triple triple(Resource subject,
                                      IRI predicate,
                                      Value object)

      Creates a new `RDF* embedded triple` with the supplied subject, predicate, and object.
      Parameters:
        `subject` - the Triple subject
        `predicate` - the Triple predicate
        `object` - the Triple object
      Returns:
        a `Triple` with the supplied subject, predicate, and object.
      Throws:
        `NullPointerException` - if any of the supplied input parameters is `null`.

    - #### triple

          public static Triple triple(ValueFactory vf,
                                      Resource subject,
                                      IRI predicate,
                                      Value object)

      Creates a new `RDF* embedded triple` with the supplied subject, predicate, and object.
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Triple`
        `subject` - the Triple subject
        `predicate` - the Triple predicate
        `object` - the Triple object
      Returns:
        a `Triple` with the supplied subject, predicate, and object.
      Throws:
        `NullPointerException` - if any of the supplied input parameters is `null`.

    - #### triple

          public static Triple triple(Statement statement)

      Creates a new `RDF* embedded triple` using the subject, predicate and object from the supplied `Statement`.
      Parameters:
        `statement` - the `Statement` from which to construct a `Triple`
      Returns:
        a `Triple` with the same subject, predicate, and object as the supplied Statement.
      Throws:
        `NullPointerException` - if statement is `null`.

    - #### triple

          public static Triple triple(ValueFactory vf,
                                      Statement statement)

      Creates a new `RDF* embedded triple` using the subject, predicate and object from the supplied `Statement`.
      Parameters:
        `vf` - the `ValueFactory` to use for creation of the `Triple`
        `statement` - the `Statement` from which to construct a `Triple`
      Returns:
        a `Triple` with the same subject, predicate, and object as the supplied Statement.
      Throws:
        `NullPointerException` - if any of the supplied input parameters is `null`.

    - #### getValueFactory

          public static ValueFactory getValueFactory()

      Get a `ValueFactory`.
      Returns:
        a `ValueFactory`.

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.