|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.apama.iaf.plugin.NormalisedEvent
public class NormalisedEvent
Represents an Apama event in the normalised form used by the IAF Semantic
Mapper. The normalised event is simply a dictionary of name/value String pairs,
where all names are unique within the event, but values are not unique and
may be null
.
The class provides methods for constructing, manipulating and querying the
contents of the event, and is designed to be similar to the C interface in
'NormalisedEvent.h', but also implements the standard Java Map
and
Iterable
interfaces.
Java developers may find it simplest to use standard Map methods
such as put(String, String)
for adding fields to the normalised event,
get(Object)
for reading field values, and a standard Java
for
loop to iterate over all the name/value entries in the
normalised event.
Note that this class is NOT itself thread-safe.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
NormalisedEvent()
Constructs a new NormalisedEvent, initially empty. |
|
NormalisedEvent(java.util.Map<java.lang.String,java.lang.String> m)
Constructs a new NormalisedEvent, with the same name/value pairs as the specified Map. |
Method Summary | |
---|---|
NormalisedEventIterator |
add(java.lang.String key,
java.lang.String value)
Add a new name-value pair to the event. |
void |
addQuick(java.lang.String key,
java.lang.String value)
Add a new name-value pair to the event. |
void |
clear()
Removes all mappings from this map. |
boolean |
containsKey(java.lang.Object name)
Returns true if this map contains a mapping for the specified name. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more names to the specified value. |
boolean |
empty()
Check whether the event is empty or not. |
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entrySet()
|
boolean |
exists(java.lang.String key)
Check whether a given element exists in the normalised event. |
NormalisedEventIterator |
find(java.lang.String key)
Search for a named element in the normalised event. |
java.lang.String |
findValue(java.lang.String key)
Search for a named element in the normalised event and return its value. |
java.lang.String |
findValueAndRemove(java.lang.String key)
Search for a named element in the normalised event and return its value. |
java.lang.String |
findValueAndRemove2(java.lang.String key)
Search for a named element in the normalised event and return its value. |
NormalisedEventIterator |
first()
Return an iterator pointing to the first element of the normalised event. |
java.lang.String |
get(java.lang.Object key)
Returns the value to which the specified name is mapped, or null if the map contains no mapping for this key. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
iterator()
Returns a standard Java Iterator over the contents of the NormalisedEvent using Map.Entry objects. |
java.util.Set<java.lang.String> |
keySet()
|
NormalisedEventIterator |
last()
Return an iterator pointing to the last element of the normalised event. |
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Adds or replaces the specified (key,value) pair in the underlying map |
void |
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> m)
Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map. |
java.lang.String |
remove(java.lang.Object key)
Removes the mapping for this key from this map if present. |
void |
remove(java.lang.String key)
Remove the named element from the normalised event. |
void |
removeAll()
Remove all elements from the normalised event. |
void |
replace(java.lang.String key,
java.lang.String newValue)
Change the value of a named element in the normalised event. |
int |
size()
Get the number of elements (name-value pairs) currently stored by the event. |
java.lang.String |
toString()
Return a printable string representation of the normalised event. |
java.util.Collection<java.lang.String> |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Constructor Detail |
---|
public NormalisedEvent()
public NormalisedEvent(java.util.Map<java.lang.String,java.lang.String> m)
Method Detail |
---|
public int size()
size
in interface java.util.Map<java.lang.String,java.lang.String>
public boolean empty()
true
if the event has zero elements,
false
otherwisepublic NormalisedEventIterator add(java.lang.String key, java.lang.String value) throws NormalisedEventException
key
- The name of the new elementvalue
- the value of the new element
null
if the element was not added (because the
name already existed).
NormalisedEventException
- Thrown if key=null
public void addQuick(java.lang.String key, java.lang.String value) throws NormalisedEventException
This function is faster and more memory-efficient than add(), since it does not bother creating an iterator. However, you have no way of knowing whether the element was actually added or not, other than searching for the name and checking the stored value.
key
- The name of the new elementvalue
- The value of the new element
NormalisedEventException
- Thrown if key=null
public void remove(java.lang.String key)
key
- The name of the element to be removedpublic void replace(java.lang.String key, java.lang.String newValue) throws NormalisedEventException
key
- The name of the element to be updatednewValue
- The new value for the named element
NormalisedEventException
- Thrown if key=null
public void removeAll()
empty()
function will return true
after this function has been
called.
public boolean exists(java.lang.String key)
key
- The element name to search for
true
if an element with the given name exists in the
normalised event, false
otherwise.public NormalisedEventIterator find(java.lang.String key) throws NormalisedEventException
key
- The element name to search for
null
if no matching element could be found.
NormalisedEventException
- Thrown if the key cannot be founditerator()
public java.lang.String findValue(java.lang.String key)
key
- The element name to search for
null
if no matching element could be found. Note that this function cannot
distinguish between an element with a missing value and an element that
does not exist - null
will be returned in either case.public java.lang.String findValueAndRemove(java.lang.String key)
key
- The element name to search for
null
if
no matching element could be found. If the element was found, it will be
deleted from the event. Note that this function cannot distinguish
between an element with a missing value and an element that does not
exist - null
will be returned in either case.public java.lang.String findValueAndRemove2(java.lang.String key) throws NormalisedEventException
key
- The element name to search for
null
if no
matching element could be found. If the element was found, it will be
deleted from the event.
NormalisedEventException
- Thrown if the key did not existpublic NormalisedEventIterator first()
null
if the event has no elements.iterator()
public NormalisedEventIterator last()
null
if the event has no elements.iterator()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
Map.Entry
objects. If the map is modified while an iteration
over the set is in progress (except through the iterator's own
remove operation, or through the setValue operation on
a map entry returned by the iterator) the results of the iteration are
undefined.
Instead of calling this method directly, it may be easier to use the
following construction:
for (Map.Entry<String,String> element: normalisedEvent)
{ ... }
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
public java.lang.String put(java.lang.String key, java.lang.String value) throws NormalisedEventException
put
in interface java.util.Map<java.lang.String,java.lang.String>
key
- Any stringvalue
- Any string or null
null
), or null
if the key did not exist
NormalisedEventException
- If key=null
Map.put(Object, Object)
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.String>
Map.entrySet()
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,java.lang.String>
Map.keySet()
public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.String>
Map.clear()
public boolean containsKey(java.lang.Object name)
containsKey
in interface java.util.Map<java.lang.String,java.lang.String>
name
- The namewhose presence in this map is to be tested
Map.containsKey(Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,java.lang.String>
value
- value whose presence in this map is to be tested.
Map.containsValue(Object)
public java.lang.String get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,java.lang.String>
key
- the key whose associated value is to be returned.
Map.put(Object, Object)
,
Map.get(Object)
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,java.lang.String>
Map.isEmpty()
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> m)
putAll
in interface java.util.Map<java.lang.String,java.lang.String>
m
- mappings to be stored in this map.
java.lang.NullPointerException
- if the specified map is null.Map.putAll(Map)
public java.lang.String remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,java.lang.String>
key
- key whose mapping is to be removed from the map.
Map.remove(Object)
public java.util.Collection<java.lang.String> values()
values
in interface java.util.Map<java.lang.String,java.lang.String>
Map.values()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |