Package com.topologi.diffx.event.impl
Class XMLBranchEvent
java.lang.Object
com.topologi.diffx.event.impl.DiffXEventBase
com.topologi.diffx.event.impl.XMLBranchEvent
- All Implemented Interfaces:
DiffXEvent,XMLFormattable,XMLWritable
A branch of XML data.
A branch of XML data must start and end with the same element.
Implementation note: this class wraps an array of DiffX events and does not give access to this array, so it can be considered immutable.
- Version:
- 27 March 2010
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DiffXEvent[]The array of Diff-X events that make up the branch.private final intPre-calculated hashcode to speed up equal comparison.Fields inherited from class com.topologi.diffx.event.impl.DiffXEventBase
ESC, weight -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanequals(DiffXEvent e) Returnstrueif the diffX events in the branch are all equal.inthashCode()private static inttoHashCode(DiffXEvent[] events) Calculates the hashcode for this event.voidWrite the DiffX events in order.toXML(StringBuffer xml) Appends the XML representation of the object of the implementing class.Methods inherited from class com.topologi.diffx.event.impl.DiffXEventBase
equals, getWeight, setWeight, toXMLMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.topologi.diffx.event.DiffXEvent
getWeight, setWeightMethods inherited from interface com.topologi.diffx.xml.XMLFormattable
toXML
-
Field Details
-
branch
The array of Diff-X events that make up the branch. -
hashCode
private final int hashCodePre-calculated hashcode to speed up equal comparison.
-
-
Constructor Details
-
XMLBranchEvent
Creates a new XML branch.- Parameters:
events- The array of events that make up the branch.
-
-
Method Details
-
hashCode
public int hashCode()Description copied from class:DiffXEventBase- Specified by:
hashCodein classDiffXEventBase
-
equals
Returnstrueif the diffX events in the branch are all equal. Indicates whether the specified event is equal to this event.- Specified by:
equalsin interfaceDiffXEvent- Specified by:
equalsin classDiffXEventBase- Parameters:
e- The event to compare it with thsi one.- Returns:
trueif considered equals;falseotherwise.
-
toXML
Write the DiffX events in order. Writes the XML representation of the implementing instance using the specifiedXMLWriter.- Specified by:
toXMLin interfaceXMLWritable- Parameters:
xml- The XMLWriter to use.- Throws:
IOException- IF an I/O exception occurs whilst writing.
-
toXML
Description copied from interface:XMLFormattableAppends the XML representation of the object of the implementing class.Implementations must ensure that the returned string buffer is the same object as the specified string buffer.
- Specified by:
toXMLin interfaceXMLFormattable- Parameters:
xml- The string buffer to which the XML representation is appended to.- Returns:
- The modified string buffer.
- Throws:
NullPointerException- if the specified character sequence isnull.
-
toHashCode
Calculates the hashcode for this event.- Parameters:
events- Events to calculate the value from.- Returns:
- a number suitable as a hashcode.
-