Class Cbsw

java.lang.Object
cbsw.Cbsw

public class Cbsw extends Object

A collection of miscellaneous methods

  • Constructor Details

    • Cbsw

      public Cbsw()
  • Method Details

    • createUnmarshaller

      public static javax.xml.bind.Unmarshaller createUnmarshaller(Class... classes)
    • urlToFile

      public static File urlToFile(String urlString)
    • unmarshal

      public static Object unmarshal(String xml, 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
    • unmarshal

      public static Object unmarshal(String xml, javax.xml.bind.annotation.adapters.XmlAdapter adapter, Class... classes)
    • unmarshal

      public static Object unmarshal(Class... classes)

      Unmarshal class using XML URL derived from first class arg.

      Parameters:
      classes - The classes that provide the unmarshalling context
      Returns:
      The unmarshalled object
    • exec

      public static void exec(Class<?> cl, 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 File chooseFile(String dir, 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(String jobName, 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(Document doc, 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(Document doc, String outPath, 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 Document loadDocument(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(String[] cmd)

      Launches system command.

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

      public static void dump(ByteBuffer bb)