Package cbsw

Class Cbsw


  • public class Cbsw
    extends java.lang.Object

    A collection of miscellaneous methods

    • Constructor Summary

      Constructors 
      Constructor Description
      Cbsw()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.File chooseFile​(java.lang.String dir, javax.swing.filechooser.FileFilter filter)
      Launch a JFileChooser to choose a file
      static void exec​(java.lang.Class<?> cl, java.lang.String cmd)
      Calls a method using Java reflection.
      static org.w3c.dom.Document loadDocument​(java.lang.String xmlPath)
      Loads a (XML) org.w3c.dom.Document.
      static boolean print​(java.lang.String jobName, java.awt.print.Printable printable)
      Sets up a printer job.
      static void system​(java.lang.String[] cmd)
      Launches system command.
      static void transformDocument​(org.w3c.dom.Document doc, java.lang.String outPath, java.lang.String xslPath)
      Writes a backup of a (XML) org.w3c.dom.Document.
      static java.lang.Object unmarshal​(java.lang.String xml, java.lang.Class... classes)
      JAXB unmarshaller
      static void writeDocumentBackup​(org.w3c.dom.Document doc, java.lang.String xmlPath)
      Writes a backup of a (XML) org.w3c.dom.Document.
      • Methods inherited from class java.lang.Object

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

      • Cbsw

        public Cbsw()
    • Method Detail

      • unmarshal

        public static java.lang.Object unmarshal​(java.lang.String xml,
                                                 java.lang.Class... classes)

        JAXB unmarshaller

        Unmarshal classes from a repository. Unmarshalling creates objects and initialises members of a class instance structure from an XML file.

        The URL may point to a file on the web or a local file using the usual URL syntax. The file is cached in the current directory with prefix www- and is used automatically if the remote connection fails.

        To prevent overwriting a previously cached file, remove the www- prefix. The unmarshalling always first tries to use the file with no prefix.

        Parameters:
        xml - URL of XML data
        classes - The classes that provide the unmarshalling context
        Returns:
        The unmarshalled object
      • exec

        public static void exec​(java.lang.Class<?> cl,
                                java.lang.String cmd)

        Calls a method using Java reflection.

        Supports only the following method signatures:

        static void method() static void method(String) static void method(String,String)
        Parameters:
        cl - The class
        cmd - The method and parameters cmd[[|arg1[|arg2]]
      • chooseFile

        public static java.io.File chooseFile​(java.lang.String dir,
                                              javax.swing.filechooser.FileFilter filter)

        Launch a JFileChooser to choose a file

        Parameters:
        dir - The directory to navigate from
        filter - A file filter
        Returns:
        The File
      • print

        public static boolean print​(java.lang.String jobName,
                                    java.awt.print.Printable printable)

        Sets up a printer job.

        Parameters:
        jobName - The printer job name.
        printable - The object to print.
        Returns:
        true if the printer is monochrome false if colour.
      • writeDocumentBackup

        public static void writeDocumentBackup​(org.w3c.dom.Document doc,
                                               java.lang.String xmlPath)

        Writes a backup of a (XML) org.w3c.dom.Document.

        The path prefix includes the directory. If the String contains %s it is replaced with a timestamp.

        Parameters:
        doc - The document.
        xmlPath - The file name which optionally contains a single %s token.
      • transformDocument

        public static void transformDocument​(org.w3c.dom.Document doc,
                                             java.lang.String outPath,
                                             java.lang.String xslPath)

        Writes a backup of a (XML) org.w3c.dom.Document.

        The path prefix includes the directory. The function inserts a timestamp before the file extension. Applies a requested transform.

        Parameters:
        doc - The document.
        outPath - The destination file name.
        xslPath - The transform file name.
      • loadDocument

        public static org.w3c.dom.Document loadDocument​(java.lang.String xmlPath)

        Loads a (XML) org.w3c.dom.Document.

        Parameters:
        xmlPath - The backup file name prefix.
        Returns:
        doc The document.
      • system

        public static void system​(java.lang.String[] cmd)

        Launches system command.

        Parameters:
        cmd - Path to executable followed by command-line parameters