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 void
addAccessFlags(AbstractInfo info)
Add attributes describing some access flags.protected void
addMethodNodes(java.lang.String desc)
Add the method nodes for the method descriptor.protected void
addTypeNode(java.lang.String desc)
Add a type node for the specified descriptor.protected void
addTypeNode(org.objectweb.asm.Type type)
Add a type node for the specified type.void
classAdded(ClassInfo info)
Write out the class info for an added class.void
classChanged(ClassInfo oldInfo, ClassInfo newInfo)
Write out info aboout a changed class.void
classRemoved(ClassInfo info)
Write out class info for a removed class.void
contains(ClassInfo info)
Add a contained class.void
endAdded()
End the added section.void
endChanged()
End the changed section.void
endClassChanged()
End the changed section for an individual class.void
endDiff()
End the diff.void
endNewContents()
End the list of new contents.void
endOldContents()
End the list of old contents.void
endRemoved()
End the removed section.void
fieldAdded(FieldInfo info)
Write out info about an added field.void
fieldChanged(FieldInfo oldInfo, FieldInfo newInfo)
Write out info aboout a changed field.void
fieldRemoved(FieldInfo info)
Write out info about a removed field.void
methodAdded(MethodInfo info)
Write out info about a added method.void
methodChanged(MethodInfo oldInfo, MethodInfo newInfo)
Write out info aboout a changed method.void
methodRemoved(MethodInfo info)
Write out info about a removed method.void
startAdded()
Start the added section.void
startChanged()
Start the changed section.void
startClassChanged(java.lang.String internalName)
Start a changed section for an individual class.void
startDiff(java.lang.String oldJar, java.lang.String newJar)
Start the diff.void
startNewContents()
Start the list of old contents.void
startOldContents()
Start the list of old contents.void
startRemoved()
Start the removed node.protected void
writeClassInfo(ClassInfo info)
Write out information about a class.protected void
writeFieldInfo(FieldInfo info)
Write out information about a field.protected void
writeMethodInfo(MethodInfo info)
Write out information about a method.private java.lang.String
xmlEscape(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 DiffException
Create 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 DiffException
Create 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 DiffException
Start the diff. This writes out the start of a <diff> node.- Specified by:
startDiff
in 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 DiffException
Start the list of old contents.- Specified by:
startOldContents
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startNewContents
public void startNewContents() throws DiffException
Start the list of old contents.- Specified by:
startNewContents
in 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:
contains
in 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 DiffException
End the list of old contents.- Specified by:
endOldContents
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endNewContents
public void endNewContents() throws DiffException
End the list of new contents.- Specified by:
endNewContents
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startRemoved
public void startRemoved() throws DiffException
Start the removed node. This writes out a <removed> node.- Specified by:
startRemoved
in 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:
classRemoved
in 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 DiffException
End the removed section. This closes the <removed> tag.- Specified by:
endRemoved
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startAdded
public void startAdded() throws DiffException
Start the added section. This opens the <added> tag.- Specified by:
startAdded
in 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:
classAdded
in 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 DiffException
End the added section. This closes the <added> tag.- Specified by:
endAdded
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
startChanged
public void startChanged() throws DiffException
Start the changed section. This writes out the <changed> node.- Specified by:
startChanged
in 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 DiffException
Start a changed section for an individual class. This writes out an <classchanged> node with the real class name as the name attribute.- Specified by:
startClassChanged
in 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:
fieldRemoved
in 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:
methodRemoved
in 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:
fieldAdded
in 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:
methodAdded
in 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:
classChanged
in 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:
fieldChanged
in 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:
methodChanged
in 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 DiffException
End the changed section for an individual class. This closes the <classchanged> node.- Specified by:
endClassChanged
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endChanged
public void endChanged() throws DiffException
End the changed section. This closes the <changed> node.- Specified by:
endChanged
in interfaceDiffHandler
- Throws:
DiffException
- when there is an underlying exception, e.g. writing to a file caused an IOException
-
endDiff
public void endDiff() throws DiffException
End the diff. This closes the <diff> node.- Specified by:
endDiff
in 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.IOException
Add 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.IOException
Add 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.IOException
Add 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
-
-