Skip to main content

ModelCenter Remote Execution Java API 2025 R2

Class PHXSimpleArray`<T extendsPHXSimpleType>`

Last update: 16.07.2025

Package: com.phoenix_int.aserver.types

↳ java.lang.Object
  ↳ com.phoenix_int.aserver.types.PHXSimpleType
    ↳ com.phoenix_int.aserver.types.PHXSimpleArray<t>

All Implemented Interfaces:

Direct Known Subclasses:


Declaration

public abstract class PHXSimpleArray<t extends phxsimpletype>
extends PHXSimpleType
implements IPHXType2, java.lang.Iterable<t>

This class enables components to create resizeable arrays where the number of dimensions is variable as well as the size of each dimension. Typically you don't use this class directly but one of its sub-classes that are created and passed to you automatically.

Nested Class Summary

Nested classes/interfaces inherited from interface com.phoenix_int.aserver.types.IPHXType2

IPHXType2.IVisitor<t>

Field Summary

Modifier and Type Field and Description
protected java.lang.Object _data
protected boolean _lockDims
protected boolean _lockResize

Constructor Summary

Modifier Constructor and Description
protected PHXSimpleArray()
Default Constructor
protected PHXSimpleArray(java.lang.Object&nbsp;data)
Constructs a PHXSimpleArray that wraps a particular ModelCenter Remote Execution style variable.

Method Summary

Modifier and Type Method and Description
protected void _getMetaData()
Gets the meta data off of the first element of the array and sets it into our meta data info.
protected void _getMetaData(PHXSimpleTypev)
Worker which takes the meta data from an instance of PHXSimpleType and sets it into our meta data.
protected void _setMetaData()
Call this function to set the meta data from this object into every element of the array.
protected void _setMetaData(PHXSimpleTypev)
Sets a simple type's meta data based on the meta data in this object.
protected java.lang.Object allocateElement(java.lang.Class&nbsp;elementClass)
Allocates a single element in a default state.
static boolean checkRectangular(java.lang.Object&nbsp;obj)
Check if the array is rectangular
protected void copy(PHXSimpleArrayother)
Clone another PHXSimpleArray's value and metadata.
protected abstract boolean dataTypeOK(java.lang.Class&nbsp;c)
Must override this function and return true if the specified class is acceptable as an array element component type.
protected abstract java.lang.Object elementFromString(java.lang.String&nbsp;value)
Sub-classes must provide an implementation of this function which converts a string form of a single element to Object form.
boolean equalsNatural(PHXSimpleTypetoCompare)
Compare this PHXSimpleType to another PHXSimpleType.
void fromString(int[]&nbsp;index,PHXStringBuffervalue)
Sets the value of a single element based on string input.
void fromString(int[]&nbsp;index, java.lang.String&nbsp;value)
Sets the value of a single element based on string input.
void fromString(int&nbsp;index, java.lang.String&nbsp;value)
Sets the value of a single element based on string input for 1-d arrays.
void fromString(java.lang.String&nbsp;in)
reads in the entire array in string form.
void fromString2(PHXStringBufferin)
reads in the entire array in string form.
staticPHXSimpleArray generateFor(java.lang.Object&nbsp;o)
Static method to generate a new instance of one of the sub-classes of PHXSimpleArray as appropriate for the type of variable passed in.
staticPHXSimpleArray generateFor(java.lang.Object&nbsp;o, java.lang.Class&nbsp;c)
Static method to generate a new instance of one of the sub-classes of PHXSimpleArray as appropriate for the type of variable passed in.
java.lang.Object getArray()
Gets the entire contents of the array
java.lang.Object getArrayElement(int&nbsp;index)
Gets a particular element from a 1-d array
java.lang.Object getArrayElement(int[]&nbsp;index)
Gets a particular element from the array
java.lang.Class getComponentType()
Returns the component type of the array wrapped with this class
static java.lang.Class getComponentType(java.lang.Object&nbsp;v)
Gets the component type of an array, even for n-d arrays.
int[] getDimensions()
static int[] getDimensions(java.lang.Object&nbsp;array)
Gets the array of dimensions of the array
java.lang.Object getFirst()
Returns the first element of the array, or throws ArrayIndexOutOfBounds if there are no elements.
int getLength()
Gets the length of the first dimension of the array
int getLength(int&nbsp;dim)
Gets the length of a dimension of the array
boolean getLockResize()
protected int[] getnDIndex(long&nbsp;oneDIndex, int[]&nbsp;actualSize)
int getNumDimensions()
Gets the number of dimensions of the array
static int getNumDimensions(java.lang.Object&nbsp;o)
PHXSimpleArray getSelf()
T getValue(int&nbsp;index)
Gets an element as PHXSimpleType object of the appropriate subtype
abstractT getValue(int[]&nbsp;index)
Gets the value of an element as an object of the appropriate subtype Must be overridden in subclasses
static boolean incrementIndex(int[]&nbsp;index, int[]&nbsp;size)
Utility function for incrementing an nD index on the array
java.util.Iterator<t> iterator()
Returns an iterator that loops over the array in the standard order, rightmost index varies fastest.
void lockDimensions()
Tells this array that the number of dimensions cannot be changed from what they are right now.
int[] newIndex()
Produces a new index based zeroed out, but with the proper dimensions
static int[] parseIndex(java.lang.String&nbsp;index)
Takes a string of the form "anything[n, n2, n3]" or "n, n2, n3" and returns an int[] of the index values.
void resize(int[]&nbsp;newSize)
Resize the nD array to the new size specified.
void setArray(java.lang.Object&nbsp;v)
Sets the entire array.
void setArrayElement(int[]&nbsp;index, java.lang.Object&nbsp;v)
Sets a particular element of the array
void setArrayElement(int&nbsp;index, java.lang.Object&nbsp;v)
Sets a particular element of a 1-d array
void setDimensions(int[]&nbsp;dim)
Sets the dimensions of the array.
void setFirst(java.lang.Object&nbsp;val)
Sets the first element of the array, or throws ArrayIndexOutOfBounds if there are no elements.
void setLength(int&nbsp;len)
Sets the length of the first dimension of the array.
void setLength(int&nbsp;len, int&nbsp;dim)
Sets the length of a dimensions of the array.
void setLockResize(boolean&nbsp;lockResize)
Tells this array that it cannot be resized.
abstract void setValue(int[]&nbsp;index,Tval)
Sets an element as an object of the appropriate PHXSimpleType. Must be overridden in subclasses
void setValue(int&nbsp;index,Tval)
Sets an element as an object of the appropriate PHXSimpleType
java.lang.String toString()
Returns the string form of this array.
java.lang.String toString(int&nbsp;index)
Converts a single element of a 1-d array to a string
java.lang.String toString(int[]&nbsp;index)
Converts a single element to a string
java.lang.String toString(java.lang.String&nbsp;index)
Converts a single element to a string
PHXStringBuffer toString2()
Returns the string form of this array.
PHXStringBuffer toString2(int[]&nbsp;index)
Converts a single element to a string
PHXStringBuffer toString2(java.lang.String&nbsp;index)
Converts a single element to a string
boolean validElement(int[]&nbsp;index, int[]&nbsp;size)
Is the given index valid?

Methods inherited from class com.phoenix_int.aserver.types.PHXSimpleType

_copyMetadataFromOther, addPropertyChangeListener, createCopy, fromObject, 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

Methods inherited from interface com.phoenix_int.aserver.types.IPHXType2

Accept

Methods inherited from interface java.lang.Iterable

forEach, spliterator

Field Detail

_data

protected&nbsp;java.lang.Object _data

_lockDims

protected&nbsp;boolean _lockDims

_lockResize

protected&nbsp;boolean _lockResize

Constructor Detail

