Package org.faceless.publisher.type
Class Util
java.lang.Object
org.faceless.publisher.type.Util
A collection of static Utility methods
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The namespace for BFO Publisher: http://bfo.com/ns/publisherstatic 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/xhtmlstatic final String
The namespace for MathML: http://www.w3.org/1998/Math/MathMLstatic final String
The namespace for all tags used with PDF 1.x: http://iso.org/pdf/ssnstatic final String
The namespace for all tags used with PDF 2.x: http://iso.org/pdf2/ssnstatic 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/svgstatic final String
The "xi" namespace for XInclude: http://www.w3.org/2001/XIncludestatic final String
The namespace for XInclude 1.1 local attributes: http://www.w3.org/2001/XInclude/local-attributesstatic final String
The "xlink" namespace: http://www.w3.org/1999/xlinkstatic final String
The "xml" namespace (seeXMLConstants.XML_NS_URI
static final String
The "xmlns" namespace (seeXMLConstants.XMLNS_ATTRIBUTE_NS_URI
)static final String
The "xsl" namespace for XSLT: http://www.w3.org/1999/XSL/Transform -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyStream
(InputStream in, OutputStream out) Convenient method to copy an InputStream to an OutputStream.static URL2
createDataURL
(Blob blob) Create a "data:" URL from the specifiedBlob
static URL2
createDataURL
(MediaType mediaType, InputStream in) Create a "data:" URL which will be Base-64 encoded.static URL2
createDataURL
(MediaType mediaType, String data) Create a "data:" URLstatic boolean
static OutputStream
getCompressingOutputStream
(OutputStream out, String type) Compress the supplied OutputStreamstatic String
hex
(byte[] in) Return the byte array as a lowercase hex stringstatic byte[]
Return a byte array from the hex-encoded inputstatic byte[]
readFully
(InputStream in) Convenient method to read an InputStream fully into a byte array.static String
A toString() method that improves on the original where possible
-
Field Details
-
NS_HTML
The namespace for HTML: http://www.w3.org/1999/xhtml- See Also:
-
NS_BFO
The namespace for BFO Publisher: http://bfo.com/ns/publisher- See Also:
-
NS_SVG
The namespace for SVG: http://www.w3.org/2000/svg- See Also:
-
NS_MATHML
The namespace for MathML: http://www.w3.org/1998/Math/MathML- See Also:
-
NS_RDF
The "rdf" namespace for RDF: http://www.w3.org/1999/02/22-rdf-syntax-ns#- See Also:
-
NS_DC
The "dc" namespace for Dublin Core elements: http://purl.org/dc/elements/1.1/- See Also:
-
NS_XML
The "xml" namespace (seeXMLConstants.XML_NS_URI
- See Also:
-
NS_XLINK
The "xlink" namespace: http://www.w3.org/1999/xlink- See Also:
-
NS_XMLNS
The "xmlns" namespace (seeXMLConstants.XMLNS_ATTRIBUTE_NS_URI
)- See Also:
-
NS_XI
The "xi" namespace for XInclude: http://www.w3.org/2001/XInclude- See Also:
-
NS_XILA
The namespace for XInclude 1.1 local attributes: http://www.w3.org/2001/XInclude/local-attributes- See Also:
-
NS_XSL
The "xsl" namespace for XSLT: http://www.w3.org/1999/XSL/Transform- See Also:
-
NS_PDF1
The namespace for all tags used with PDF 1.x: http://iso.org/pdf/ssn- See Also:
-
NS_PDF2
The namespace for all tags used with PDF 2.x: http://iso.org/pdf2/ssn- See Also:
-
-
Method Details
-
hex
Return a byte array from the hex-encoded input -
hex
Return the byte array as a lowercase hex string -
equals
-
toString
A toString() method that improves on the original where possible- Parameters:
o
- the object to convert to a String
-
readFully
Convenient method to read an InputStream fully into a byte array.- Parameters:
in
- the InputStream The stream is closed on completion- Throws:
IOException
-
copyStream
Convenient method to copy an InputStream to an OutputStream.- Parameters:
in
- the InputStreamout
- the OutputStream- Throws:
IOException
-
createDataURL
Create a "data:" URL- Parameters:
mediaType
- the mediaType to specify, or null to leave this unsetdata
- the data to encode. The result will not be Base-64 encoded- Returns:
- the data URL
-
createDataURL
Create a "data:" URL which will be Base-64 encoded.- Parameters:
mediaType
- the mediaType to specify, or null to leave this unsetin
- the InputStream to read the data to encode. The stream is not closed- Returns:
- the data URL
- Throws:
IOException
-
createDataURL
Create a "data:" URL from the specifiedBlob
- Parameters:
blob
- the blob to convert- Returns:
- the data URL
-
getCompressingOutputStream
public static OutputStream getCompressingOutputStream(OutputStream out, String type) throws IOException Compress the supplied OutputStream- Parameters:
type
- the algorithm - lz4, gzip, zstd, xz, or null for no compression- Throws:
IOException
-