endurox-java
Public Member Functions | List of all members
org.endurox.TypedUbf Class Reference

Public Member Functions

 TypedUbf (AtmiCtx ctx, boolean doFinalize, long cPtr, long len)
 
native void Badd (int bfldid, short s)
 
native void Badd (int bfldid, long l)
 
native void Badd (int bfldid, byte c)
 
native void Badd (int bfldid, float f)
 
native void Badd (int bfldid, double d)
 
native void Badd (int bfldid, String s)
 
native void Badd (int bfldid, byte []b)
 
native void Bprint ()
 
native short BgetShort (int bfldid, int occ)
 
native long BgetLong (int bfldid, int occ)
 
native byte BgetByte (int bfldid, int occ)
 
native float BgetFloat (int bfldid, int occ)
 
native double BgetDouble (int bfldid, int occ)
 
native String BgetString (int bfldid, int occ)
 
native byte [] BgetByteArr (int bfldid, int occ)
 
native void Baddfast (int bfldid, short s, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, long l, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, byte c, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, float f, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, double d, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, String s, BFldLocInfo next_fld)
 
native void Baddfast (int bfldid, byte []b, BFldLocInfo next_fld)
 
native void Bchg (int bfldid, int occ, short s)
 
native void Bchg (int bfldid, int occ, long l)
 
native void Bchg (int bfldid, int occ, byte c)
 
native void Bchg (int bfldid, int occ, float f)
 
native void Bchg (int bfldid, int occ, double d)
 
native void Bchg (int bfldid, int occ, String s)
 
native void Bchg (int bfldid, int occ, byte []b)
 
native boolean Bboolev (BExprTree tree)
 
native boolean Bqboolev (String expr)
 
native double Bfloatev (BExprTree tree)
 
native void Bdel (int bfldid, int occ)
 
native void Bdelall (int bfldid)
 
native boolean Bpres (int bfldid, int occ)
 
native void Bextread (BufferedReader reader)
 
native boolean Bisubf ()
 
native int Blen (int bfldid, int occ)
 
native BNextResult Bnext (boolean first)
 
native int Boccur (int bfldid)
 
native void Bread (byte[] data)
 
native byte [] Bwrite ()
 
native long Bsizeof ()
 
native long Bunused ()
 
native long Bused ()
 
native long Binit ()
 
native void Bproj (int bfldid[])
 
native void Bdelete (int [] bfldid)
 
native void Bconcat (TypedUbf src)
 
native void Bcpy (TypedUbf src)
 
native void Bprojcpy (TypedUbf src, int [] bfldida)
 
native void Bupdate (TypedUbf src)
 
native int Bcmp (TypedUbf ub2)
 
native boolean Bsubset (TypedUbf needle)
 
void marshal (Object o)
 
void marshal (Object o, int occ)
 
void unmarshal (Object o)
 
void unmarshal (Object o, int occ)
 
native void tpjsontoubf (String json)
 
native String tpubftojson ()
 
native void tplogprintubf (int lev, String title)
 
native int Bnum ()
 
native void Bjoin (TypedUbf src)
 
native void Bojoin (TypedUbf src)
 
- Public Member Functions inherited from org.endurox.TypedBuffer
native void tprealloc (long size)
 
 TypedBuffer (AtmiCtx ctx, boolean doFinalize, long cPtr, long len)
 
void setAtmiCtx (AtmiCtx ctx)
 
void cleanup ()
 
void setDoFinalize (boolean b)
 
native TpTypesResult tptypes ()
 

Additional Inherited Members

- Protected Member Functions inherited from org.endurox.TypedBuffer
void finalize () throws Throwable
 

Constructor & Destructor Documentation

◆ TypedUbf()

org.endurox.TypedUbf.TypedUbf ( AtmiCtx  ctx,
boolean  doFinalize,
long  cPtr,
long  len 
)

Initialize UBF Object

Parameters
ctx[in]ATMI Context allocated this method
doFinalize[in]Should
cPtr[in]C pointer to allocated block
len[in]Conditional buffer length

Member Function Documentation

◆ Bcmp()

native int org.endurox.TypedUbf.Bcmp ( TypedUbf  ub2)

Compare this UBF buffer with second UBF buffer passed in the argument. See Bcmp(3) manpage for more information.

Parameters
ub2UBF buffer to compare this with given buffer.
Returns
If buffer are equal, value 0 is returned. If this have lesser fields, field id is lesser than ub2 or value of field is lesser than ub2 then -1 is returned. In the same way if this buffer is greater ub2, then value 1 is returned.
Exceptions
UbfBEINVALExceptionthis buffer or ub2 are have NULL pointers wrapped in the objects - corrupted buffer.
UbfBNOTFLDExceptionthis buffer or ub2 buffers not fielded, not correctly allocated or corrupted - corrupted buffer.