PHXSimpleArray

protected&nbsp;PHXSimpleArray(java.lang.Object&nbsp;data)

Constructs a PHXSimpleArray that wraps a particular ModelCenter Remote Execution style variable.

Parameters:

  • data - ModelCenter Remote Execution variable to wrap, which must be an array.

PHXSimpleArray

protected&nbsp;PHXSimpleArray()
```java
Default Constructor

### Method Detail

### copy

```java
protected&nbsp;void&nbsp;copy(PHXSimpleArray&nbsp;other)

Clone another PHXSimpleArray's value and metadata.

Parameters:

  • other - the other PHXSimpleArray to clone.

lockDimensions

public&nbsp;void&nbsp;lockDimensions()

Tells this array that the number of dimensions cannot be changed from what they are right now.

setLockResize

public&nbsp;void&nbsp;setLockResize(boolean&nbsp;lockResize)

Tells this array that it cannot be resized. Implies lockDimensions.

getLockResize

public&nbsp;boolean&nbsp;getLockResize()

_getMetaData

protected&nbsp;void&nbsp;_getMetaData()

Gets the meta data off of the first element of the array and sets it into our meta data info. Call this from base classes in the constructor and after anything that might change the meta information on the first array element.

_getMetaData

protected&nbsp;void&nbsp;_getMetaData(PHXSimpleType&nbsp;v)

Worker which takes the meta data from an instance of PHXSimpleType and sets it into our meta data. Override this in order to add more custom meta data in sub-classes. Be sure to call super._getMetaData(PHXSimpleType), though!

dataTypeOK

protected abstract&nbsp;boolean&nbsp;dataTypeOK(java.lang.Class&nbsp;c)
```java
Must override this function and return true if the specified class is acceptable as an array element component type.

### resize

```java
public&nbsp;void&nbsp;resize(int[]&nbsp;newSize)
            throws java.lang.IllegalAccessException,
                   java.lang.InstantiationException

Resize the nD array to the new size specified. Preserve elements if the # of dimensions stays the same, else initialize the array with default values.

Parameters:

  • newSize - new dimensions for the array

Throws:

  • java.lang.IllegalAccessException - if an error occurs allocating new array size
  • java.lang.InstantiationException - if an error occurs allocating new array size

getFirst

public&nbsp;java.lang.Object&nbsp;getFirst()

Returns the first element of the array, or throws ArrayIndexOutOfBounds if there are no elements.

setFirst

public&nbsp;void&nbsp;setFirst(java.lang.Object&nbsp;val)

Sets the first element of the array, or throws ArrayIndexOutOfBounds if there are no elements.

getLength

public&nbsp;int&nbsp;getLength()

Gets the length of the first dimension of the array

getLength

public&nbsp;int&nbsp;getLength(int&nbsp;dim)

Gets the length of a dimension of the array

Parameters:

  • dim - the dimension of interest

Returns:

  • the size of the dimension

setLength

public&nbsp;void&nbsp;setLength(int&nbsp;len)
               throws java.lang.IllegalAccessException,
                      java.lang.InstantiationException

Sets the length of the first dimension of the array. Will preserve as many element values as possible.

Parameters:

  • len - the new length of the 1D array

Throws:

  • java.lang.IllegalArgumentException - thrown if arguments are incorrect or don't jive with the current array
  • java.lang.IllegalAccessException
  • java.lang.InstantiationException

setLength

public&nbsp;void&nbsp;setLength(int&nbsp;len,
                      int&nbsp;dim)
               throws java.lang.IllegalAccessException,
                      java.lang.InstantiationException

Sets the length of a dimensions of the array. You may grow the array by 1 dimension if 'dim' is the next dim that needs defining. You may shorten the array by passing in 'len' 0 and 'dim' as the first dimension after the valid dimensions.

Parameters:

  • len - the new length of the dimension.
  • dim - the dimension to change

