public final class LogEntryXML extends java.lang.Object implements ILogEntry
Note on reuse of equal Strings, Integers etc:
The XML parser currently produces separate instances of the same Strings,
so that a lot of memory would be used up unnecessarily.
This class reuses String objects for its field values,
but does not exchange the String instances that are referenced by the log Node.
That current design will only yield a memory advantage if the LogEntryXML
instance is not kept permanently in the application, but instead its fields are read
and the values transfered (without the DOM Node) to an object of another class.
Ale: please check if there are other Srings that could be reused based on stringPool,
and if we should use also a pool for Integers, at least for log levels since they are always the same few.
ILogEntry.AdditionalData| Modifier and Type | Field and Description |
|---|---|
VectorNodeList |
complexLogEntryMessage |
DATA_ELEMENT_TAG_NAME, HEADER_ELEMENT_TAG_NAME, LOG_ELEMENT_TAG_NAME, NAME_ATTRIBUTE_NAME| Constructor and Description |
|---|
LogEntryXML(org.w3c.dom.Node log)
This constructor is called by the DOMParser.
|
LogEntryXML(java.util.Random random)
This costructor is used only for testing purposes.
|
LogEntryXML(java.lang.String stackId,
int stackLevel) |
| Modifier and Type | Method and Description |
|---|---|
void |
addData(java.lang.String name,
java.lang.String value)
Add a data node to this log:
value
|
static LogEntryXML |
generateRandomLog(java.util.Random random) |
java.util.Vector<ILogEntry.AdditionalData> |
getAdditionalData()
The vector return contains only strings and it is formed
in this way:
name value name value name value...
|
org.w3c.dom.NodeList |
getDatas()
Data Nodes are returned as a org.w3c.dom.NodeList.
|
java.lang.String |
getEntryTypeAsString()
Returns the type of this Object as String.
|
java.lang.Object |
getField(LogField f)
Returns a specific field according to field name constants.
|
org.w3c.dom.Node |
getNode() |
LogTypeHelper |
getType() |
boolean |
hasDatas()
Check if the log entry has datas
|
boolean |
isLogEntryMessageSimple()
This boolean tag specifies whether LogEntryMessage is simple or not:
logEntryMessageSimple = true: Log message is a single String. |
static boolean |
isValidLogEntryType(int index)
Insert the method's description here.
|
static void |
printNode(org.w3c.dom.Node logNode,
int depth)
Recursively prints the struct of the node
|
protected void |
setField(LogField field,
java.lang.Object value)
Sets the specified field.
|
java.lang.String |
toString()
Returns a String representation of the log.
|
java.lang.String |
toXMLString()
Return the object as XML string
|
public VectorNodeList complexLogEntryMessage
public LogEntryXML(java.lang.String stackId,
int stackLevel)
throws org.w3c.dom.DOMException
org.w3c.dom.DOMExceptionpublic LogEntryXML(java.util.Random random)
public LogEntryXML(org.w3c.dom.Node log)
throws org.w3c.dom.DOMException
log - org.w3c.Nodeorg.w3c.dom.DOMExceptionpublic static LogEntryXML generateRandomLog(java.util.Random random)
public boolean hasDatas()
public org.w3c.dom.NodeList getDatas()
public org.w3c.dom.Node getNode()
public java.lang.String getEntryTypeAsString()
public java.lang.Object getField(LogField f)
public LogTypeHelper getType()
public boolean isLogEntryMessageSimple()
logEntryMessageSimple = true: Log message is a single String. It is obtained via
String logEntry.simpleLogEntryMessage. Value is null if message is not present.logEntryMessageSimple = false: Log message is more complex, it is an XML
org.w3c.dom.NodeList. It is obtained via org.w3c.dom.NodeList logEntry.complexLogEntryMessage.
Value is null if message is simple.public static final boolean isValidLogEntryType(int index)
index - intprotected void setField(LogField field, java.lang.Object value)
field - The fieldvalue - java.lang.Object value to setpublic java.lang.String toString()
public static void printNode(org.w3c.dom.Node logNode,
int depth)
logNode - The node to printpublic java.lang.String toXMLString()
toXMLString in interface ILogEntrypublic java.util.Vector<ILogEntry.AdditionalData> getAdditionalData()
getAdditionalData in interface ILogEntry