◆ Bconcat()

native void org.endurox.TypedUbf.Bconcat ( TypedUbf  src)

Concatenate source buffer from src to this object buffer. Method will add any field from source buffer to destination buffer by using Badd(3) function call. See Bsizeof(3) manpage for more information.

Parameters
srcsource buffer to copy from.
Exceptions
UbfBALIGNERRExceptionSource or dest buffer corrupted or pointing to not aligned memory area.
UbfBNOTFLDExceptionSource or dest buffer not fielded, not correctly allocated or corrupted.
UbfBNOSPACEExceptionNo space left in target buffer.

◆ Bcpy()

native void org.endurox.TypedUbf.Bcpy ( TypedUbf  src)

Copy buffer from source (src) to this objects buffer. See Bcpy(3) manpage for more information.

Parameters
srcsource buffer copy data from
Exceptions
UbfBNOTFLDExceptionSource or dest buffer not fielded, not correctly allocated or corrupted.
UbfBNOSPACEExceptionNo space left in target buffer.

◆ Bdelete()

native void org.endurox.TypedUbf.Bdelete ( int []  bfldid)

Delete list of fields from UBF buffer For more information see Bdelete(3) manpage.

Parameters
bfldidarray of fields which needs to be deleted. Note that as Java have array length information, no BBADFLDID is required at the end of the array.
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.

◆ Bextread()

native void org.endurox.TypedUbf.Bextread ( BufferedReader  reader)

Restore UBF buffer from printed text buffer in the stream. For data format description see Bextread(3) manpage. Basically format is: <FIELDNAME>


Parameters
readerinput stream interface. The stream will be read line by line UbfBALIGNERRException Corrupted buffer or pointing to not aligned memory area. UbfBNOTFLDException Buffer not fielded, not correctly allocated or corrupted. UbfBSYNTAXException Missing tab between field id or missing newline. UbfBBADNAMEException Field not found in field table.

◆ Binit()

native long org.endurox.TypedUbf.Binit ( )

Initialize UBF buffer to allocated size. This can be effectively used to reset the UBF buffer to initial state - erase all infos from the buffer.

Returns
returns the un-used/free space of the UBF buffer
Exceptions
UbfBNOTFLDExceptioninternal error, buffer NULL.
UbfBALIGNERRExceptionalign error (internal err).
UbfBNOSPACEExceptionbuffer too short. The sizeof(UBF_header_t) is minimum size of buffer.

◆ Bisubf()

native boolean org.endurox.TypedUbf.Bisubf ( )

Test UBF buffer to see does underlying memory corresponds to the UBF format. For more information see Bisubf(3) manpage.

Returns
true - buffer is UBF, false - buffer is not UBF

◆ Bjoin()

native void org.endurox.TypedUbf.Bjoin ( TypedUbf  src)

Join UBF buffer. This object is destination. Leave in this object only matching field IDs and occurrences. Matched fields are updated from source buffer. Non matched fields are removed from UBF buffer.

Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. src is NULL.
UbfFBADFLDExceptionInvalid field type.
Parameters
src[in]source buffer

◆ Blen()

native int org.endurox.TypedUbf.Blen ( int  bfldid,
int  occ 
)

Return field length in bytes (used bytes). For strings including EOS.

Parameters
bfldidcompiled field id generated by mkfldhdr(8).
occfield occurrence
Returns
occupied bytes
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. p_ub is NULL.
UbfBBADFLDExceptionInvalid field id passed.
UbfBNOTPRESExceptionField not present.

◆ Bnext()

native BNextResult org.endurox.TypedUbf.Bnext ( boolean  first)

Iterate over the UBF buffer fields. This method returns all field ids and their corresponding occurrences in the buffer. see Bnext(3) manpage for more information.

Parameters
firstRestart the iteration.
Returns
Iteration result
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDBuffer not fielded, not correctly allocated or corrupted.
UbfBNOSPACENo space in buf.

◆ Bnum()

native int org.endurox.TypedUbf.Bnum ( )

Return number of fields in UBF buffer

Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. p_ub is NULL.
UbfFBADFLDExceptionInvalid field type.
Returns
number of UBF buffer fields

◆ Boccur()

native int org.endurox.TypedUbf.Boccur ( int  bfldid)

Get number of field occurrences in UBF buffer see Boccur(3) manpage for more information.

Parameters
bfldidcompiled field id
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. Or C buffer ptr is NULL.
UbfFBADFLDExceptionInvalid field type.

◆ Bojoin()

native void org.endurox.TypedUbf.Bojoin ( TypedUbf  src)

