Class StructuredItem
- All Implemented Interfaces:
StructuredField
- Direct Known Subclasses:
StructuredBoolean
,StructuredBytes
,StructuredDecimal
,StructuredInnerList
,StructuredInteger
,StructuredString
,StructuredToken
Items and Inner List have common base class because they both can have parameters and can be members of Structured List and Structured Dictionary. Parameter values do not have "inner" parameters and cannot be Inner Lists.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbigDecimalParam
(String key) ReturnsBigDecimal
value of requested parameter.ReturnsBoolean
value of requested parameter.Optional<byte[]>
bytesParam
(String key) Returns byte[] value of requested parameter.doubleParam
(String key) ReturnsDouble
value of requested parameter.boolean
Compares the specified object with this Structured Item for equality.int
hashCode()
Returns hash code for this Structured Item.ReturnsInteger
value of requested parameter.ReturnsLong
value of requested parameter.Returns parameters associated with this Item.static StructuredItem
Parses given string for Structured Item, according to the specificationSerializes this Structured Item to a String, according to the specification.stringParam
(String key) Returns value of requested parameter converted to aString
.Returns string representation this Structured Item's valuetoString()
Returns the string representation of this Structured Item, which is the same as serialized representation.
-
Method Details
-
serialize
Serializes this Structured Item to a String, according to the specification.- Specified by:
serialize
in interfaceStructuredField
- Returns:
- Serialized representation of this Structured Item
- See Also:
-
parse
Parses given string for Structured Item, according to the specificationClass of returned value depends on parsed content, and it can be any of
StructuredItem
's subclasses, excludingStructuredInnerList
.- Parameters:
httpHeader
- String to parse, e.g. an HTTP header- Returns:
- Parsed Structured Item: a subclass of
StructuredItem
- Throws:
StructuredException
- Thrown in case of malformatted string- See Also:
-
stringValue
Returns string representation this Structured Item's valueIt's not the same as the result of serialization - it's closer to
Object.toString()
. Mostly, it should be used forStructuredString
andStructuredToken
, where underlying values are strings. For remaining classes, it could be for representation only. Properties are not included.- Returns:
- String representation of this Structured Item's value
-
parameters
Returns parameters associated with this Item. If the Item does not have any parameters, an "empty" object is returned -StructuredParameters
with empty underlying map.- Returns:
- Structured Item's parameters
-
stringParam
Returns value of requested parameter converted to aString
. Valid for all parameter types: their String representation is returned.Mostly, it should be used for String and Token parameters.
- Parameters:
key
- Parameter key- Returns:
- String value of requested parameter, or empty Optional if parameter with given key does not exist.
-
boolParam
ReturnsBoolean
value of requested parameter. Valid for Boolean parameters only.- Parameters:
key
- Parameter key- Returns:
- Boolean value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is not a Boolean
-
intParam
ReturnsInteger
value of requested parameter. Valid for Integer parameters only.(int) cast is used internally, which means that returned value will be incorrect for parameter values smaller than
Integer.MIN_VALUE
or grater thanInteger.MAX_VALUE
.- Parameters:
key
- Parameter key- Returns:
- Int value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is not an Integer
-
longParam
ReturnsLong
value of requested parameter. Valid for Integer parameters only.- Parameters:
key
- Parameter key- Returns:
- Long value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is not an Integer
-
bigDecimalParam
ReturnsBigDecimal
value of requested parameter. Valid for Decimal and Integer parameters only.- Parameters:
key
- Parameter key- Returns:
- BigDecimal value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is neither Decimal nor Integer
-
doubleParam
ReturnsDouble
value of requested parameter. Valid for Decimal and Integer parameters only.- Parameters:
key
- Parameter key- Returns:
- Double value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is neither Decimal nor Integer
-
bytesParam
Returns byte[] value of requested parameter. Valid for Byte Sequence parameters only.- Parameters:
key
- Parameter key- Returns:
- byte[] value of requested parameter, or empty Optional if parameter with given key does not exist.
- Throws:
UnsupportedOperationException
- When requested parameter is not a Byte Sequence
-
equals
Compares the specified object with this Structured Item for equality. Returns true if the given object is of the same class as this Item, it has the same value and properties. -
hashCode
public int hashCode()Returns hash code for this Structured Item. The hash code is a combination of hash codes of Item parameters and Item value. -
toString
Returns the string representation of this Structured Item, which is the same as serialized representation.
-