Class Util

java.lang.Object
org.faceless.publisher.type.Util

public class Util extends Object
A collection of static Utility methods
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The namespace for BFO Publisher: http://bfo.com/ns/publisher
    static final String
    The "dc" namespace for Dublin Core elements: http://purl.org/dc/elements/1.1/
    static final String
    The namespace for HTML: http://www.w3.org/1999/xhtml
    static final String
    The namespace for MathML: http://www.w3.org/1998/Math/MathML
    static final String
    The namespace for all tags used with PDF 1.x: http://iso.org/pdf/ssn
    static final String
    The namespace for all tags used with PDF 2.x: http://iso.org/pdf2/ssn
    static final String
    The "rdf" namespace for RDF: http://www.w3.org/1999/02/22-rdf-syntax-ns#
    static final String
    The namespace for SVG: http://www.w3.org/2000/svg
    static final String
    The "xi" namespace for XInclude: http://www.w3.org/2001/XInclude
    static final String
    The namespace for XInclude 1.1 local attributes: http://www.w3.org/2001/XInclude/local-attributes
    static final String
    The "xlink" namespace: http://www.w3.org/1999/xlink
    static final String
    The "xml" namespace (see XMLConstants.XML_NS_URI
    static final String
    The "xmlns" namespace (see XMLConstants.XMLNS_ATTRIBUTE_NS_URI)
    static final String
    The "xsl" namespace for XSLT: http://www.w3.org/1999/XSL/Transform
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Convenient method to copy an InputStream to an OutputStream.
    static URL2
    Create a "data:" URL from the specified Blob
    static URL2
    Create a "data:" URL which will be Base-64 encoded.
    static URL2
    createDataURL(MediaType mediaType, String data)
    Create a "data:" URL
    static boolean
    equals(Object o1, Object o2)
     
    static String
    hex(byte[] in)
    Return the byte array as a lowercase hex string
    static byte[]
    hex(String in)
    Return a byte array from the hex-encoded input
    static byte[]
    Convenient method to read an InputStream fully into a byte array.
    static String
    A toString() method that improves on the original where possible

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NS_HTML

      public static final String NS_HTML
      The namespace for HTML: http://www.w3.org/1999/xhtml
      See Also:
    • NS_BFO

      public static final String NS_BFO
      The namespace for BFO Publisher: http://bfo.com/ns/publisher
      See Also:
    • NS_SVG

      public static final String NS_SVG
      The namespace for SVG: http://www.w3.org/2000/svg
      See Also:
    • NS_MATHML

      public static final String NS_MATHML
      The namespace for MathML: http://www.w3.org/1998/Math/MathML
      See Also:
    • NS_RDF

      public static final String NS_RDF
      The "rdf" namespace for RDF: http://www.w3.org/1999/02/22-rdf-syntax-ns#
      See Also:
    • NS_DC

      public static final String NS_DC
      The "dc" namespace for Dublin Core elements: http://purl.org/dc/elements/1.1/
      See Also:
    • NS_XML

      public static final String NS_XML
      The "xml" namespace (see XMLConstants.XML_NS_URI
      See Also:
    • NS_XMLNS

      public static final String NS_XMLNS
      The "xmlns" namespace (see XMLConstants.XMLNS_ATTRIBUTE_NS_URI)
      See Also:
    • NS_XI

      public static final String NS_XI
      The "xi" namespace for XInclude: http://www.w3.org/2001/XInclude
      See Also:
    • NS_XILA

      public static final String NS_XILA
      The namespace for XInclude 1.1 local attributes: http://www.w3.org/2001/XInclude/local-attributes
      See Also:
    • NS_XSL

      public static final String NS_XSL
      The "xsl" namespace for XSLT: http://www.w3.org/1999/XSL/Transform
      See Also:
    • NS_PDF1

      public static final String NS_PDF1
      The namespace for all tags used with PDF 1.x: http://iso.org/pdf/ssn
      See Also:
    • NS_PDF2

      public static final String NS_PDF2
      The namespace for all tags used with PDF 2.x: http://iso.org/pdf2/ssn
      See Also:
  • Method Details

    • hex

      public static byte[] hex(String in)
      Return a byte array from the hex-encoded input
    • hex

      public static String hex(byte[] in)
      Return the byte array as a lowercase hex string
    • equals

      public static boolean equals(Object o1, Object o2)
    • toString

      public static String toString(Object o)
      A toString() method that improves on the original where possible
      Parameters:
      o - the object to convert to a String
    • readFully

      public static byte[] readFully(InputStream in) throws IOException
      Convenient method to read an InputStream fully into a byte array.
      Parameters:
      in - the InputStream The stream is closed on completion
      Throws:
      IOException
    • copyStream

      public static void copyStream(InputStream in, OutputStream out) throws IOException
      Convenient method to copy an InputStream to an OutputStream.
      Parameters:
      in - the InputStream
      out - the OutputStream
      Throws:
      IOException
    • createDataURL

      public static URL2 createDataURL(MediaType mediaType, String data)
      Create a "data:" URL
      Parameters:
      mediaType - the mediaType to specify, or null to leave this unset
      data - the data to encode. The result will not be Base-64 encoded
      Returns:
      the data URL
    • createDataURL

      public static URL2 createDataURL(MediaType mediaType, InputStream in) throws IOException
      Create a "data:" URL which will be Base-64 encoded.
      Parameters:
      mediaType - the mediaType to specify, or null to leave this unset
      in - the InputStream to read the data to encode. The stream is not closed
      Returns:
      the data URL
      Throws:
      IOException
    • createDataURL

      public static URL2 createDataURL(Blob blob)
      Create a "data:" URL from the specified Blob
      Parameters:
      blob - the blob to convert
      Returns:
      the data URL