Package org.faceless.publisher.type
Class Util
java.lang.Object
org.faceless.publisher.type.Util
A collection of static Utility methods
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe namespace for BFO Publisher: http://bfo.com/ns/publisherstatic final StringThe "dc" namespace for Dublin Core elements: http://purl.org/dc/elements/1.1/static final StringThe namespace for HTML: http://www.w3.org/1999/xhtmlstatic final StringThe namespace for MathML: http://www.w3.org/1998/Math/MathMLstatic final StringThe namespace for all tags used with PDF 1.x: http://iso.org/pdf/ssnstatic final StringThe namespace for all tags used with PDF 2.x: http://iso.org/pdf2/ssnstatic final StringThe "rdf" namespace for RDF: http://www.w3.org/1999/02/22-rdf-syntax-ns#static final StringThe namespace for SVG: http://www.w3.org/2000/svgstatic final StringThe "xi" namespace for XInclude: http://www.w3.org/2001/XIncludestatic final StringThe namespace for XInclude 1.1 local attributes: http://www.w3.org/2001/XInclude/local-attributesstatic final StringThe "xlink" namespace: http://www.w3.org/1999/xlinkstatic final StringThe "xml" namespace, seeXMLConstants.XML_NS_URIstatic final StringThe "xmlns" namespace (seeXMLConstants.XMLNS_ATTRIBUTE_NS_URI)static final StringThe "xsl" namespace for XSLT: http://www.w3.org/1999/XSL/Transform -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyStream(InputStream in, OutputStream out) Convenient method to copy an InputStream to an OutputStream.static URL2createDataURL(Blob blob, URL2 source) Create a "data:" URL from the specifiedBlobstatic URL2createDataURL(MediaType mediaType, InputStream in, URL2 source) Create a "data:" URL which will be Base-64 encoded.static URL2createDataURL(MediaType mediaType, String data, URL2 source) Create a "data:" URLstatic ReaderGiven an InputStream, return a Reader that Base-64 encodes the stream on the fly.static OutputStreamgetCompressingOutputStream(OutputStream out, String type) Compress the supplied OutputStreamstatic Stringhex(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 StringA 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 -
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
public static URL2 createDataURL(MediaType mediaType, InputStream in, URL2 source) throws IOException 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
-
getBase64EncodingReader
Given an InputStream, return a Reader that Base-64 encodes the stream on the fly. The reader will return (((in.size() + 2) / 3) * 4) characters
-