public class BytesEvent extends com.streamscape.sdo.event.AbstractMutableEvent implements EventDatagram
Title: Structured Data Objects: Bytes Event
Description: An object that represents a Bytes Event.
byte array
as it's payload and includes a number of methods
that are specific to byte arrays.
A Bytes Event
has the following limitations:
Semantic Type
.Copyright: Copyright (c) 2011
Company: StreamScape Technologies
SEMANTIC_TYPE_NAME
DEFAULT_SERIAL_VERSION_ID
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(java.lang.String propertyName,
java.lang.String sdrPath)
Annotates (exports the value) of a specified data field in the class denoted by the
Semantic Type . |
void |
clearData()
Clears this event data.
|
BytesEvent |
clone()
Clones the event.
|
boolean |
equals(java.lang.Object other) |
byte[] |
getBytes()
Returns the content of the event.
|
long |
getBytesLength()
Returns a length of the byte array stored in this event.
|
boolean |
readBoolean()
Reads a boolean value from this event stream.
|
byte |
readByte()
Reads a byte value from this event stream.
|
int |
readBytes(byte[] value)
Reads the byte array from the event stream and returns the number of read bytes.
|
int |
readBytes(byte[] value,
int length)
Reads the byte array from the bytes event stream, but not more than
length bytes. |
char |
readChar()
Reads a char value from this event stream.
|
double |
readDouble()
Reads a double value from this event stream.
|
float |
readFloat()
Reads a float value from this event stream.
|
int |
readInt()
Reads an integer value from this event stream.
|
long |
readLong()
Reads a long value from this event stream.
|
short |
readShort()
Reads a short value from this event stream.
|
int |
readUnsignedByte()
Reads an unsigned byte value from this event stream.
|
int |
readUnsignedShort()
Reads an unsigned short value from this event stream.
|
java.lang.String |
readUTF()
Reads a string that has been encoded using a modified UTF-8 format from this event stream.
|
void |
resetData()
Puts the event data in read-only mode and resets its stream.
|
void |
setBytes(byte[] data)
Sets the specified byte array as a content of event.
|
void |
writeBoolean(boolean value)
Writes the boolean value to this event stream.
|
void |
writeByte(byte value)
Writes the byte value to this event stream.
|
void |
writeBytes(byte[] value)
Writes the byte array to this event stream.
|
void |
writeBytes(byte[] value,
int offset,
int length)
Writes the
length bytes from the specified array starting
from offset byte to this event stream. |
void |
writeChar(char value)
Writes the char value to this event stream.
|
void |
writeDouble(double value)
Writes the double value to this event stream.
|
void |
writeFloat(float value)
Writes the float value to this event stream.
|
void |
writeInt(int value)
Writes the integer value to this event stream.
|
void |
writeLong(long value)
Writes the long value to this event stream.
|
void |
writeObject(java.lang.Object value)
Writes the specified value to this event stream.
|
void |
writeShort(short value)
Writes the short value to this event stream.
|
void |
writeUTF(java.lang.String value)
Writes the string to this event stream using modified UTF-8 encoding in a machine-independent manner.
|
clearEventProperties, protect, removeAnnotation, removeEventProperty, resetReplyTo, setCorrelationId, setCorrelationIdAsBytes, setDurable, setEventBigDecimalProperty, setEventBigDecimalProperty, setEventBooleanProperty, setEventByteProperty, setEventDoubleProperty, setEventExpiration, setEventFloatProperty, setEventGroupId, setEventIntProperty, setEventKey, setEventLongProperty, setEventObjectProperty, setEventShortProperty, setEventStringProperty, setFinal, setForwardTo, setReplyTo, setSecurityAssertionToken, setSecurityAssertionTokenAsBytes, unprotect
canConvertEventProperty, existsEventProperty, getAnnotatedProperties, getAnnotation, getCorrelationId, getCorrelationIdAsBytes, getDurable, getEventBigDecimalProperty, getEventBooleanProperty, getEventByteProperty, getEventDoubleProperty, getEventExpiration, getEventFloatProperty, getEventGroupId, getEventId, getEventIntProperty, getEventKey, getEventLongProperty, getEventObjectProperty, getEventPropertyNames, getEventPropertyType, getEventShortProperty, getEventSource, getEventStringProperty, getForwardTo, getPermissions, getReadAccess, getReplyTo, getSecurityAssertionToken, getSecurityAssertionTokenAsBytes, getTimestamp, getTransmitAccess, getWriteAccess, hasAnnotatedProperties, hasSuitableAnnotationType, isProtected
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canConvertEventProperty, clearEventProperties, existsEventProperty, getAnnotatedProperties, getAnnotation, getCorrelationId, getCorrelationIdAsBytes, getEventBigDecimalProperty, getEventBooleanProperty, getEventByteProperty, getEventDoubleProperty, getEventExpiration, getEventFloatProperty, getEventIntProperty, getEventLongProperty, getEventObjectProperty, getEventPropertyNames, getEventPropertyType, getEventShortProperty, getEventStringProperty, getForwardTo, getPermissions, getReadAccess, getReplyTo, getSecurityAssertionToken, getSecurityAssertionTokenAsBytes, getTransmitAccess, getWriteAccess, hasAnnotatedProperties, isProtected, protect, removeAnnotation, removeEventProperty, resetReplyTo, setCorrelationId, setCorrelationIdAsBytes, setDurable, setEventBigDecimalProperty, setEventBigDecimalProperty, setEventBooleanProperty, setEventByteProperty, setEventDoubleProperty, setEventExpiration, setEventFloatProperty, setEventGroupId, setEventIntProperty, setEventKey, setEventLongProperty, setEventObjectProperty, setEventShortProperty, setEventStringProperty, setFinal, setForwardTo, setReplyTo, setSecurityAssertionToken, setSecurityAssertionTokenAsBytes, unprotect
getDurable, getEventGroupId, getEventId, getEventKey, getEventSource, getTimestamp
getSerialVersionUID
public void setBytes(byte[] data) throws SecurityViolationException, SDOException
This method can be used to avoid copying a content from the event stream to the event data
in the resetData()
method.
data
- the byte array to be set.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing data to the event stream failed.public byte[] getBytes() throws SecurityViolationException
If the event is protected from write access or the event data is write-only (i.e. writing is in progress), this method returns a copy of the event data.
If the event is not protected from write access and the event data is read-only (i.e. reading is in progress) this method directly returns the event data, not a copy! So the subscriber should not change this data, because such a change can affect the initial event instance or other subscribers of this event in the current node.
SecurityViolationException
- if the event is protected from read access.public long getBytesLength() throws SecurityViolationException
SecurityViolationException
- if the event is protected from read access.public boolean readBoolean() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public byte readByte() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public int readUnsignedByte() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public short readShort() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public int readUnsignedShort() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public char readChar() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public int readInt() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public long readLong() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public float readFloat() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public double readDouble() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public java.lang.String readUTF() throws SecurityViolationException, SDOException
SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public int readBytes(byte[] value) throws SecurityViolationException, SDOException
value
is less than the number of
bytes remaining in the stream, the array will be filled.
value
, the bytes will be read into the array.value
, or -1
if there is no more data because the end of the stream has been reached.SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public int readBytes(byte[] value, int length) throws SecurityViolationException, SDOException
length
bytes.
See readBytes(byte[])
for further information.
length
must be less than or equal to value.length
.value
, or -1
if there is no more data because the end of the stream has been reached.SecurityViolationException
- if the event is protected from read access.SDOException
- if the event data is write-only or
if reading failed.public void writeBoolean(boolean value) throws SecurityViolationException, SDOException
value
- the boolean value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeByte(byte value) throws SecurityViolationException, SDOException
value
- the byte value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeShort(short value) throws SecurityViolationException, SDOException
value
- the short value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeChar(char value) throws SecurityViolationException, SDOException
value
- the char value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeInt(int value) throws SecurityViolationException, SDOException
value
- the integer value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeLong(long value) throws SecurityViolationException, SDOException
value
- the long value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeFloat(float value) throws SecurityViolationException, SDOException
value
- the float value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeDouble(double value) throws SecurityViolationException, SDOException
value
- the double value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeUTF(java.lang.String value) throws SecurityViolationException, SDOException
value
- the unicode string to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeBytes(byte[] value) throws SecurityViolationException, SDOException
value
- the byte array to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeBytes(byte[] value, int offset, int length) throws SecurityViolationException, SDOException
length
bytes from the specified array starting
from offset
byte to this event stream.value
- the byte array to be written to the stream.offset
- the index of the first byte in the specified array to be written.length
- the number of bytes to be written.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if writing failed.public void writeObject(java.lang.Object value) throws SecurityViolationException, SDOException
The value can be one of the following types:
value
- the value to be written to the stream.SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.SDOException
- if the event data is read-only or
if the value type is wrong or
if writing failed.public void clearData() throws SecurityViolationException
SDORuntimeException
- if the event is coalesced (locked for editing).SecurityViolationException
- if the event is protected from write access.public void resetData() throws SecurityViolationException
Note that this method copies a content of the event stream to the event data.
To avoid creation of the data copy a user can use the method setBytes(byte[])
for data writing
instead of write...
methods.
SecurityViolationException
- if the event is protected from read access.public BytesEvent clone()
clone
in interface CloneableObject
clone
in interface ImmutableEventDatagram
clone
in class com.streamscape.sdo.IAbstractDataEvent
public void addAnnotation(java.lang.String propertyName, java.lang.String sdrPath) throws SecurityViolationException, SDOException
EventDatagram
Semantic Type
. In EventGram parlance an annotated datagram is an object
that contains additional information in it's header that refers (or is a subset of) the
datagram's payload. It is expected that the payload object referenced by Semantic Type
is part of the object's data structure prior to invocation of this method.
Annotated properties are populated with values derived from field elements of the data class.
The event source factory uses Java reflection to inspect the class and extract the specified
field elements prior to transmitting the event. This allows EventGrams to produce
secured content and still route and filter the datagrams by annotated content. The annotated
classes must be part of the Structured Data Object
definition.
If this event datagram has been created from a prototype (by method DatagramFactory.createEvent(String)
),
adding of new properties is not allowed. An exception will be thrown if the specified property does not exist.
Adding of new properties is allowed for uninitialized event datagram intended for a prototype creation
(such datagram can be created by methods like DatagramFactory.newEventInstance(String)
or
DatagramFactory.newEventInstanceFrom(String)
).
Event models supporting annotations are the following:
AuditEvent
//data
or //severity
.DataEvent
//data
or //data/<data_fields>
.
DeltaEvent
//beforeImage
or //beforeImage/<image_fields>
or
//afterImage
or //afterImage/<image_fields>
.
ExceptionEvent
//errorMessage
or //errorCode
or //severity
.
MapEvent
//map[<index>]
or //map[key='<key>']
or
//map[value='<value>']
.
String
value and
so the type of annotated property will always be String
.
RowArrayEvent
//row[<primary_key_value>]/<column_name>
or
//row[<primary_key_value>]/column[<column_index>]
.
<primary_key_value>;
is the value of the primary key column in the desired
row for annotation.
RowChangeEvent
//rowBefore/<column_name>
or //rowBefore/column[<column_index>]
or //rowAfter/<column_name>
or //rowAfter/column[<column_index>]
.
RowEvent
//row/<column_name>
or //row/column[<column_index>]
.
RowSetEvent
//row[<row_index>]/<column_name>
or
//row[<row_index>]/column[<column_index>]
.
StreamStateEvent
//streamState
or //stateMessage
or //streamPosition
.
TextEvent
//data/text
.
XMLEvent
<test attr="val"> <inside>Test1</inside> <inside>Test2</inside> </test>An annotation with path
//test/inside[2]
makes an event property with String
value equal to Test2
.
//test
makes an event property with String
value equal to
<inside>Test1</inside><inside>Test2</inside>
.
XMPPEvent
//body
.
addAnnotation
in interface EventDatagram
addAnnotation
in class com.streamscape.sdo.event.AbstractMutableEvent
propertyName
- the name of the property to be added.sdrPath
- the path to the data field to be annotated.SecurityViolationException
- if the event is write-protected.SDOException
- if the event does not support annotation or
if the specified property does not exist and this event has been created from a prototype or
if some internal error occurs.public boolean equals(java.lang.Object other)
equals
in class com.streamscape.sdo.IAbstractDataEvent
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.