Class StructuredFieldBareItem
java.lang.Object
org.apache.hc.core5.http.structured.StructuredFieldBareItem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimalprivate final StructuredFieldTypeprivate final Object -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateStructuredFieldBareItem(StructuredFieldType type, Object value) -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcheckInteger(long value) booleanbooleanbyte[]longgetType()getValue()Returns the value using its Java representation.inthashCode()static StructuredFieldBareItemofBoolean(boolean value) Creates a Boolean bare Item.static StructuredFieldBareItemofByteSequence(byte[] value) Creates a Byte Sequence bare Item using a defensive copy.static StructuredFieldBareItemofDate(long epochSeconds) Creates a Date bare Item expressed as seconds since the Unix epoch.static StructuredFieldBareItemofDecimal(BigDecimal value) Creates a Decimal bare Item, applying the Structured Field rounding algorithm.static StructuredFieldBareItemofDisplayString(String value) Creates a Unicode Display String bare Item.static StructuredFieldBareItemofInteger(long value) Creates an Integer bare Item.static StructuredFieldBareItemCreates an ASCII String bare Item.static StructuredFieldBareItemCreates a Token bare Item.private voidrequireType(StructuredFieldType... expected) toString()
-
Field Details
-
DECIMAL_ROUNDING_LIMIT
-
type
-
value
-
-
Constructor Details
-
StructuredFieldBareItem
-
-
Method Details
-
ofInteger
Creates an Integer bare Item.- Parameters:
value- the integer value.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the value is outside the Structured Field range.
-
ofDecimal
Creates a Decimal bare Item, applying the Structured Field rounding algorithm.- Parameters:
value- the decimal value.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the rounded value has more than 12 integer digits.
-
ofString
Creates an ASCII String bare Item.- Parameters:
value- the printable ASCII value.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the value contains a character outside SP through~.
-
ofToken
Creates a Token bare Item.- Parameters:
value- the token value.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the value is not an Structured Field token.
-
ofByteSequence
Creates a Byte Sequence bare Item using a defensive copy.- Parameters:
value- the byte sequence.- Returns:
- the bare Item.
-
ofBoolean
Creates a Boolean bare Item.- Parameters:
value- the boolean value.- Returns:
- the bare Item.
-
ofDate
Creates a Date bare Item expressed as seconds since the Unix epoch.- Parameters:
epochSeconds- seconds since the Unix epoch.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the value is outside the Structured Field Integer range.
-
ofDisplayString
Creates a Unicode Display String bare Item.- Parameters:
value- the Unicode value.- Returns:
- the bare Item.
- Throws:
IllegalArgumentException- if the value contains an unpaired surrogate.
-
checkInteger
private static void checkInteger(long value) -
getType
- Returns:
- the bare Item type.
-
getValue
Returns the value using its Java representation. Byte sequences are defensively copied.- Returns:
- the value.
-
getLongValue
public long getLongValue()- Returns:
- the Integer or Date value.
- Throws:
IllegalStateException- if this Item is not an Integer or Date.
-
getDecimalValue
- Returns:
- the Decimal value.
- Throws:
IllegalStateException- if this Item is not a Decimal.
-
getTextValue
- Returns:
- the String, Token, or Display String value.
- Throws:
IllegalStateException- if this Item is not one of those textual types.
-
getByteSequenceValue
public byte[] getByteSequenceValue()- Returns:
- a defensive copy of the Byte Sequence value.
- Throws:
IllegalStateException- if this Item is not a Byte Sequence.
-
getBooleanValue
public boolean getBooleanValue()- Returns:
- the Boolean value.
- Throws:
IllegalStateException- if this Item is not a Boolean.
-
requireType
-
equals
-
hashCode
-
toString
-