Constructor and Description |
---|
Group()
Constructor super of inherited Group classes
|
Group(java.lang.Object from)
Constructor to create a group from something that
wasn't originally intended to be a group, such as
a String, Integer, etc.
|
Modifier and Type | Method and Description |
---|---|
Group |
assign(java.lang.Object fromObj)
Distribute a value along each element of a structure on a
byte-by-byte basis.
|
Group |
assignByField(Group from)
assign on a field-by-field basis the given Group parameter to this
Group.
|
Group |
assignByName(Group from)
assign on a field-by-field basis the given Group parameter to this
Group only where structure names match.
|
int |
compareTo(Group anotherGroup)
Compare two structures (Group), this and anotherGroup.
|
int |
compareTo(java.lang.String op2)
Compare a structure (Group) when represented as a String
to another String.
|
boolean |
equals(Group anotherGroup)
Return if two groups are equal, same as this.compareTo(anotherGroup)==0
|
java.lang.Object[] |
findElement(java.lang.String fullName)
Find an element by name within this group using reflection taking into account
that the class structure may be embedded within program classes (e.g., MyProg$1MyGroup$2MySubGroup$3MyElement)
|
void |
fromBytes(byte[] bytes)
Use reflection to assign each Group's field from byte array segment
|
int |
getSize()
same as length
|
Group |
init(java.lang.Object value)
Initialize each element of a structure to a value, often seen in
A = '' or A(*) = '' where A is a structure or an array of structures
|
int |
length()
Use reflection to determine each Group's field size and return it
|
static void |
main(java.lang.String[] args)
unit test
|
void |
setElement(java.lang.Object field,
java.lang.Object element,
java.lang.Object value)
setElement - for a previously found element via findElement(name), set the
value of that field
|
byte[] |
toByteArray()
toByteArray - synonym for toBytes()
|
byte[] |
toBytes()
Use reflection to convert each Group's field into a byte array
|
java.lang.String |
toString()
Use reflection to convert each Group's field into a string
|
static Group |
valueOf(java.lang.Object from)
static factory method creating a group
|
public Group()
public Group(java.lang.Object from)
public static Group valueOf(java.lang.Object from)
public int compareTo(Group anotherGroup)
anotherGroup
- - a group to compare with this onepublic int compareTo(java.lang.String op2)
op2
- - a String to compare with this Grouppublic java.lang.Object[] findElement(java.lang.String fullName)
fullName
- - the name to find, which might include array indexes and other subgroups, but does not
include the top level variable or class nameNAME
- Condition if name could not be foundpublic void setElement(java.lang.Object field, java.lang.Object element, java.lang.Object value)
field
- - the Field object of an element within this Groupelement
- - the element to set (only used to verify old and new values are of the same type)value
- - the value to setpublic boolean equals(Group anotherGroup)
anotherGroup
- - the source group (this group is destination)public java.lang.String toString()
toString
in class java.lang.Object
public byte[] toBytes()
public byte[] toByteArray()
public int length()
public int getSize()
public void fromBytes(byte[] bytes)
bytes
- - the input buffer or null if we're meant to ignore this operationpublic Group assignByField(Group from)
DCL 1 G1, 2 G2, 3 G2F1 FIXED BIN(15) INIT(3), 3 G2F2 FLOAT DEC(10,5) DIM(10) init(7.0), 2 G1F3 CHAR(10) INIT('is g1f3'); DCL 1 G3, 2 G4, 3 G4F4 FIXED BIN(15), 3 G4F5 FLOAT DEC(10,5) DIM(10), 2 G3F6; G3 = G1, BY STRUCTURE // assign field objects using assignByField() //G3 = G1; // copy values by bytes using assign() //G3 = G1, BY NAME; // assign field objects by field names using assignByName() as Java public class G1 { public class G2 { public Short G2F1 = Short.value((Short)3); public ArrayG2F2 = new Array ("G2F2", 7.0); } public G2 g2 = new G2(); public @CHAR(10) String g1f3 = new String("is g1f3"); }; public class G3 { public class G4 { public Short G4F4 = Short.value((Short)3); public Array G4F5 = new Array ("G2F2", 7.0); } public G4 g4 = new G4(); public @CHAR(10) String g3f6 = new String(""); }; G1 g1 = new G1(); G3 g3 = (new G3()).assignByField(g1); assert (g1.g2.g2f1 == g3.g4.g4f4) && (g1.g2.g2f2.get(5) == g3.g4.g4f5.get(5)) && (g1.g2f3 == g3.g3f6);
from
- - the Group superclass from which content is to be copied into this GroupCondition
- CONDITION.CONVERSION - if the structures of the two
Group's subclasses do not line up on number of fields, field type or field sizepublic Group assign(java.lang.Object fromObj)
fromObj
- - the object from which to copy into this structureG1 g1 = new G1(); G3 g3 = (new G3()).assign(g1); assert (g1.g2.g2f1.shortValue() == g3.g4.g4f4.shortValue()) && (g1.g2.g2f2.get(5).doubleValue() == g3.g4.g4f5.get(5).doubleValue()) && (g1.g2f3.equals(g3.g3f6));
public Group assignByName(Group from)
G1 g1 = new G1(); G1 g11= (new G1()).assignByName(g1); assert (g1.g2.g2f1 == g11.g2.g2f1) && (g1.g2.g2f2.get(5) == g11.g2.g2f2.get(5)) && (g1.g2f3 == g11.g2f3); or, if compiled with "-out:style ENCAPSULATION" which creates getters/setters and a copy constructor G1 g1 = new G1(); G1 g11 = new G1(g1);
from
- - the Group superclass from which content is to be copied into this GroupCondition.CONDITION.CONVERSION
- - conversion between like-named
but type-differing fields can't be convertedpublic Group init(java.lang.Object value)
value
- - the scalar value to assign each element of a structure
or an array of structuresNote: difference between init() and assign() is that init() will assign each element of the structure the same value (converted to the type of that element) while assign() will distribute portions of the value (based on the byte size of the element) to elements in the structure, resulting in different values being set for each element.
public static void main(java.lang.String[] args)