Skip Headers

Oracle9i Supplied Java Packages Reference
Release 2 (9.2)

Part Number A96609-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

14
Package oracle.xml.differ

This chapter documents package oracle.xml.differ for XML Diff Bean. This package is part of the Oracle XDK for Java Beans.

This chapter contains these sections:


Package oracle.xml.differ Description

The classes contained in oracle.xml.differ implement the XML Diff Bean, which performs a comparison on two XML DOM trees using a graphical user interface. A node can be inserted, deleted, moved, or modified.

You can generate the differences between the two XML trees in the form of XSL code. The first XML file can be transformed into the second XML file by using the XSL code generated.


Package oracle.xml.differ class Summary

class java.lang.Object


class java.beans.SimpleBeanInfo (implements java.beans.BeanInfo) 
class oracle.xml.differ.XMLDiffBeanInfo
class oracle.xml.differ.XMLDiff (implements 
oracle.xml.async.DOMBuilderErrorListener, 
oracle.xml.async.DOMBuilderListener, java.io.Serializable)

Table 14-1  oracle.xml.differ classes
Class Description

XMLDiff Class

Defines an interface for comparing two XML documents.

XMLDiffBeanInfo Class

Extends java.beans.SimpleBeanInfo.


XMLDiff Class

Description

Public class XMLDiff

Extends java.lang.Object

Implements DOMBuilderListener, DOMBuilderErrorListener, java.io.Serializable

Defines an interface for comparing two XML files. It enables two XML files to be compared to check for their equivalence. It provides the objects to display the differences, if any, in a graphical format. The differences can also be represented as XSL. The corresponding XSL stylesheet with the differences can be generated as a file or an XMLDocument object. The first XML file can be transformed into the second XML file by using the XSL stylesheet generated.

java.lang.Object

|

+--oracle.xml.differ.XMLDiff


Constructors

XMLDiff

Syntax

public XMLDiff()


Methods

setFiles

Description

Sets the XML files which need to be compared. Both files are parsed into DOM trees for comparision. This is faster than calling setInput1() and setInput2()

Syntax

public void setFiles(java.io.File file1,
                     java.io.File file2)

Parameters

File - first XML file (separate File with comma for each increment)

File - second XML file

Throws

java.io.IOException - thrown when an I/O error occurs

XMLParseException - caused when parsing XML document

SAXException - caused when parsing XML document

java.lang.InterruptedException - if a sleeping thread is interrupted

setDocuments

Description

Sets the XML documents which need to be compared.

Syntax

public void setDocuments(XMLDocument doc1,
                         XMLDocument doc2)

Parameters

XMLDocument - first XML document

XMLDocument - second XML document

setInput1

Description

Sets the first XML file that needs to be compared. The input file is parsed into a DOM tree for comparision.

Syntax

public void setInput1(java.io.File file1)

Parameters

File - first XML file

Throws

java.io.IOException - thrown when an I/O error occurs

XMLParseException - caused when parsing XML document

SAXException - caused when parsing XML document

java.lang.InterruptedException - if a sleeping thread is interrupted

setInput2

Description

Sets the second XML file that needs to be compared. The input file is parsed into a DOM tree for comparision.

Syntax

public void setInput2(java.io.File file2)

Parameters

File - second XML file

Throws

java.io.IOException - thrown when an I/O error occurs

XMLParseException - caused when parsing XML document

SAXException - caused when parsing XML document

java.lang.InterruptedException - if a sleeping thread is interrupted

setInput1

Description

Sets the first XML document which need to be compared.

Syntax

public void setInput1(XMLDocument doc1)

Parameters

XMLDocument - first XML document

setInput2

Description

Sets the second XML document which need to be compared.

Syntax

public void setInput2(XMLDocument doc2)

Parameters

XML - Document second XML document

getDocument1

Description

Gets the document root as an XMLDocument object of the first XML tree

Syntax

public XMLDocument getDocument1()

Returns

the document root of the first XML file

getDocument2

public XMLDocument getDocument2()

Gets the document root as an XMLDocument object of the second XML tree

Returns:

the document root of the second XML file

diff

Description

Finds the differences between the two XML files or the two XMLDocument objects.

Syntax

public boolean diff()

Returns

false if the XML files or docs are same, true if they are different

Throws

java.lang.NullPointerException - occurs when xml files were not parsed successfully and this function was called. Or if xml documents have not been set.

getDiffPane1

Description

Gets the text panel as JTextPane object which visually shows the diffs in the first XML file.

Syntax

public javax.swing.JTextPane getDiffPane1()

Returns

visual text panel showing diffs in first XML file

getDiffPane2

Description

Gets the text panel as JTextPane object which visually shows the diffs in the second XML file or document

Syntax

public javax.swing.JTextPane getDiffPane2()

Returns

visual text panel showing diffs in second XML file

