Skip to main content

ModelCenter Remote Execution Java API 2025 R2

Class: PHXDouble

Last update: 16.07.2025

Package: com.phoenix_int.aserver.types

Class Hierarchy

↳ java.lang.Object
  ↳ com.phoenix_int.aserver.types.PHXSimpleType
    ↳ com.phoenix_int.aserver.types.PHXDouble

Implemented Interfaces


Declaration

public class PHXDouble
extends PHXSimpleType
implements IPHXFormat

The type for doubles. This class adds the following features to the PHXSimpleType:

  • value: double
  • valueStr: the source string for the value, useful for error checking when the value is NaN
  • hasUpperValue: boolean
  • upperValue: double
  • hasLowerValue: boolean
  • lowerValue: double
  • enumValues: double[]
  • enumValues: string[]

If the variable has an upper or lower bound and an attempt is made to store an invalid value, then an exception will be thrown.

Nested Class Summary

Nested classes/interfaces inherited from interface IPHXType2

IPHXType2.IVisitor<T>

Constructor Summary

Constructor and Description
PHXDouble()
Initializes value to zero without upper or lower bounds
PHXDouble(double value)
Initializes value to specified value without upper or lower bounds.
PHXDouble(PHXDouble other)
Clone another PHXDouble's value and metadata.

Method Summary

Modifier and Type Method and Description
protected void _copyMetadataFromOther(PHXDouble other)
Clone another PHXDouble's metadata.
<T> T Accept(IPHXType2.IVisitor<T> visitor)
Accept a Visitor.
static java.lang.String arrayToString(double[] sa)
PHXDouble 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.
void fromString3(java.lang.String value, java.util.function.ToDoubleFunction<java.lang.String> converter)
Converts a String representation to the internal value using specified converter.
java.lang.String[] getEnumAliases()
An interface function for the enumeration array.
java.lang.String getEnumAliasesStr()
An interface function for the enumeration array.
double[] getEnumValues()
An interface function for the enumeration array.
java.lang.String getEnumValuesStr()
Interface function to pass out the enumeration array as a comma separated string.
java.lang.String getFormat()
Get the format string for the variable.
boolean getHasLowerBound()
Retrieves the hasLowerBound flag.
boolean getHasUpperBound()
Retrieves the hasUpperBound flag.
double getLowerBound()
Retrieves the current lower bound value.
double getUpperBound()
Retrieves the current upper bound value.
double 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().
boolean hasFormat()
Whether or not the variable has a format.
void setEnumAliases(java.lang.String values)
Takes a comma separated string of values and fills the enumeration aliases list with values.
void setEnumAliases(java.lang.String[] values)
Sets the enumeration aliases list.
void setEnumValues(double[] values)
Sets the enumeration list of valid values.
void setEnumValues(java.lang.String values)
Takes a comma separated string of values and fills the enumeration List with values.
void setFormat(java.lang.String format)
Set the format string for the variable.
void setHasLowerBound(boolean value)
Sets the hasLowerBound flag.
void setHasUpperBound(boolean value)
Sets the hasUpperBound flag.
void setIgnoreConversionErrors(boolean ignoreConversionErrors)
Indicates whether the object should accept bad values in the fromString() method without throwing an exception.
void setLowerBound(double value)
Sets the lower bound.
void setLowerBound(java.lang.String value)
void setUpperBound(double value)
Sets the upper bound.
void setUpperBound(java.lang.String value)
void setValue(double v)
Sets the value for the variable.
java.lang.String toString()
Converts the variable to a string.
java.lang.String toString(int width)
Converts the value to a string with the best possible formatting, e.g. scientific or absolute values based on the width available.
PHXStringBuffer toString2()
Converts the variable to a PHXStringBuffer.

Methods inherited from class 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

PHXDouble

public PHXDouble()

Initializes value to zero without upper or lower bounds.

PHXDouble

public PHXDouble(double value)

Parameters:

  • value -

Initializes value to specified value without upper or lower bounds.

PHXDouble

public PHXDouble(PHXDouble other)

Parameters:

  • other - the other PHXDouble to clone.

Clone another PHXDouble's value and metadata.

Method Detail

_copyMetadataFromOther

protected final void _copyMetadataFromOther(PHXDouble other)

Parameters:

  • other - the other PHXDouble

Clone another PHXDouble's metadata.

getValue

public double 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(double v)

Parameters:

  • v - the value

Sets the value for the variable.

setUpperBound

public void setUpperBound(double value)

Parameters:

  • value - the upper bound

Sets the upper bound. The hasUpperBound value is set to true.

setUpperBound

public void setUpperBound(java.lang.String value)

getUpperBound

public double getUpperBound()

Retrieves the current upper bound value.

Returns:

  • the upper bound

setLowerBound

public void setLowerBound(double value)

Parameters:

  • value - the lower bound

Sets the lower bound. The hasLowerBound value is set to true.

setLowerBound

