public class ArrayAssigner
extends java.lang.Object
BaseDataType
array based on 2 array inputs.Modifier and Type | Class and Description |
---|---|
private static class |
ArrayAssigner.WorkArea
Stores global data relating to the state of the current context.
|
Modifier and Type | Field and Description |
---|---|
private static ContextLocal<ArrayAssigner.WorkArea> |
local
Context-local data container.
|
Constructor and Description |
---|
ArrayAssigner() |
Modifier and Type | Method and Description |
---|---|
static void |
assignMulti(BaseDataType[] target,
BaseDataType source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static BaseDataType[] |
assignMulti(BaseDataType[] target,
BaseDataType[] source)
Assigns (mutates the content of) each matching element of a target
array based on the corresponding element of the source array.
|
static void |
assignMulti(BaseDataType[] target,
boolean source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static void |
assignMulti(BaseDataType[] target,
double source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
BaseDataType source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
boolean source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
double source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
long source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
java.lang.String source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
int idx,
WrappedResource source)
Assigns (mutates the content of) all elements of a target array starting
at the given index through the end of the array, using the same source
value.
|
static void |
assignMulti(BaseDataType[] target,
long source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static void |
assignMulti(BaseDataType[] target,
java.lang.String source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static void |
assignMulti(BaseDataType[] target,
WrappedResource source)
Assigns (mutates the content of) all elements of a target array from
the same source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
BaseDataType source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
boolean source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
double source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
long source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
java.lang.String source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
long index,
WrappedResource source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
BaseDataType source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
boolean source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
double source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
long source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
java.lang.String source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingle(BaseDataType[] target,
NumberType index,
WrappedResource source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignSingleUnknown(BaseDataType[] target,
long index)
Assigns (or mutates the content of) the indexed element of a target array
to the unknown value.
|
static void |
assignSingleUnknown(BaseDataType[] target,
NumberType index)
Assigns (or mutates the content of) the indexed element of a target array
to the unknown value.
|
private static void |
assignSingleWorker(BaseDataType[] target,
NumberType index,
BaseDataType source)
Assigns (or mutates the content of) the indexed element of a target array
to the given source value.
|
static void |
assignUnknown(BaseDataType[] target)
Sets all elements of a target array to the
unknown value . |
private static void |
copyDecimalPrecision(BaseDataType[] source,
BaseDataType[] destination)
Copies decimal precision from
source to destination if
decimal array is passed in. |
static <T extends BaseDataType> |
copyOf(T[] array)
Get a copy of the given array.
|
static java.lang.Integer |
getDecimalPrecision(decimal[] array)
Returns decimal precision of the supplied array.
|
static boolean |
isDynamicArray(BaseDataType[] array)
This method returns true for any real dynamic-extent array (regardless if it had its
size set).
|
static integer |
lengthOf(BaseDataType[] array)
Get the length of the given dynamic-extent variable.
|
(package private) static void |
load()
Ensure all the context-local data has initialized (to be able to listen for scope
notifications).
|
static void |
registerDynamicArray(BaseDataType[] array)
Register the given array as a dynamic-array.
|
static void |
registerDynamicUndoableArray(java.util.Set<BaseDataType[]> arrays,
int transLevel)
Register the set of given arrays as dynamic extent.
|
(package private) static <T extends BaseDataType> |
registerExtentParameter(AbstractExtentParameter<T> extentParameter)
Registers an unfixed indeterminate extent parameter instance.
|
static <T extends BaseDataType> |
resize(T[] array,
int newSize)
Implement the EXTENT statement.
|
static <T extends BaseDataType> |
resize(T[] array,
int64 newSize)
Implement the EXTENT statement.
|
static <T extends BaseDataType> |
resize(T[] array,
int64 newSize,
boolean initToUnknown)
Implement the EXTENT statement.
|
static <T extends BaseDataType> |
resize(T[] array,
int newSize,
boolean initToUnknown)
Implement the EXTENT statement.
|
static void |
setDecimalPrecision(decimal[] array,
int precision)
Sets decimal precision for the array argument.
|
static <B extends BaseDataType> |
subscript(B[] array,
long index)
Dereference the given array using the given 1-based index.
|
static <B extends BaseDataType> |
subscript(B[] array,
NumberType index)
Dereference the given array using the given 1-based index.
|
private static int |
subscriptHelper(BaseDataType[] array,
long idx)
Generate a valid 0-based integral subscript from the 1-based numeric
value given.
|
private static int |
subscriptHelper(BaseDataType[] array,
NumberType _idx,
boolean assign)
Generate a valid 0-based integral subscript from the 1-based numeric
value given.
|
private static <B extends BaseDataType> |
subscriptWorker(B[] array,
int idx)
Dereference the given array using the given 0-based index.
|
private static ContextLocal<ArrayAssigner.WorkArea> local
static void load()
public static BaseDataType[] assignMulti(BaseDataType[] target, BaseDataType[] source) throws ErrorConditionException, java.lang.NullPointerException
In case the assignment target represents an indeterminate extent variable and the source is a determinate extent or a fixed indeterminate extent the target is reallocated to the size of the source extent. The allocated reference is returned as the result from the function.
target
- The array to be assigned. Must not be null
.source
- The array from which to assign. Must not be null
.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, long source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, double source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, java.lang.String source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, boolean source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, BaseDataType source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, WrappedResource source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, long source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, double source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, java.lang.String source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, boolean source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, BaseDataType source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignMulti(BaseDataType[] target, int idx, WrappedResource source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.idx
- Starting index (0-based) for the assignments.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure of an individual assignment.java.lang.NullPointerException
- If either the source or the target arrays are
null
.public static void assignSingle(BaseDataType[] target, long index, long source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, long index, double source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, long index, boolean source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, long index, java.lang.String source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, long index, BaseDataType source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, long index, WrappedResource source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, long source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, double source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, boolean source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, java.lang.String source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, BaseDataType source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingle(BaseDataType[] target, NumberType index, WrappedResource source) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static <B extends BaseDataType> B subscript(B[] array, long index)
array
- The array to dereference.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.public static <B extends BaseDataType> B subscript(B[] array, NumberType index)
array
- The array to dereference.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.public static void assignSingleUnknown(BaseDataType[] target, long index) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignSingleUnknown(BaseDataType[] target, NumberType index) throws ErrorConditionException, java.lang.NullPointerException
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.public static void assignUnknown(BaseDataType[] target)
unknown value
.target
- The array to be modified. Must not be null
.public static <T extends BaseDataType> T[] resize(T[] array, int newSize)
If the given array is not of size zero, then an error is raised. Else, all the elements of the array will be set to default value.
array
- The dynamic-extent array to be resized.newSize
- The array's new size.public static <T extends BaseDataType> T[] resize(T[] array, int64 newSize)
If the given array is not of size zero, then an error is raised. Else, all the elements of the array will be set to default value.
array
- The dynamic-extent array to be resized.newSize
- The array's new size.public static <T extends BaseDataType> T[] resize(T[] array, int newSize, boolean initToUnknown)
If the given array is not of size zero, then an error is raised. Else, all the elements
of the array will be set to unknown or default value depending on the initToUnknown
parameter.
array
- The dynamic-extent array to be resized.newSize
- The array's new size.initToUnknown
- Initialization flag, see above for more info.public static <T extends BaseDataType> T[] resize(T[] array, int64 newSize, boolean initToUnknown)
If the given array is not of size zero (and the newSize is not unknown), then an error is
raised. Else, the array will be resized and all the elements will be set to unknown or
the default value depending on the initToUnknown
parameter.
The new extent value must be from the [1..28000] interval.
array
- The dynamic-extent array to be resized. Must not be null. If the array was not
resized yet, must be 0-length.newSize
- The array's new size.initToUnknown
- Initialization flag, see above for more info.public static <T extends BaseDataType> T[] copyOf(T[] array)
array
- The array for which a copy is needed.public static integer lengthOf(BaseDataType[] array)
array
- The dynamic-extent variable.public static void registerDynamicArray(BaseDataType[] array)
array
- The dynamic-array to register.public static void registerDynamicUndoableArray(java.util.Set<BaseDataType[]> arrays, int transLevel)
arrays
- The set of dynamic arrays to register.transLevel
- The transaction nesting level where this instance was created.public static boolean isDynamicArray(BaseDataType[] array)
array
- The array to be checked.public static void setDecimalPrecision(decimal[] array, int precision)
array
- The array to be set with the supplied precision.precision
- Decimal precision to be set in the supplied array.public static java.lang.Integer getDecimalPrecision(decimal[] array)
null
is
returned.array
- Array representing an extent variable.null
, see above.static <T extends BaseDataType> void registerExtentParameter(AbstractExtentParameter<T> extentParameter)
extentParameter
- An instance representing an input or input-output extent parameter.java.lang.IllegalArgumentException
- When the passed in instance does not represent an unfixed
indeterminate extent.private static <B extends BaseDataType> B subscriptWorker(B[] array, int idx)
array
- The array to dereference.idx
- The 0-based index into the array. No bounds checking is done.private static int subscriptHelper(BaseDataType[] array, NumberType _idx, boolean assign) throws ErrorConditionException
array
- The array to dereference._idx
- The 1-based index to be checked and modified.assign
- true
if the extent var in on the left-side of the assign.unknown value
or -1 if the index is out of bounds
in silent error mode.ErrorConditionException
- If the index is out of bounds.private static int subscriptHelper(BaseDataType[] array, long idx) throws ErrorConditionException
array
- The array to dereference.idx
- The 1-based index to be checked and modified.ErrorConditionException
- If the index is out of bounds.private static void assignSingleWorker(BaseDataType[] target, NumberType index, BaseDataType source)
target
- The array to be assigned. Must not be null
.index
- The 1-based index into the array. This will be decremented by
1 and then used if it is in bounds.source
- The value from which to assign. Must not be null
.ErrorConditionException
- On any failure in the assignment or array index out of bounds.java.lang.NullPointerException
- If either the source or the target arrays are null
.private static void copyDecimalPrecision(BaseDataType[] source, BaseDataType[] destination)
source
to destination
if
decimal array is passed in. For non-decimal arrays, this method is effectively a no-op.source
- An array instance, the source of decimal precision.destination
- An array instance, the destination for decimal precision.java.lang.IllegalArgumentException
- When component types of the source and destination array are not equal.