setIndentIncr

Description

Sets the indentation for the XSL generation. This should be called before the generateXSLFile() or generateXSLDoc(). The indentation will be applied to all attributes only. For indenting newly inserted nodes besides attributes see setNewNodeIndentIncr()

Syntax

public void setIndentIncr(int spaces)

Parameters

int - indentation increment in number of spaces for attributes

setNewNodeIndentIncr

Description

Sets the indentation for the XSL generation. This should be called before the generateXSLFile() or generateXSLDoc(). The indentation will be applied to all newly inserted nodes only (except attributes). For indentation attributes supported, see setIndentIncr().

Syntax

public void setNewNodeIndentIncr(int spaces)

Parameters

int - indentation increment in number of spaces for new nodes

generateXSLFile

Description

Generates an XSL file of input filename which represents the differences between the 2 XML files which were set initially. If the input filename is null a default XSL file named XMLDiff.xsl will be generated. The first XML file can be transformed into the second XML file using the XSL stylesheet generated. If the XML files were the same then the XSL generated will transform the first XML file into the second XML file, where the first and second files will equivalent.

Syntax

public void generateXSLFile(java.lang.String filename)

Parameters

String - output XSL file name

Throws

java.io.IOException - could occur if the xsl file was not created successfully

generateXSLDoc

Description

Generates an XSL stylesheet as an XMLDocument which represents the differences between the 2 XML documents set initially. The first XML file can be transformed into the second XML file using the XSL stylesheet generated. If the XML files were the same then the XSL generated will transform the first XML file into the second XML file, where the first and second files will equivalent.

Syntax

public XMLDocument generateXSLDoc()

Returns

XSL stylesheet as an XML document

Throws

java.io.IOException - could occur if the xsl file was not created successfully

java.io.FileNotFoundException - if xsl file generated could not be found

SAXException - caused when parsing xml document

XMLParseException - caused when parsing xml document

equals

Description

Method that performs the comparision of two (2) nodes. It is called by the differ algorithm. If needed, this function can be overwritten for customized comparisions.

Syntax

protected boolean equals(Node node1,
                         Node node2)

Parameters

Node - node1 first node to compare

Node - node2 second node to compare

domBuilderErrorCalled

Description

Method implementing the DOMBuilderErrorListener interface called only by the DOM parser when there is an error while parsing.

Syntax

public void domBuilderErrorCalled(DOMBuilderErrorEvent p0)

Specified By

domBuilderErrorCalled in interface DOMBuilderErrorListener

Parameters

DOMBuilderErrorEvent - error object thrown by parser

domBuilderError

Description

Method implementing the DOMBuilderErrorListener interface called only by the DOM parser.

Syntax

public void domBuilderError(DOMBuilderEvent p0)

Specified By

domBuilderError in interface DOMBuilderListener

Parameters

DOMBuilderEvent - parser event Parser errors handled by domBuilderErrorCalled

domBuilderOver

Description

Method implementing DOMBuilderListener interface called only by a DOM parser thread when the parsing is done.

Syntax

public void domBuilderOver(DOMBuilderEvent p0)

Specified By

domBuilderOver in interface DOMBuilderListener

Parameters

DOMBuilderEvent - parser event

domBuilderStarted

Description

Method implementing DOMBuilderListener interface called only by the DOM parser when the parsing starts.

Syntax

public void domBuilderStarted(DOMBuilderEvent p0)

Specified By

domBuilderStarted in interface DOMBuilderListener

Parameters

DOMBuilderEvent - parser event

printDiffTree

Description

Prints the diff tree which contains the node names and values which have been identified as diffs by the algorithm. Useful for debugging.

Syntax

public void printDiffTree(int tree,
                          java.io.BufferedWriter out)

Parameters

int - the tree to print, i.e. one or two

BufferedWriter - containing the printed diff tree

Throws

java.io.IOException - could occur if the xsl file was not created successfully

setNoMoves

Description

Assume that there are no moves to be detected by the diff algorithm. This function should be called before the diff() function. It will result in a performance gain.

Syntax

public void setNoMoves()

XMLDiffBeanInfo Class

Description

Public class XMLDiffBeanInfo

Extends java.beans.SimpleBeanInfo

java.lang.Object
  |
  +--java.beans.SimpleBeanInfo
        |
        +--oracle.xml.differ.XMLDiffBeanInfo

Constructor

XMLDiffBeanInfo

Syntax

public XMLDiffBeanInfo()


Methods

getPropertyDescriptors

Syntax

public java.beans.PropertyDescriptor[ ] getPropertyDescriptors()

Overrides

getPropertyDescriptors in class java.beans.SimpleBeanInfo

getIcon

Syntax

public java.awt.Image getIcon(int iconKind)

Overrides

getIcon in class java.beans.SimpleBeanInfo


Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback