Package org.osjava.jardiff
Class StreamDiffHandler
- java.lang.Object
-
- org.osjava.jardiff.StreamDiffHandler
-
- All Implemented Interfaces:
DiffHandler
public class StreamDiffHandler extends java.lang.Object implements DiffHandler
A specific type of DiffHandler which uses an OutputStream to create an XML document describing the changes in the diff. This is needed for java 1.2 compatibility for the ant task.- Author:
- Antony Riley
-
-
Constructor Summary
Constructors Constructor Description StreamDiffHandler()Create a new StreamDiffHandler which writes to System.outStreamDiffHandler(java.io.OutputStream out)Create a new StreamDiffHandler with the specified OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAccessFlags(AbstractInfo info)Add attributes describing some access flags.protected voidaddMethodNodes(java.lang.String desc)Add the method nodes for the method descriptor.protected voidaddTypeNode(java.lang.String desc)Add a type node for the specified descriptor.protected voidaddTypeNode(org.objectweb.asm.Type type)Add a type node for the specified type.voidclassAdded(ClassInfo info)Write out the class info for an added class.voidclassChanged(ClassInfo oldInfo, ClassInfo newInfo)Write out info aboout a changed class.voidclassRemoved(ClassInfo info)Write out class info for a removed class.voidcontains(ClassInfo info)Add a contained class.voidendAdded()End the added section.voidendChanged()End the changed section.voidendClassChanged()End the changed section for an individual class.voidendDiff()End the diff.voidendNewContents()End the list of new contents.voidendOldContents()End the list of old contents.voidendRemoved()End the removed section.voidfieldAdded(FieldInfo info)Write out info about an added field.voidfieldChanged(FieldInfo oldInfo, FieldInfo newInfo)Write out info aboout a changed field.voidfieldRemoved(FieldInfo info)Write out info about a removed field.voidmethodAdded(MethodInfo info)Write out info about a added method.voidmethodChanged(MethodInfo oldInfo, MethodInfo newInfo)Write out info aboout a changed method.voidmethodRemoved(MethodInfo info)Write out info about a removed method.voidstartAdded()Start the added section.voidstartChanged()Start the changed section.voidstartClassChanged(java.lang.String internalName)Start a changed section for an individual class.voidstartDiff(java.lang.String oldJar, java.lang.String newJar)Start the diff.voidstartNewContents()Start the list of old contents.voidstartOldContents()Start the list of old contents.voidstartRemoved()Start the removed node.protected voidwriteClassInfo(ClassInfo info)Write out information about a class.protected voidwriteFieldInfo(FieldInfo info)Write out information about a field.protected voidwriteMethodInfo(MethodInfo info)Write out information about a method.private java.lang.StringxmlEscape(java.lang.String str)Escape some text into a format suitable for output as xml.
-
-
-
Field Detail
-
XML_URI
public static final java.lang.String XML_URI
The XML namespace used.- See Also:
- Constant Field Values
-
out
private final java.io.BufferedWriter out
The javax.xml.transform.sax.Transformer used to convert the DOM to text.
-
-
Constructor Detail
-
StreamDiffHandler
public StreamDiffHandler() throws DiffExceptionCreate a new StreamDiffHandler which writes to System.out- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
StreamDiffHandler
public StreamDiffHandler(java.io.OutputStream out) throws DiffExceptionCreate a new StreamDiffHandler with the specified OutputStream.- Parameters:
out- Where to write output.- Throws:
DiffException
-
-
Method Detail
-
startDiff
public void startDiff(java.lang.String oldJar, java.lang.String newJar) throws DiffExceptionStart the diff. This writes out the start of a <diff> node.- Specified by:
startDiffin interfaceDiffHandler- Parameters:
oldJar- name of old jar file.newJar- name of new jar file.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startOldContents
public void startOldContents() throws DiffExceptionStart the list of old contents.- Specified by:
startOldContentsin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startNewContents
public void startNewContents() throws DiffExceptionStart the list of old contents.- Specified by:
startNewContentsin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
contains
public void contains(ClassInfo info) throws DiffException
Add a contained class.- Specified by:
containsin interfaceDiffHandler- Parameters:
info- information about a class- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endOldContents
public void endOldContents() throws DiffExceptionEnd the list of old contents.- Specified by:
endOldContentsin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endNewContents
public void endNewContents() throws DiffExceptionEnd the list of new contents.- Specified by:
endNewContentsin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startRemoved
public void startRemoved() throws DiffExceptionStart the removed node. This writes out a <removed> node.- Specified by:
startRemovedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
classRemoved
public void classRemoved(ClassInfo info) throws DiffException
Write out class info for a removed class. This writes out the nodes describing a class- Specified by:
classRemovedin interfaceDiffHandler- Parameters:
info- The info to write out.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endRemoved
public void endRemoved() throws DiffExceptionEnd the removed section. This closes the <removed> tag.- Specified by:
endRemovedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startAdded
public void startAdded() throws DiffExceptionStart the added section. This opens the <added> tag.- Specified by:
startAddedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
classAdded
public void classAdded(ClassInfo info) throws DiffException
Write out the class info for an added class. This writes out the nodes describing an added class.- Specified by:
classAddedin interfaceDiffHandler- Parameters:
info- The class info describing the added class.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endAdded
public void endAdded() throws DiffExceptionEnd the added section. This closes the <added> tag.- Specified by:
endAddedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startChanged
public void startChanged() throws DiffExceptionStart the changed section. This writes out the <changed> node.- Specified by:
startChangedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startClassChanged
public void startClassChanged(java.lang.String internalName) throws DiffExceptionStart a changed section for an individual class. This writes out an <classchanged> node with the real class name as the name attribute.- Specified by:
startClassChangedin interfaceDiffHandler- Parameters:
internalName- the internal name of the class that has changed.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
fieldRemoved
public void fieldRemoved(FieldInfo info) throws DiffException
Write out info about a removed field. This just writes out the field info, it will be inside a start/end removed section.- Specified by:
fieldRemovedin interfaceDiffHandler- Parameters:
info- Info about the field that's been removed.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
methodRemoved
public void methodRemoved(MethodInfo info) throws DiffException
Write out info about a removed method. This just writes out the method info, it will be inside a start/end removed section.- Specified by:
methodRemovedin interfaceDiffHandler- Parameters:
info- Info about the method that's been removed.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
fieldAdded
public void fieldAdded(FieldInfo info) throws DiffException
Write out info about an added field. This just writes out the field info, it will be inside a start/end added section.- Specified by:
fieldAddedin interfaceDiffHandler- Parameters:
info- Info about the added field.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
methodAdded
public void methodAdded(MethodInfo info) throws DiffException
Write out info about a added method. This just writes out the method info, it will be inside a start/end added section.- Specified by:
methodAddedin interfaceDiffHandler- Parameters:
info- Info about the added method.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
classChanged
public void classChanged(ClassInfo oldInfo, ClassInfo newInfo) throws DiffException
Write out info aboout a changed class. This writes out a <classchange> node, followed by a <from> node, with the old information about the class followed by a <to> node with the new information about the class.- Specified by:
classChangedin interfaceDiffHandler- Parameters:
oldInfo- Info about the old class.newInfo- Info about the new class.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
fieldChanged
public void fieldChanged(FieldInfo oldInfo, FieldInfo newInfo) throws DiffException
Write out info aboout a changed field. This writes out a <fieldchange> node, followed by a <from> node, with the old information about the field followed by a <to> node with the new information about the field.- Specified by:
fieldChangedin interfaceDiffHandler- Parameters:
oldInfo- Info about the old field.newInfo- Info about the new field.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
methodChanged
public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo) throws DiffException
Write out info aboout a changed method. This writes out a <methodchange> node, followed by a <from> node, with the old information about the method followed by a <to> node with the new information about the method.- Specified by:
methodChangedin interfaceDiffHandler- Parameters:
oldInfo- Info about the old method.newInfo- Info about the new method.- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endClassChanged
public void endClassChanged() throws DiffExceptionEnd the changed section for an individual class. This closes the <classchanged> node.- Specified by:
endClassChangedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endChanged
public void endChanged() throws DiffExceptionEnd the changed section. This closes the <changed> node.- Specified by:
endChangedin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endDiff
public void endDiff() throws DiffExceptionEnd the diff. This closes the <diff> node.- Specified by:
endDiffin interfaceDiffHandler- Throws:
DiffException- when there is an underlying exception, e.g. writing to a file caused an IOException
-
writeClassInfo
protected void writeClassInfo(ClassInfo info) throws java.io.IOException
Write out information about a class. This writes out a <class> node, which contains information about what interfaces are implemented each in a <implements> node.- Parameters:
info- Info about the class to write out.- Throws:
java.io.IOException- when there is an underlying IOException.
-
writeMethodInfo
protected void writeMethodInfo(MethodInfo info) throws java.io.IOException
Write out information about a method. This writes out a <method> node which contains information about the arguments, the return type, and the exceptions thrown by the method.- Parameters:
info- Info about the method.- Throws:
java.io.IOException- when there is an underlying IOException.
-
writeFieldInfo
protected void writeFieldInfo(FieldInfo info) throws java.io.IOException
Write out information about a field. This writes out a <field> node with attributes describing the field.- Parameters:
info- Info about the field.- Throws:
java.io.IOException- when there is an underlying IOException.
-
addAccessFlags
protected void addAccessFlags(AbstractInfo info) throws java.io.IOException
Add attributes describing some access flags. This adds the attributes to the attr field.- Parameters:
info- Info describing the access flags.- Throws:
java.io.IOException- when there is an underlying IOException.
-
addMethodNodes
protected void addMethodNodes(java.lang.String desc) throws java.io.IOExceptionAdd the method nodes for the method descriptor. This writes out an <arguments> node containing the argument types for the method, followed by a <return> node containing the return type.- Parameters:
desc- The descriptor for the method to write out.- Throws:
java.io.IOException- when there is an underlying IOException.
-
addTypeNode
protected void addTypeNode(java.lang.String desc) throws java.io.IOExceptionAdd a type node for the specified descriptor.- Parameters:
desc- A type descriptor.- Throws:
java.io.IOException- when there is an underlying IOException.
-
addTypeNode
protected void addTypeNode(org.objectweb.asm.Type type) throws java.io.IOExceptionAdd a type node for the specified type. This writes out a <type> node with attributes describing the type.- Parameters:
type- The type to describe.- Throws:
java.io.IOException- when there is an underlying IOException.
-
xmlEscape
private final java.lang.String xmlEscape(java.lang.String str)
Escape some text into a format suitable for output as xml.- Parameters:
str- the text to format- Returns:
- the formatted text
-
-