Class StructuredFieldBareItem
- java.lang.Object
-
- org.apache.hc.core5.http.structured.StructuredFieldBareItem
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)booleangetBooleanValue()byte[]getByteSequenceValue()java.math.BigDecimalgetDecimalValue()longgetLongValue()java.lang.StringgetTextValue()StructuredFieldTypegetType()java.lang.ObjectgetValue()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(java.math.BigDecimal value)Creates a Decimal bare Item, applying the Structured Field rounding algorithm.static StructuredFieldBareItemofDisplayString(java.lang.String value)Creates a Unicode Display String bare Item.static StructuredFieldBareItemofInteger(long value)Creates an Integer bare Item.static StructuredFieldBareItemofString(java.lang.String value)Creates an ASCII String bare Item.static StructuredFieldBareItemofToken(java.lang.String value)Creates a Token bare Item.java.lang.StringtoString()
-
-
-
Method Detail
-
ofInteger
public static StructuredFieldBareItem ofInteger(long value)
Creates an Integer bare Item.- Parameters:
value- the integer value.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the value is outside the Structured Field range.
-
ofDecimal
public static StructuredFieldBareItem ofDecimal(java.math.BigDecimal value)
Creates a Decimal bare Item, applying the Structured Field rounding algorithm.- Parameters:
value- the decimal value.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the rounded value has more than 12 integer digits.
-
ofString
public static StructuredFieldBareItem ofString(java.lang.String value)
Creates an ASCII String bare Item.- Parameters:
value- the printable ASCII value.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the value contains a character outside SP through~.
-
ofToken
public static StructuredFieldBareItem ofToken(java.lang.String value)
Creates a Token bare Item.- Parameters:
value- the token value.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the value is not an Structured Field token.
-
ofByteSequence
public static StructuredFieldBareItem ofByteSequence(byte[] value)
Creates a Byte Sequence bare Item using a defensive copy.- Parameters:
value- the byte sequence.- Returns:
- the bare Item.
-
ofBoolean
public static StructuredFieldBareItem ofBoolean(boolean value)
Creates a Boolean bare Item.- Parameters:
value- the boolean value.- Returns:
- the bare Item.
-
ofDate
public static StructuredFieldBareItem ofDate(long epochSeconds)
Creates a Date bare Item expressed as seconds since the Unix epoch.- Parameters:
epochSeconds- seconds since the Unix epoch.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the value is outside the Structured Field Integer range.
-
ofDisplayString
public static StructuredFieldBareItem ofDisplayString(java.lang.String value)
Creates a Unicode Display String bare Item.- Parameters:
value- the Unicode value.- Returns:
- the bare Item.
- Throws:
java.lang.IllegalArgumentException- if the value contains an unpaired surrogate.
-
getType
public StructuredFieldType getType()
- Returns:
- the bare Item type.
-
getValue
public java.lang.Object 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:
java.lang.IllegalStateException- if this Item is not an Integer or Date.
-
getDecimalValue
public java.math.BigDecimal getDecimalValue()
- Returns:
- the Decimal value.
- Throws:
java.lang.IllegalStateException- if this Item is not a Decimal.
-
getTextValue
public java.lang.String getTextValue()
- Returns:
- the String, Token, or Display String value.
- Throws:
java.lang.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:
java.lang.IllegalStateException- if this Item is not a Byte Sequence.
-
getBooleanValue
public boolean getBooleanValue()
- Returns:
- the Boolean value.
- Throws:
java.lang.IllegalStateException- if this Item is not a Boolean.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-