JADE v6.1

com.dautelle.util
Class Struct.ArrayMember

java.lang.Object
  extended bycom.dautelle.util.Struct.Member
      extended bycom.dautelle.util.Struct.ArrayMember
Enclosing class:
Struct

public final class Struct.ArrayMember
extends Struct.Member

This class represents an array member. Array's element can be Struct.Member or Struct/Union. For example the following C code:

     struct Vertex {
         float x;
         float y;
     };
     struct Rectangle {
         int    colors[4];
         struct Vertex vertices[2][2];
         char   text[4][20];
     };
would be represented by:
     public class Vertex extends Struct {
         public final Float32 x = new Float32();
         public final Float32 y = new Float32();
     }
     public class Rectangle extends Struct {
         public final Signed32[] colors = (Signed32[]) new ArrayMember(Signed32.class, 4).get();
         public final Vertex[][] vertices = (Vertex[][]) new ArrayMember(Vertex.class, new int[] {2, 2}).get();
         public final UTF8String20[] text = (UTF8String20[]) new ArrayMember(UTF8String20.class, 4).get();
         public class UTF8String20 extends UTF8String {
             public UTF8String20() { // Default constructor (no argument) to be used.
                 super(20); // UTF8String of 20 bytes.
             }
         }
     }
Arrays elements are directly accessible:
     float x01 = myRectangle.vertices[0][1].x.get();
     myRectangle.colors[2].set(0xFF00FF);
     myRectangle.text[0].set("Blah, Blah, Blah");


Constructor Summary
Struct.ArrayMember(java.lang.Class componentType, int length)
          Creates an Struct.ArrayMember of specified component type.
Struct.ArrayMember(java.lang.Class componentType, int[] dimensions)
          Creates an Struct.ArrayMember of specified component type and dimensions.
 
Method Summary
 java.lang.Object get()
          Returns the array represented by this Struct.ArrayMember.
 
Methods inherited from class com.dautelle.util.Struct.Member
offset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Struct.ArrayMember

public Struct.ArrayMember(java.lang.Class componentType,
                          int length)
Creates an Struct.ArrayMember of specified component type.

Parameters:
componentType - the component type of the array.
length - the length of the array.
Throws:
java.lang.ClassCastException - if the componentType is not derived from Struct.Member or Struct.

Struct.ArrayMember

public Struct.ArrayMember(java.lang.Class componentType,
                          int[] dimensions)
Creates an Struct.ArrayMember of specified component type and dimensions.

Parameters:
componentType - the component type of the array.
dimensions - the dimensions of the array.
Throws:
java.lang.ClassCastException - if the componentType is not derived from Struct.Member or Struct.
Method Detail

get

public java.lang.Object get()
Returns the array represented by this Struct.ArrayMember.

Returns:
the array member.

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.