Package com.unboundid.util.json
Class JSONBoolean
- java.lang.Object
-
- com.unboundid.util.json.JSONValue
-
- com.unboundid.util.json.JSONBoolean
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class JSONBoolean extends JSONValue
This class provides an implementation of a JSON value that represents a Java Boolean. The string representation of the JSON Boolean true value istrue, and the string representation of the JSON Boolean false value isfalse. These values are not surrounded by quotation marks, and they must be entirely lowercase.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static JSONBooleanFALSEA pre-allocated object that represents a value offalse.static JSONBooleanTRUEA pre-allocated object that represents a value oftrue.
-
Constructor Summary
Constructors Constructor Description JSONBoolean(boolean booleanValue)Creates a new JSON value capable of representing a Boolean value of eithertrueorfalse.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendToJSONBuffer(JSONBuffer buffer)Appends this value to the provided JSON buffer.voidappendToJSONBuffer(java.lang.String fieldName, JSONBuffer buffer)Appends a field with the given name and this value to the provided JSON buffer.booleanbooleanValue()Retrieves the Java boolean value for this JSON value.booleanequals(JSONValue v, boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)Indicates whether this JSON value is considered equal to the provided JSON value, subject to the specified constraints.booleanequals(java.lang.Object o)Indicates whether the provided object is equal to this JSON value.inthashCode()Retrieves a hash code for this JSON value.java.lang.StringtoNormalizedString()Retrieves a normalized string representation of this Boolean value as it should appear in a JSON object.java.lang.StringtoNormalizedString(boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)Retrieves a normalized string representation of this Boolean value as it should appear in a JSON object.voidtoNormalizedString(java.lang.StringBuilder buffer)Appends a normalized string representation of this Boolean value as it should appear in a JSON object to the provided buffer.voidtoNormalizedString(java.lang.StringBuilder buffer, boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)Appends a normalized string representation of this Boolean value as it should appear in a JSON object to the provided buffer.java.lang.StringtoSingleLineString()Retrieves a single-line string representation of this Boolean value as it should appear in a JSON object.voidtoSingleLineString(java.lang.StringBuilder buffer)Appends a single-line string representation of this Boolean value as it should appear in a JSON object to the provided buffer.java.lang.StringtoString()Retrieves a string representation of this Boolean value as it should appear in a JSON object.voidtoString(java.lang.StringBuilder buffer)Appends a string representation of this Boolean value as it should appear in a JSON object to the provided buffer.
-
-
-
Field Detail
-
FALSE
public static final JSONBoolean FALSE
A pre-allocated object that represents a value offalse.
-
TRUE
public static final JSONBoolean TRUE
A pre-allocated object that represents a value oftrue.
-
-
Constructor Detail
-
JSONBoolean
public JSONBoolean(boolean booleanValue)
Creates a new JSON value capable of representing a Boolean value of eithertrueorfalse.- Parameters:
booleanValue- The Boolean value for this JSON value.
-
-
Method Detail
-
booleanValue
public boolean booleanValue()
Retrieves the Java boolean value for this JSON value.- Returns:
- The Java boolean value for this JSON value.
-
hashCode
public int hashCode()
Retrieves a hash code for this JSON value.
-
equals
public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this JSON value.
-
equals
public boolean equals(JSONValue v, boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)
Indicates whether this JSON value is considered equal to the provided JSON value, subject to the specified constraints. Note that not all constraints will apply to all data types.- Specified by:
equalsin classJSONValue- Parameters:
v- The JSON value for which to make the determination. It must not benull.ignoreFieldNameCase- Indicates whether to ignore differences in the capitalization of JSON field names.ignoreValueCase- Indicates whether to ignore differences in the capitalization of JSON values that represent strings.ignoreArrayOrder- Indicates whether to ignore differences in the order of elements in JSON arrays.- Returns:
trueif this JSON value is considered equal to the provided JSON value (subject to the specified constraints), orfalseif not.
-
toString
public java.lang.String toString()
Retrieves a string representation of this Boolean value as it should appear in a JSON object. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).
-
toString
public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this Boolean value as it should appear in a JSON object to the provided buffer. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).
-
toSingleLineString
public java.lang.String toSingleLineString()
Retrieves a single-line string representation of this Boolean value as it should appear in a JSON object. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toSingleLineStringin classJSONValue- Returns:
- A single-line string representation of this Boolean value as it should appear in a JSON object.
-
toSingleLineString
public void toSingleLineString(java.lang.StringBuilder buffer)
Appends a single-line string representation of this Boolean value as it should appear in a JSON object to the provided buffer. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toSingleLineStringin classJSONValue- Parameters:
buffer- The buffer to which the information should be appended.
-
toNormalizedString
public java.lang.String toNormalizedString()
Retrieves a normalized string representation of this Boolean value as it should appear in a JSON object. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toNormalizedStringin classJSONValue- Returns:
- A normalized string representation of this Boolean value as it should appear in a JSON object.
-
toNormalizedString
public void toNormalizedString(java.lang.StringBuilder buffer)
Appends a normalized string representation of this Boolean value as it should appear in a JSON object to the provided buffer. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toNormalizedStringin classJSONValue- Parameters:
buffer- The buffer to which the information should be appended.
-
toNormalizedString
public java.lang.String toNormalizedString(boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)
Retrieves a normalized string representation of this Boolean value as it should appear in a JSON object. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toNormalizedStringin classJSONValue- Parameters:
ignoreFieldNameCase- Indicates whether field names should be treated in a case-sensitive (iffalse) or case-insensitive (iftrue) manner.ignoreValueCase- Indicates whether string field values should be treated in a case-sensitive (iffalse) or case-insensitive (iftrue) manner.ignoreArrayOrder- Indicates whether the order of elements in an array should be considered significant (iffalse) or insignificant (iftrue).- Returns:
- A normalized string representation of this Boolean value as it should appear in a JSON object.
-
toNormalizedString
public void toNormalizedString(java.lang.StringBuilder buffer, boolean ignoreFieldNameCase, boolean ignoreValueCase, boolean ignoreArrayOrder)
Appends a normalized string representation of this Boolean value as it should appear in a JSON object to the provided buffer. If the Boolean value istrue, then the string representation will be "true" (without the surrounding quotes). If the Boolean value isfalse, then the string representation will be "false" (again, without the quotes).- Specified by:
toNormalizedStringin classJSONValue- Parameters:
buffer- The buffer to which the information should be appended.ignoreFieldNameCase- Indicates whether field names should be treated in a case-sensitive (iffalse) or case-insensitive (iftrue) manner.ignoreValueCase- Indicates whether string field values should be treated in a case-sensitive (iffalse) or case-insensitive (iftrue) manner.ignoreArrayOrder- Indicates whether the order of elements in an array should be considered significant (iffalse) or insignificant (iftrue).
-
appendToJSONBuffer
public void appendToJSONBuffer(JSONBuffer buffer)
Appends this value to the provided JSON buffer. This will not include a field name, so it should only be used for Boolean value elements in an array.- Specified by:
appendToJSONBufferin classJSONValue- Parameters:
buffer- The JSON buffer to which this value should be appended.
-
appendToJSONBuffer
public void appendToJSONBuffer(java.lang.String fieldName, JSONBuffer buffer)
Appends a field with the given name and this value to the provided JSON buffer.- Specified by:
appendToJSONBufferin classJSONValue- Parameters:
fieldName- The name to use for the field.buffer- The JSON buffer to which this value should be appended.
-
-