Package org.rexxla.bsf.engines.rexx
Class ArrayWrapper
java.lang.Object
org.rexxla.bsf.engines.rexx.ArrayWrapper
This class serves as a wrapper for Java arrays. Its methods allow to fully interact
with arrays of any type from Rexx (and other non-Java-based languages). Names of
methods are called after their Object Rexx counterparts, if any.
------------------------ Apache Version 2.0 license -------------------------
Copyright (C) 2001-2021 Rony G. Flatscher
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------------------------------- - Version:
- 1.6, 2021-02-05
- Author:
- Rony G. Flatscher (WU-Wien/Wirtschaftsuniversität Wien, http://www.wu-wien.ac.at/english)
-
Field Summary
FieldsModifier and TypeFieldDescriptionintStores the total number of dimensions.intStores the total size (maximum number of entries) of the entire array.int[]Array ofintwhich stores the size (maximum number of entries) of the appropriate dimension.static StringVersion string indicating version of this class (majorVersion*100+minorVersion concatenated with a dot and the sorted date of last change. -
Constructor Summary
ConstructorsConstructorDescriptionArrayWrapper(Object objArray) Creates and returns an instance of this class, allowing easier access to Java arrays. -
Method Summary
Modifier and TypeMethodDescriptionintdimension(int i) Returns the size of the given dimension.get(int[] idxArr) Get a value (item, element) from the array at the given position.Object[]makearray(boolean bSupplier, boolean bRexxStyle) Modelled after Object RexxMAKEARRAYmethod of the array class.voidPut a value (item, element) into the array object at the given position.supplier()Creates a supplier object for allowing to enumerate the array together with the appropriate indices (Java style: index starts with0and is enclosed in square brackets).supplier(boolean bRexxStyle) Creates a supplier object for allowing to enumerate the array together with the appropriate indices.Creates a Rexx supplier object (from the supplied ooRexx .Supplier class object) for allowing to enumerate the array together with the appropriate indices.
-
Field Details
-
version
Version string indicating version of this class (majorVersion*100+minorVersion concatenated with a dot and the sorted date of last change. -
dimensions
public int dimensionsStores the total number of dimensions. -
sizeOfDimension
public int[] sizeOfDimensionArray ofintwhich stores the size (maximum number of entries) of the appropriate dimension. -
items
public int itemsStores the total size (maximum number of entries) of the entire array. -
componentType
-
-
Constructor Details
-
ArrayWrapper
Creates and returns an instance of this class, allowing easier access to Java arrays. The methodsget(int[] idxArr),put(Object valueObj, int[] idxArr),supplier(),supplier(boolean bRexxStyle)and( boolean bSupplier, boolean bRexxStyle )are modelled after ooRexx (eg. cf. ooRexx classArray).- Parameters:
objArray- the array object for which an ArrayWrapper instance is sought- Throws:
ClassNotFoundExceptionorg.apache.bsf.BSFException
-
-
Method Details
-
dimension
public int dimension(int i) Returns the size of the given dimension.- Parameters:
i- indicates the dimension of interest (Java index, i.e. first dimension to be indicated/indexed with the value0).- Returns:
- the size of the given dimension.
-
get
Get a value (item, element) from the array at the given position.- Parameters:
idxArr- a one-dimensional array ofints determining the location in the array.- Returns:
- the Object stored at the specified location.
-
put
Put a value (item, element) into the array object at the given position.- Parameters:
idxArr- a one-dimensional array ofints determining the location in the array.valueObj- the Object to store; in the case of primitives the appropriate conversions takes place, curtesy ofArray.
-
supplier
Creates a supplier object for allowing to enumerate the array together with the appropriate indices (Java style: index starts with0and is enclosed in square brackets).- Returns:
- an instance of class
Supplier, allowing for enumerating the contents of the array.
-
supplier
Creates a supplier object for allowing to enumerate the array together with the appropriate indices.- Parameters:
bRexxStyle- determines whether the index value is [Object] Rexx style (index starts with1, multiple indices are separated by a comma) or Java style (index starts with0, indices are enclosed in square brackets)- Returns:
- an instance of class
Supplier, allowing for enumerating the contents of the array.
-
supplier
Creates a Rexx supplier object (from the supplied ooRexx .Supplier class object) for allowing to enumerate the array together with the appropriate indices.- Parameters:
clzSupplier- the ooRexx "Supplier" class object to be used for creating a genuine ooRexx supplier (to allow ooRexx 5.0 new "DO WITH" to work)- Returns:
- the ooRexx supplier object (a Java
RexxProxy) - Throws:
org.apache.bsf.BSFException
-
makearray
Modelled after Object RexxMAKEARRAYmethod of the array class. This method is executed synchronized.- Parameters:
bSupplier- boolean value to indicate whether asupplierarray (containing the appropriate indices as Strings) is to be prepared and returned (if set totrue).bRexxStyle- boolean value to indicate whether using Rexx (index starts at:1) or Java (index starts at:0) style for creating the indices for asupplier.- Returns:
- a two-dimensional array of Objects, where the first element contains the single dimensioned array and the second element the optional supplier array
-