public void setLowerBound(java.lang.String value)

getLowerBound

public double getLowerBound()

Retrieves the current lower bound value.

Returns:

  • the lower bound

setHasUpperBound

public void setHasUpperBound(boolean value)

Parameters:

  • value - true or false

Sets the hasUpperBound flag.

getHasUpperBound

public boolean getHasUpperBound()

Retrieves the hasUpperBound flag.

Returns:

  • true or false

setHasLowerBound

public void setHasLowerBound(boolean value)

Parameters:

  • value - true or false

Sets the hasLowerBound flag.

getHasLowerBound

public boolean getHasLowerBound()

Retrieves the hasLowerBound flag.

Returns:

  • true or false

toString2

public PHXStringBuffer toString2()

Converts the variable to a PHXStringBuffer.

Specified by:

Returns:

  • the PHXStringBuffer representation of the variable

toString

public java.lang.String toString()

Converts the variable to a string.

Specified by:

Overrides:

  • toString in class java.lang.Object

Returns:

  • a String representation of the variable

fromString2

public void fromString2(PHXStringBuffer value)

Converts a PHXStringBuffer representation to the internal value.

Specified by:

Parameters:

  • value - the value to convert

fromString3

public void fromString3(java.lang.String value, 
                        java.util.function.ToDoubleFunction<java.lang.String> converter)

Converts a String representation to the internal value using specified converter.

Parameters:

  • value - the value to convert
  • converter - functional interface used to convert String value to a double

fromString

public void fromString(java.lang.String value)

Converts a String representation to the internal value.

Specified by:

Parameters:

  • value - the value to convert

toString

public java.lang.String toString(int width)
                          throws PHXNumberFormatException

Converts the value to a string with the best possible formatting, e.g. scientific or absolute values based on the width available.

Parameters:

  • width - the number of characters print to

Returns:

  • the formatted string value

Throws:

setIgnoreConversionErrors

public void setIgnoreConversionErrors(boolean ignoreConversionErrors)

Indicates whether the object should accept bad values in the fromString() method without throwing an exception. The raw value is stored in property valueStr regardless.

Parameters:

  • ignoreConversionErrors - true if errors should be ignored

setEnumValues

public void setEnumValues(java.lang.String values)

Takes a comma separated string of values and fills the enumeration List with values.

Parameters:

  • values - A comma separated string of enumeration values

setEnumValues

public void setEnumValues(double[] values)

Sets the enumeration list of valid values.

Parameters:

  • values - An array of double values

getEnumValues

public double[] getEnumValues()

An interface function for the enumeration array.

Returns:

  • an array of the possible values of the list

getEnumValuesStr

public java.lang.String getEnumValuesStr()

Interface function to pass out the enumeration array as a comma separated string.

Returns:

  • comma separated string of the possible values of the list

setEnumAliases

public void setEnumAliases(java.lang.String values)

Takes a comma separated string of values and fills the enumeration aliases list with values.

Parameters:

  • values - A comma separated string of enumeration aliases

setEnumAliases

public void setEnumAliases(java.lang.String[] values)

Sets the enumeration aliases list.

Parameters:

  • values - An array of strings

getEnumAliases

public java.lang.String[] getEnumAliases()

An interface function for the enumeration array.

Returns:

  • an array of the possible values of the list

getEnumAliasesStr

public java.lang.String getEnumAliasesStr()

An interface function for the enumeration array.

Returns:

  • a comma separated string of the possible values of the list

setFormat

public void setFormat(java.lang.String format)

Set the format string for the variable.

Specified by:

Parameters:

  • format - format string

getFormat

public java.lang.String getFormat()

Get the format string for the variable.

Specified by:

Returns:

  • format string

hasFormat

public boolean hasFormat()

Whether or not the variable has a format.

Specified by:

Returns:

  • true if variable has a format

arrayToString

public static java.lang.String arrayToString(double[] sa)

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.

NOTE: two PHXDoubles are considered naturally equal if they are the same to within 5 significant figures. The equals natural algorithm uses a relative error or epsilon comparison for equality. This should NOT be confused with a true double equality comparison and should not be used as such! It is only intended to verify that values specified in PACJ configurations are roughly equal to instantiated component values.

Specified by:

Parameters:

  • toCompare -

Returns:

  • a negative number if this object is less than toCompare, a positive number if this object is greater than to compare, and zero if these two objects are equal.

Throws:

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:

Parameters:

  • toRead - to object from which to load this objects value.

Throws:

Accept

public <T> T Accept(IPHXType2.IVisitor<T> visitor)

Accept a Visitor.

Specified by:

Type Parameters:

  • T - Type of the result of the visit.

Parameters:

  • visitor - The visitor to accept.

Returns:

  • The results of the visit.

createCopy

public PHXDouble createCopy()

Create a copy of this instance, including the value and metadata.

Specified by:

Returns:

  • a newly constructed copy of this instance.

Connect with Ansys