com.jinvoke
Annotation Type Embedded


@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface Embedded

The @Embedded annotation is used to declare fixed-size Strings and arrays embedded in structures.

This annotation should be applied to String and array fields of a class declared with the NativeStruct annotation.

The length of the embedded String, or the number of elements in the embedded array is specified using the length member.

Example:

Some structures have fixed size strings embedded in them. The LOGFONT struct is defined as below:

typedef struct tagLOGFONT { 
  LONG lfHeight; 
  LONG lfWidth; 
  //... some fields deleted for clarity 
  TCHAR lfFaceName[32]; // embedded string of length 32 chars
} LOGFONT, *PLOGFONT; 

This struct can be represented by a Java class with the @NativeStruct annotation. The lpFaceName member is an embedded String of length 32 characters, and is expressed using the @Embedded annotation as shown below:

import com.jinvoke.Embedded;
import com.jinvoke.NativeStruct;

@NativeStruct
public class LOGFONT {
        public int lfHeight;
        public int lfWidth;
        //... some fields deleted for clarity
        @Embedded(length=32) 
        String lpFaceName;       // embedded string of length 32 chars
}

Similarly, the native structure PAINTSTRUCT has an embedded array of 32 bytes (rgbReserved):

typedef struct tagPAINTSTRUCT { 
  HDC  hdc; 
  BOOL fErase; 
  RECT rcPaint; 
  BOOL fRestore; 
  BOOL fIncUpdate; 
  BYTE rgbReserved[32]; 
} PAINTSTRUCT, *PPAINTSTRUCT; 
This struct can be represented by a Java class with the @NativeStruct annotation. The rgbReserved member is an embedded byte array of length 32 characters, and is expressed using the @Embedded annotation as shown below:
import com.jinvoke.Embedded;
import com.jinvoke.NativeStruct;

@NativeStruct
public class PaintStruct {
    public int hdc;
    public boolean fErase;
    public Rect    rcPaint;
    public boolean fRestore;
    public boolean fIncUpdate;
    @Embedded(length=32)
    public byte[] rgbReserved = new byte[32];
}


Required Element Summary
 int length
          The number of elements in the embedded array, or the number of characters in the embedded String.
 

Element Detail

length

public abstract int length
The number of elements in the embedded array, or the number of characters in the embedded String.