Class DocViewFormat


  • public class DocViewFormat
    extends java.lang.Object
    This class provides access to the commonly used doc view xml format and functionality that checks files for the format or reformats them accordingly.
    • Constructor Summary

      Constructors 
      Constructor Description
      DocViewFormat()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean format​(java.io.File file, boolean dryRun)
      Formats a given file using the OutputFormat returned by getXmlOutputFormat().
      java.util.List<java.lang.String> format​(java.io.File directory, java.util.List<java.util.regex.Pattern> filenamePatterns, boolean dryRun)
      Formats given files using the OutputFormat returned by getXmlOutputFormat() by traversing the directory tree given as file.
      org.apache.jackrabbit.vault.util.xml.serialize.OutputFormat getXmlOutputFormat()
      Returns the OutputFormat used by DocViewSerializer when writing doc view xml files.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DocViewFormat

        public DocViewFormat()
    • Method Detail

      • getXmlOutputFormat

        public org.apache.jackrabbit.vault.util.xml.serialize.OutputFormat getXmlOutputFormat()
        Returns the OutputFormat used by DocViewSerializer when writing doc view xml files.
        Returns:
        the output format
      • format

        public boolean format​(java.io.File file,
                              boolean dryRun)
                       throws java.io.IOException
        Formats a given file using the OutputFormat returned by getXmlOutputFormat(). The file is replaced on disk but only if wasn't already formatted correctly and if dryRun is false.
        Parameters:
        file - the file to format
        dryRun - If true, then the file is never replaced on disk.
        Returns:
        true if the formatted version differs from the original.
        Throws:
        java.io.IOException - if an I/O error occurs
      • format

        public java.util.List<java.lang.String> format​(java.io.File directory,
                                                       java.util.List<java.util.regex.Pattern> filenamePatterns,
                                                       boolean dryRun)
                                                throws java.io.IOException
        Formats given files using the OutputFormat returned by getXmlOutputFormat() by traversing the directory tree given as file. Only those files will be formatted, that have a filename matching at least one of the given filenamePatterns, and only if dryRun is false.
        Parameters:
        directory - the start directory
        filenamePatterns - list of regexp patterns
        dryRun - If true, then the file is never replaced on disk.
        Returns:
        a list of relative paths of those files which are not formatted correctly according to format(File, boolean)
        Throws:
        java.io.IOException - in case there is an exception during traversal or formatting. That means formatting will fail on the first error that appeared