Class: PHXBoolean
Last update: 22.06.2026Package: com.phoenix_int.aserver.types
Class Hierarchy
↳ java.lang.Object
↳ com.phoenix_int.aserver.types.PHXSimpleType
↳ com.phoenix_int.aserver.types.PHXBoolean
Implemented Interfaces
IPHXType,IPHXType2,IPHXUnits
Declaration
public class PHXBoolean
extends PHXSimpleType
The type for booleans. This class adds the following features to PHXSimpleType:
- value: boolean
- valueStr: the source string for the value, useful for error checking when the value is NaN
Nested Class Summary
Nested classes/interfaces inherited from interface com.phoenix_int.aserver.types.IPHXType2
IPHXType2.IVisitor<t>
Constructor Summary
| Constructor and Description |
|---|
PHXBoolean() initializes value to false |
PHXBoolean(boolean value) Initializes the value to the specified value. |
PHXBoolean(PHXBoolean other) Clone another PHXBoolean's value and metadata. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
<t> T |
Accept(IPHXType2.IVisitor<t> visitor) Accept a Visitor. |
PHXBoolean |
createCopy() Create a copy of this instance, including the value and metadata. |
boolean |
equalsNatural(PHXSimpleType toCompare) Compare this PHXSimpleType to another PHXSimpleType. |
void |
fromObject(java.lang.Object toRead) Load the value of this object from the specified object. |
void |
fromString(java.lang.String value) Converts a String representation to the internal value |
void |
fromString2(PHXStringBuffer value)Converts a PHXStringBuffer representation to the internal value |
boolean |
getValue() Retrieves the current value of the variable |
java.lang.String |
getValueStr() Retrieves the string value of this variable as passed into the last call to fromString(). |
static boolean |
parse(java.lang.Object value) A utility function to convert a string to a boolean value |
void |
setIgnoreConversionErrors(boolean ignoreConversionErrors) Indicates whether the object should accept bad values in the fromString() method without throwing an exception. |
void |
setValue(boolean v) Sets the value for the variable |
java.lang.String |
toString() Converts the variable to a string |
PHXStringBuffer |
toString2() Converts the variable to a PHXStringBuffer |
Methods inherited from class com.phoenix_int.aserver.types.PHXSimpleType
_copyMetadataFromOther, addPropertyChangeListener, getDescription, getEnumTokens, getHasChanged, getUnits, removePropertyChangeListener, setDescription, setHasChanged, setUnits
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Constructor Detail
PHXBoolean
public PHXBoolean()
Initializes value to false.
PHXBoolean
public PHXBoolean(boolean value)
Parameters:
value- the initial value
PHXBoolean
public PHXBoolean(PHXBoolean other)
Parameters:
other- the other PHXBoolean to clone.
Method Detail
getValue
public boolean getValue()
Retrieves the current value of the variable.
Returns:
- the value of the variable
getValueStr
public java.lang.String getValueStr()
Retrieves the string value of this variable as passed into the last call to fromString(). This may not be equivalent to the current value of the variable.
Returns:
- the string last used to set the variable
setValue
public void setValue(boolean v)
Parameters:
v- the value
toString2
public PHXStringBuffer toString2()
Converts the variable to a PHXStringBuffer.
Returns:
- a PHXStringBuffer representation of the variable
toString
public java.lang.String toString()
Converts the variable to a string.
Specified by:
toStringin interfaceIPHXType
Overrides:
toStringin classjava.lang.Object
Returns:
- a String representation of the variable
fromString2
public void fromString2(PHXStringBuffer value)
Converts a PHXStringBuffer representation to the internal value.
Parameters:
value- the value to convert
fromString
public void fromString(java.lang.String value)
Converts a String representation to the internal value.
Parameters:
value- the value to convert
parse
public static boolean parse(java.lang.Object value)
A utility function to convert a string to a boolean value.
Parameters:
value- the string
Returns:
- a boolean value
setIgnoreConversionErrors
public void setIgnoreConversionErrors(boolean ignoreConversionErrors)
Indicates whether the object should accept bad values in the fromString() method without throwing an exception. The raw values is stored in property valueStr regardless.
Parameters:
ignoreConversionErrors- true if errors should be ignored
equalsNatural
public boolean equalsNatural(PHXSimpleType toCompare)
throws PHXTypeMismatchException
Compare this PHXSimpleType to another PHXSimpleType. This type of comparison is different than Comparable in that it does a natural comparison between numbers. It is not designed, nor suited, for use in things such as sets, and may behave oddly if put in those circumstances.
Specified by:
equalsNaturalin classPHXSimpleType
Parameters:
toCompare- thePHXSimpleTypeto compare
Returns:
- a negative number if this object is less than
toCompare, a positive number if this object is greater thantoCompare, and zero if these two objects are equal.
Throws:
PHXTypeMismatchException- if the givenPHXSimpleTypecannot be compared with this object.
fromObject
public void fromObject(java.lang.Object toRead)
throws PHXInvalidTypeException
Load the value of this object from the specified object. This will read the object and attempt to convert it if it is a known type. If the type isn't recognized, it will throw a PHXInvalidTypeException. If there is an error in conversion, it will also throw a PHXInvalidTypeException.
NOTE: while it might be logical to think you can create a PHX(Type)Array from, say, an array of java.lang.(Type), that is not currently supported. You MUST use the PHX string array formatting style.
Specified by:
fromObjectin classPHXSimpleType
Parameters:
toRead- to object from which to load this object's value.
Throws:
PHXInvalidTypeException- if the specified object is of an invalid type or there is an error in conversion.
Accept
public <t> T Accept(IPHXType2.IVisitor<t> visitor)
Accept a Visitor.
Type Parameters:
T- Type of the result of the visit.
Parameters:
visitor- The visitor to accept.
Returns:
- The results of the visit.
createCopy
public PHXBoolean createCopy()
Description copied from class: PHXSimpleType. Create a copy of this instance, including the value and metadata.
Specified by:
createCopyin classPHXSimpleType
Returns:
- a newly constructed copy of this instance.