Throws:

  • java.lang.IllegalArgumentException - thrown if arguments are incorrect or don't jive with the current array
  • java.lang.IllegalAccessException
  • java.lang.InstantiationException

getDimensions

public static&nbsp;int[]&nbsp;getDimensions(java.lang.Object&nbsp;array)

Gets the array of dimensions of the array

Returns:

  • the array with the dimensions

getDimensions

public&nbsp;int[]&nbsp;getDimensions()

setDimensions

public&nbsp;void&nbsp;setDimensions(int[]&nbsp;dim)
                   throws java.lang.IllegalAccessException,
                          java.lang.InstantiationException

Sets the dimensions of the array. Will preserve as many element values as possible.

Parameters:

  • dim - the new dimensions for the array

Throws:

  • java.lang.IllegalAccessException
  • java.lang.InstantiationException

getNumDimensions

public static&nbsp;int&nbsp;getNumDimensions(java.lang.Object&nbsp;o)

getNumDimensions

public&nbsp;int&nbsp;getNumDimensions()

Gets the number of dimensions of the array

fromString

public&nbsp;void&nbsp;fromString(int&nbsp;index,
                       java.lang.String&nbsp;value)

Sets the value of a single element based on string input for 1-d arrays. Data is converted as appropriate.

Parameters:

  • index - Which element to set.
  • value - The new value.

fromString

public&nbsp;void&nbsp;fromString(int[]&nbsp;index,
                       PHXStringBuffer&nbsp;value)

Sets the value of a single element based on string input. Data is converted as appropriate.

Parameters:

  • index - Which element to set.
  • value - The new value.

fromString

public&nbsp;void&nbsp;fromString(int[]&nbsp;index,
                       java.lang.String&nbsp;value)

Sets the value of a single element based on string input. Data is converted as appropriate.

Parameters:

  • index - Which element to set.
  • value - The new value.

elementFromString

protected abstract&nbsp;java.lang.Object&nbsp;elementFromString(java.lang.String&nbsp;value)

Sub-classes must provide an implementation of this function which converts a string form of a single element to Object form. This is only used when the element type does not implement IPHXType or IPHXType2. For primitives, return the wrapper objects.

toString

public&nbsp;java.lang.String&nbsp;toString(int&nbsp;index)

Converts a single element of a 1-d array to a string

Parameters:

  • index - the index of the desired element

Returns:

  • the desired element, in string form

parseIndex

public static&nbsp;int[]&nbsp;parseIndex(java.lang.String&nbsp;index)

Takes a string of the form "anything[n, n2, n3]" or "n, n2, n3" and returns an int[] of the index values.

toString

public&nbsp;java.lang.String&nbsp;toString(java.lang.String&nbsp;index)

Converts a single element to a string

Parameters:

  • index - the index of the desired element

Returns:

  • the desired element, in string form

toString2

public&nbsp;PHXStringBuffer&nbsp;toString2(java.lang.String&nbsp;index)
                          throws java.io.IOException

Converts a single element to a string

Parameters:

  • index - the index of the desired element

Returns:

  • the desired element, in string form

Throws:

  • java.io.IOException

toString

public&nbsp;java.lang.String&nbsp;toString(int[]&nbsp;index)

Converts a single element to a string

Parameters:

  • index - the index of the desired element

Returns:

  • the desired element, in string form

toString2

public&nbsp;PHXStringBuffer&nbsp;toString2(int[]&nbsp;index)
                          throws java.io.IOException

Converts a single element to a string

Parameters:

  • index - the index of the desired element

Returns:

  • the desired element, in string form

Throws:

  • java.io.IOException

getArrayElement

public&nbsp;java.lang.Object&nbsp;getArrayElement(int&nbsp;index)

Gets a particular element from a 1-d array

Parameters:

  • index - the 1D array index into the 1D array

Returns:

  • the specified element

Throws:

  • java.lang.IllegalArgumentException - thrown if 1D reference is given to a >1D array