Outer join UBF buffer. This object is destination. Method updates matched fields/occurrences in this buffer. The non matched fields are left un-touched. Non matched fields from src is not added to this buffer.

Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. src is NULL.
UbfFBADFLDExceptionInvalid field type.
Parameters
src[in]source buffer

◆ Bpres()

native boolean org.endurox.TypedUbf.Bpres ( int  bfldid,
int  occ 
)

Test for field presence in UBF buffer. For more information see Bpres(3) manpage.

Parameters
bfldidcompiled UBF buffer id
occfield occurrence (0 based).
Returns
true - field present, false - field not present or error occurred

◆ Bprint()

native void org.endurox.TypedUbf.Bprint ( )

Print the UBF buffer to STDOUT

Exceptions
AtmiBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
AtmiBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.

◆ Bproj()

native void org.endurox.TypedUbf.Bproj ( int  bfldid[])

This method removes any un-needed field from UBF buffer and keeps only the list of field identifiers found in bfldlist array. As Java keeps the array length internally, the array shall not be terminated with BBADFLDID as in case for C. see Boccur(3) manpage for more information.

Parameters
bfldidarray of
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.

◆ Bprojcpy()

native void org.endurox.TypedUbf.Bprojcpy ( TypedUbf  src,
int []  bfldida 
)

Copy a list from src buffer fields to this buffer. This list of fields is marked in bfldid argument. This list shall not be terminated with BBADFLDID as for Java arrays are self describing. See Bprojcpy(3) manpage for more information.

Parameters
srcsource UBF buffer to copy fields from
bfldidalist of fields to copy to this buffer/object
Exceptions
UbfBALIGNERRExceptionSource or dest buffer corrupted or pointing to not aligned memory area.
UbfBNOTFLDExceptionSource or dest buffer not fielded, not correctly allocated or corrupted.
UbfBNOSPACEExceptionNo space left in target buffer.

◆ Bread()

native void org.endurox.TypedUbf.Bread ( byte []  data)

Read the UBF buffer from input stream. This read binary/platform specific version of the UBF buffer, produced either by memory dump or by Bwrite() method. see Bread(3) manpage for more information.

Parameters
databyte array containing the buffer image
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.
UbfBEINVALExceptioninternal error (invalid read function)
UbfBEUNIXExceptionFailed to read from stream.

◆ Bsizeof()

native long org.endurox.TypedUbf.Bsizeof ( )

Return buffer size in bytes, this includes the header data too. See Bsizeof(3) manpage for more information.

Returns
bufer size in bytes
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. p_ub is NULL.

◆ Bsubset()

native boolean org.endurox.TypedUbf.Bsubset ( TypedUbf  needle)

Test that UBF buffer 2 (present in needle) is part of the this UBF buffer.

Parameters
needleto search in this buffer
Returns
true - the needle is part of the this buffer, false - needle is not part of this UBF buffer.
Exceptions
UbfBEINVALExceptionthis buffer or needle are NULL pointers - corrupted UBF buffer.
UbfBNOTFLDExceptionthis buffer or needle buffers not fielded, not correctly allocated or corrupted - corrupted buffers.

◆ Bunused()

native long org.endurox.TypedUbf.Bunused ( )

Return free space of the UBF buffer. The number is given in bytes. See Bunused(3) manpage for more information.

Returns
free bytes in UBF buffer
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.

◆ Bupdate()

native void org.endurox.TypedUbf.Bupdate ( TypedUbf  src)

Update this object from source buffer. Any matching field occurrences are replaced or added from src buffer to this buffer. See Bupdate(3) manpage for more information.

Parameters
srcsource buffer to take data from
Exceptions
UbfBALIGNERRExceptionSource or dest buffer corrupted or pointing to not aligned memory area.
UbfBNOTFLDExceptionSource or dest buffer not fielded, not correctly allocated or corrupted.
UbfBNOSPACEExceptionNo space left in target buffer.

◆ Bused()

native long org.endurox.TypedUbf.Bused ( )

Return number of bytes used by UBF buffer. See Bused(3) manpage for more information.

Returns
number of used bytes of UBF buffer, this includes header too.
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted. Internal ptr is NULL.

◆ Bwrite()

native byte [] org.endurox.TypedUbf.Bwrite ( )

Write the buffer to byte array. The produced result is platform specific version of buffer dump. For cross platform dump, use either Bfprint() or Bprint(). See Bwrite(3) manpage for more information.

Returns
buffer dump
Exceptions
UbfBALIGNERRExceptionCorrupted buffer or pointing to not aligned memory area.
UbfBNOTFLDExceptionBuffer not fielded, not correctly allocated or corrupted.
UbfBEINVALExceptionInternal error.
UbfBEUNIXExceptionFailed to read from stream.
UbfBNOSPACEExceptionNo space in UBF buffer.

