Class Main

java.lang.Object
com.topologi.diffx.Main

public final class Main extends Object
Utility class to centralise the access to this API from the command line.
Version:
10 May 2010
  • Constructor Details

    • Main

      private Main()
      Prevents creation of instances.
  • Method Details

    • equivalent

      public static boolean equivalent(File xml1, File xml2) throws DiffXException, IOException
      Returns true if the two specified files are XML equivalent by looking at the sequence SAX events reported an XML reader.
      Parameters:
      xml1 - The first XML stream to compare.
      xml2 - The first XML stream to compare.
      Returns:
      true If the XML are considered equivalent; false otherwise.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • equivalent

      public static boolean equivalent(InputStream xml1, InputStream xml2) throws DiffXException, IOException
      Returns true if the two specified input streams are equivalent by looking at the sequence SAX events reported an XML reader.
      Parameters:
      xml1 - The first XML stream to compare.
      xml2 - The first XML stream to compare.
      Returns:
      true If the XML are considered equivalent; false otherwise.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • equivalent

      public static boolean equivalent(Reader xml1, Reader xml2) throws DiffXException, IOException
      Returns true if the two specified readers are equivalent by looking at the sequence SAX events reported an XML reader.
      Parameters:
      xml1 - The first XML stream to compare.
      xml2 - The first XML stream to compare.
      Returns:
      true If the XML are considered equivalent; false otherwise.
      Throws:
      DiffXException - If a DiffX exception is reported by the recorders.
      IOException - Should an I/O exception occur.
    • diff

      public static void diff(Node xml1, Node xml2, Writer out, DiffXConfig config) throws DiffXException, IOException
      Compares the two specified XML nodes and prints the diff onto the given writer.
      Parameters:
      xml1 - The first XML node to compare.
      xml2 - The second XML node to compare.
      out - Where the output goes.
      config - The DiffX configuration to use.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • diff

      public static void diff(NodeList xml1, NodeList xml2, Writer out, DiffXConfig config) throws DiffXException, IOException
      Compares the two specified NodeLists and prints the diff onto the given writer.

      Only the first node in the node list is sequenced.

      Parameters:
      xml1 - The first XML node list to compare.
      xml2 - The second XML node list to compare.
      out - Where the output goes.
      config - The DiffX configuration to use.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • diff

      public static void diff(Reader xml1, Reader xml2, Writer out, DiffXConfig config) throws DiffXException, IOException
      Compares the two specified xml files and prints the diff onto the given writer.
      Parameters:
      xml1 - The first XML reader to compare.
      xml2 - The first XML reader to compare.
      out - Where the output goes.
      config - The DiffX configuration to use.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • diff

      public static void diff(Reader xml1, Reader xml2, Writer out) throws DiffXException, IOException
      Compares the two specified xml files and prints the diff onto the given writer.
      Parameters:
      xml1 - The first XML reader to compare.
      xml2 - The first XML reader to compare.
      out - Where the output goes
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • diff

      public static void diff(InputStream xml1, InputStream xml2, OutputStream out) throws DiffXException, IOException
      Compares the two specified xml files and prints the diff onto the given writer.
      Parameters:
      xml1 - The first XML input stream to compare.
      xml2 - The first XML input stream to compare.
      out - Where the output goes
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • diff

      private static void diff(EventSequence seq1, EventSequence seq2, Writer out, DiffXConfig config) throws DiffXException, IOException
      Compares the two specified xml files and prints the diff onto the given writer.
      Parameters:
      seq1 - The first XML reader to compare.
      seq2 - The first XML reader to compare.
      out - Where the output goes.
      config - The DiffX configuration to use.
      Throws:
      DiffXException - Should a Diff-X exception occur.
      IOException - Should an I/O exception occur.
    • main

      public static void main(String[] args) throws Exception
      Main entry point from the command line.
      Parameters:
      args - The command-line arguments
      Throws:
      Exception - If anything wrong happens.
    • usage

      public static void usage()
      Displays the usage on the System.err console
    • getRecorder

      private static Recorder getRecorder(String[] args)
      Parameters:
      args - The command line arguments.
      Returns:
      The recorder to use.
    • getOutput

      private static OutputStream getOutput(String[] args) throws FileNotFoundException
      Parameters:
      args - The command line arguments.
      Returns:
      The output to use.
      Throws:
      FileNotFoundException - If the file does not exist.
    • getAlgorithm

      private static DiffXAlgorithm getAlgorithm(String[] args, EventSequence seq1, EventSequence seq2)
      Parameters:
      args - The command line arguments.
      seq1 - The first sequence.
      seq2 - The second sequence.
      Returns:
      The algorithm to use.
    • getFormatter

      private static DiffXFormatter getFormatter(String[] args, Writer out) throws IOException
      Parameters:
      args - The command line arguments.
      out - The writer to use.
      Returns:
      The formatter to use.
      Throws:
      IOException - Should and I/O error occur
    • getWhiteSpaceProcessing

      private static WhiteSpaceProcessing getWhiteSpaceProcessing(String[] args) throws IOException
      Parameters:
      args - The command line arguments.
      Returns:
      The formatter to use.
      Throws:
      IOException - Should and I/O error occur
    • getTextGranularity

      private static TextGranularity getTextGranularity(String[] args) throws IOException
      Parameters:
      args - The command line arguments.
      Returns:
      The formatter to use.
      Throws:
      IOException - Should and I/O error occur