getArrayElement

public&nbsp;java.lang.Object&nbsp;getArrayElement(int[]&nbsp;index)

Gets a particular element from the array

Parameters:

  • index - the 1D array index into the 1D array

Returns:

  • the specified element

Throws:

  • java.lang.IllegalArgumentException - thrown if 1D reference is given to a >1D array

setArrayElement

public&nbsp;void&nbsp;setArrayElement(int&nbsp;index,
                            java.lang.Object&nbsp;v)

Sets a particular element of a 1-d array

Parameters:

  • index - Which index to set
  • v - The new value. Note that this takes an instance of a PHXType.

setArrayElement

public&nbsp;void&nbsp;setArrayElement(int[]&nbsp;index,
                            java.lang.Object&nbsp;v)

Sets a particular element of the array

Parameters:

  • index - Which index to set
  • v - The new value. Note that this takes an instance of a PHXType.

getArray

public&nbsp;java.lang.Object&nbsp;getArray()

Gets the entire contents of the array

Returns:

  • the base array object

setArray

public&nbsp;void&nbsp;setArray(java.lang.Object&nbsp;v)

Sets the entire array. Array is checked for validity and rectangularity. _getMetaData() is called.

Parameters:

  • v - the new array (nD)

Throws:

  • java.lang.IllegalArgumentException - thrown if array passed in is not rectangular

getSelf

public&nbsp;PHXSimpleArray&nbsp;getSelf()

checkRectangular

public static&nbsp;boolean&nbsp;checkRectangular(java.lang.Object&nbsp;obj)

Check if the array is rectangular

Parameters:

  • obj - the array to check

Returns:

  • is the array rectangular?

Throws:

  • java.lang.NullPointerException - thrown if one of the values in the array is null

getComponentType

public static&nbsp;java.lang.Class&nbsp;getComponentType(java.lang.Object&nbsp;v)

Gets the component type of an array, even for n-d arrays.

Parameters:

  • v - The array to get the component type for

getComponentType

public&nbsp;java.lang.Class&nbsp;getComponentType()

Returns the component type of the array wrapped with this class

generateFor

public static&nbsp;PHXSimpleArray&nbsp;generateFor(java.lang.Object&nbsp;o)
                                  throws java.lang.IllegalArgumentException

Static method to generate a new instance of one of the sub-classes of PHXSimpleArray as appropriate for the type of variable passed in.

Throws:

  • java.lang.IllegalArgumentException

generateFor

public static&nbsp;PHXSimpleArray&nbsp;generateFor(java.lang.Object&nbsp;o,
                                         java.lang.Class&nbsp;c)
                                  throws java.lang.IllegalArgumentException

Static method to generate a new instance of one of the sub-classes of PHXSimpleArray as appropriate for the type of variable passed in. If 'o' is null, a new 0 length array will be generated based on 'c' as the component type.

Throws:

  • java.lang.IllegalArgumentException

fromString

public&nbsp;void&nbsp;fromString(java.lang.String&nbsp;in)

Reads in the entire array in string form, e.g., bounds[3,2] { 1,2,3,4,5,6 }

Specified by:

Parameters:

  • in - the value of the variable

fromString2

public&nbsp;void&nbsp;fromString2(PHXStringBuffer&nbsp;in)

Reads in the entire array in string form. bounds[3,2] { 1,2,3,4,5,6 }

Specified by:

Parameters:

  • in - representation of the type to use

toString

public&nbsp;java.lang.String&nbsp;toString()

Returns the string form of this array. Puts each element in quotes, even if it is a number and backslashes any quote or backslash characters (" and \).

Specified by:

Overrides:

  • toString in class java.lang.Object

Returns:

  • the value as a String

toString2

public&nbsp;PHXStringBuffer&nbsp;toString2()

Returns the string form of this array. Puts each element in quotes, even if it is a number and backslashes any quote or backslash characters (" and \).

Specified by:

Returns:

  • PHXStringBuffer representation of the type

incrementIndex

public static&nbsp;boolean&nbsp;incrementIndex(int[]&nbsp;index,
                                     int[]&nbsp;size)

Utility function for incrementing an nD index on the array

Parameters:

  • index - the index to increment
  • size - the maximum size of the array

Returns:

  • did the incrment work?

Throws:

  • java.lang.IllegalArgumentException - thrown if index lengths don't match

newIndex

public&nbsp;int[]&nbsp;newIndex()

Produces a new index based zeroed out, but with the proper dimensions

Returns:

  • the new index

validElement

public&nbsp;boolean&nbsp;validElement(int[]&nbsp;index,
                            int[]&nbsp;size)

Is the given index valid?

Parameters:

  • index - the index to check
  • size - the maximum size

Returns:

  • is the given index valid?

allocateElement

protected&nbsp;java.lang.Object&nbsp;allocateElement(java.lang.Class&nbsp;elementClass)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.InstantiationException

Allocates a single element in a default state. If the class type in question has a default constructor, there is no need to override this.

Throws:

  • java.lang.IllegalAccessException
  • java.lang.InstantiationException

_setMetaData

protected&nbsp;void&nbsp;_setMetaData(PHXSimpleType&nbsp;v)

Sets a simple type's meta data based on the meta data in this object. Override this to set additional information in sub-classes. Be sure to call super._setMetaData(PHXSimpleType).

_setMetaData

protected&nbsp;void&nbsp;_setMetaData()

Call this function to set the meta data from this object into every element of the array.

getnDIndex

protected&nbsp;int[]&nbsp;getnDIndex(long&nbsp;oneDIndex,
                           int[]&nbsp;actualSize)
                    throws java.lang.IllegalArgumentException

Throws:

  • java.lang.IllegalArgumentException

getValue

public&nbsp;T&nbsp;getValue(int&nbsp;index)

Gets an element as PHXSimpleType object of the appropriate subtype

Parameters:

  • index - 1D array index

Returns:

  • referenced array value

Throws:

  • java.lang.IllegalArgumentException - thrown if called on non-1D array

setValue

public&nbsp;void&nbsp;setValue(int&nbsp;index,
                     T&nbsp;val)

Sets an element as an object of the appropriate PHXSimpleType

Parameters:

  • index - 1D array index
  • val - value to set

getValue

public abstract&nbsp;T&nbsp;getValue(int[]&nbsp;index)

Gets the value of an element as an object of the appropriate subtype. Must be overridden in subclasses

Parameters:

  • index - nD array index

Returns:

  • referenced array value

iterator

public&nbsp;java.util.Iterator<t>&nbsp;iterator()

Returns an iterator that loops over the array in the standard PHX order, rightmost index varies fastest. Note that the iterator returned is not thread safe. It also has undefined behavior if the array is modified while iterating over the array. It does not support Iterator.remove(). Lastly, the iterator returned may throw exceptions other than NoSuchElementException, such as IndexOutOfBoundsException.

Specified by:

  • iterator in interface java.lang.Iterable<textendsphxsimpletype>

See Also:

  • Iterable

setValue

public abstract&nbsp;void&nbsp;setValue(int[]&nbsp;index,
                              T&nbsp;val)

Sets an element as an object of the appropriate PHXSimpleType. Must be overridden in subclasses

Parameters:

  • index - nD array index
  • val - value to set

equalsNatural

public&nbsp;boolean&nbsp;equalsNatural(PHXSimpleType&nbsp;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.

Array comparison is handled as follows:

  1. Compare the number of dimensions between the two arrays
  2. Compare the length of dimensions between the two arrays
  3. Compare the values in each of the two arrays

If these three conditions are met, the two arrays are considered naturally equal.

Specified by:

  • equalsNatural in class PHXSimpleType

Parameters:

  • toCompare -

Returns:

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

Throws:

Connect with Ansys