◆ marshal() [1/2]

void org.endurox.TypedUbf.marshal ( Object  o)

Copy object fields to UBF (serialize)

Parameters
oobject which shall be copied to this UBF
Exceptions
UbfBEUNIXExceptioncannot get field value from object, access problem, either got: IllegalAccessException/IllegalArgumentException/ InvocationTargetException or IntrospectionException exception
UbfBNOTPRESExceptiontwo few object array elements ("objmin" not reached).
UbfBSYNTAXExceptionInvalid mapped field type. Enduro/X for Java supports only following data types: short,Short,long,Long,byte,Byte,float, Float,double,Double,String,byte[].
UbfBALIGNERRExceptionInvalid Buffer
UbfBNOTFLDExceptionInvalid Buffer
UbfBNOSPACEExceptionNo space in buffer
UbfBBADFLDExceptionNo space in buffer

◆ marshal() [2/2]

void org.endurox.TypedUbf.marshal ( Object  o,
int  occ 
)

Copy object fields to UBF (serialize)

Parameters
oobject which shall be copied to this UBF
occoccurrence to serialize
Exceptions
UbfBEUNIXExceptioncannot get field value from object, access problem, either got: IllegalAccessException/IllegalArgumentException/ InvocationTargetException or IntrospectionException exception
UbfBNOTPRESExceptiontwo few object array elements ("objmin" not reached).
UbfBSYNTAXExceptionInvalid mapped field type. Enduro/X for Java supports only following data types: short,Short,long,Long,byte,Byte,float, Float,double,Double,String,byte[].
UbfBALIGNERRExceptionInvalid Buffer
UbfBNOTFLDExceptionInvalid Buffer
UbfBNOSPACEExceptionNo space in buffer
UbfBBADFLDExceptionNo space in buffer

◆ tpjsontoubf()

native void org.endurox.TypedUbf.tpjsontoubf ( String  json)

Restore UBF buffer from JSON. it is assumed that there is enough space in UBF buffer to store all data. see tpjsontoubf(3) manpage for more information.

Exceptions
AtmiTPEINVALExceptionInvalid JSON or invalid base64 encoding,
AtmiTPESYSTEMExceptionUBF sub-system error, JSON sub-system error.
AtmiTPEOSExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info. In case of insufficient memory this error will be generated too.
Parameters
jsonJSON string

◆ tplogprintubf()

native void org.endurox.TypedUbf.tplogprintubf ( int  lev,
String  title 
)

Print UBF buffer to TPLOG

Parameters
[in]levlog level see AtmiConstants.LOG_...
[in]titleTitle of UBF buffer dump

◆ tpubftojson()

native String org.endurox.TypedUbf.tpubftojson ( )

Convert UBF buffer to JSON string see tpubftojson(3) manpage for more information.

Exceptions
AtmiTPESYSTEMExceptionSystem failure occurred during serving. See logs i.e. user log, or debugs for more info. Might be insufficient memory, JSON or UBF library failure.
AtmiTPEOSExceptionNot enough space in output buffer.
Returns
JSON string

◆ unmarshal() [1/2]

void org.endurox.TypedUbf.unmarshal ( Object  o)

Copy UBF fields to object (deserialize) This buffer is reset before filling in with data from o.

Parameters
oobject to which copy the UBF data
Exceptions
UbfBEUNIXException
UbfBNOTPRESException
UbfBSYNTAXExceptionError while accessing object o. Problem with setter methods. Got either exception: IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException.
UbfBALIGNERRExceptionInvalid UBF Buffer
UbfBNOTFLDExceptionInvalid UBF Buffer
UbfBNOSPACEExceptionNo space in buffer (temp buffer for read)
UbfBNOTPRESExceptionUBF buffer does not meet "ubfmin" annotation minimum fields.

◆ unmarshal() [2/2]

void org.endurox.TypedUbf.unmarshal ( Object  o,
int  occ 
)

Copy UBF fields to object(deserialize)

Parameters
oobject o which copy UBF data
occarray element occurrence to copy
Exceptions
UbfBEUNIXException
UbfBNOTPRESException
UbfBSYNTAXExceptionError while accessing object o. Problem with setter methods. Got either exception: IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException.
UbfBALIGNERRExceptionInvalid UBF Buffer
UbfBNOTFLDExceptionInvalid UBF Buffer
UbfBNOSPACEExceptionNo space in buffer (temp buffer for read)
UbfBNOTPRESExceptionUBF buffer does not meet "ubfmin" annotation minimum fields.