Class XMLDecoder
java.lang.Object
org.apache.log4j.receivers.xml.XMLDecoder
- All Implemented Interfaces:
Decoder
Decodes Logging Events in XML formated into elements that are used by
Chainsaw.
This decoder can process a collection of log4j:event nodes ONLY
(no XML declaration nor eventSet node)
NOTE: Only a single LoggingEvent is returned from the decode method
even though the DTD supports multiple events nested in an eventSet.
NOTE: This class has been created on the assumption that all XML log files
are encoded in UTF-8. There is no current support for any other
encoding format at this time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MapAdditional properties.private static final StringDocument prolog.private DocumentBuilderDocument builder.private static final Stringprivate static final StringDocument close.private ComponentOwner.private StringPartial event.private static final StringRecord end. -
Constructor Summary
ConstructorsConstructorDescriptionCreate new instance.Create new instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.log4j.spi.LoggingEventConverts the string data into an XML Document, and then soaks out the relevant bits to form a new LoggingEvent instance which can be used by any Log4j element locally.Decodes a File into a Vector of LoggingEvents.decodeEvents(String document) Decodes a String representing a number of events into a Vector of LoggingEvents.private VectordecodeEvents(Document document) Given a Document, converts the XML into a Vector of LoggingEvents.private StringGet contents of CDATASection.private DocumentConverts the LoggingEvent data in XML string format into an actual XML Document class instance.voidsetAdditionalProperties(Map properties) Sets an additionalProperty map, where each Key/Value pair is automatically added to each LoggingEvent as it is decoded.
-
Field Details
-
ENCODING
- See Also:
-
BEGINPART
-
ENDPART
-
RECORD_END
-
docBuilder
Document builder. -
additionalProperties
Additional properties. -
partialEvent
Partial event. -
owner
Owner.
-
-
Constructor Details
-
XMLDecoder
-
XMLDecoder
public XMLDecoder()Create new instance.
-
-
Method Details
-
setAdditionalProperties
Sets an additionalProperty map, where each Key/Value pair is automatically added to each LoggingEvent as it is decoded. This is useful, say, to include the source file name of the Logging events- Specified by:
setAdditionalPropertiesin interfaceDecoder- Parameters:
properties- additional properties
-
parse
-
decode
Decodes a File into a Vector of LoggingEvents.- Specified by:
decodein interfaceDecoder- Parameters:
url- the url of a file containing events to decode- Returns:
- Vector of LoggingEvents
- Throws:
IOException- if IO error during processing.
-
decodeEvents
Decodes a String representing a number of events into a Vector of LoggingEvents.- Specified by:
decodeEventsin interfaceDecoder- Parameters:
document- to decode events from- Returns:
- Vector of LoggingEvents
-
decode
Converts the string data into an XML Document, and then soaks out the relevant bits to form a new LoggingEvent instance which can be used by any Log4j element locally. -
decodeEvents
-
getCData
-