Package nl.siegmann.epublib.util
Class ResourceUtil
- java.lang.Object
-
- nl.siegmann.epublib.util.ResourceUtil
-
public class ResourceUtil extends java.lang.ObjectVarious resource utility methods
-
-
Constructor Summary
Constructors Constructor Description ResourceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ResourcecreateResource(java.io.File file)static ResourcecreateResource(java.lang.String title, java.lang.String href)Creates a resource with as contents a html page with the given title.static ResourcecreateResource(ZipEntry zipEntry, java.io.InputStream zipInputStream)static ResourcecreateResource(ZipEntry zipEntry, ZipInputStream zipInputStream)Creates a resource out of the given zipEntry and zipInputStream.static org.w3c.dom.DocumentgetAsDocument(Resource resource)Reads parses the xml therein and returns the result as a Documentstatic org.w3c.dom.DocumentgetAsDocument(Resource resource, javax.xml.parsers.DocumentBuilder documentBuilder)Reads the given resources inputstream, parses the xml therein and returns the result as a Documentstatic org.xml.sax.InputSourcegetInputSource(Resource resource)Gets the contents of the Resource as an InputSource in a null-safe manner.static byte[]recode(java.lang.String inputEncoding, java.lang.String outputEncoding, byte[] input)Converts a given string from given input character encoding to the requested output character encoding.
-
-
-
Method Detail
-
createResource
public static Resource createResource(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
createResource
public static Resource createResource(java.lang.String title, java.lang.String href)
Creates a resource with as contents a html page with the given title.- Parameters:
title-href-- Returns:
- a resource with as contents a html page with the given title.
-
createResource
public static Resource createResource(ZipEntry zipEntry, ZipInputStream zipInputStream) throws java.io.IOException
Creates a resource out of the given zipEntry and zipInputStream.- Parameters:
zipEntry-zipInputStream-- Returns:
- a resource created out of the given zipEntry and zipInputStream.
- Throws:
java.io.IOException
-
createResource
public static Resource createResource(ZipEntry zipEntry, java.io.InputStream zipInputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
recode
public static byte[] recode(java.lang.String inputEncoding, java.lang.String outputEncoding, byte[] input) throws java.io.UnsupportedEncodingExceptionConverts a given string from given input character encoding to the requested output character encoding.- Parameters:
inputEncoding-outputEncoding-input-- Returns:
- the string from given input character encoding converted to the requested output character encoding.
- Throws:
java.io.UnsupportedEncodingException
-
getInputSource
public static org.xml.sax.InputSource getInputSource(Resource resource) throws java.io.IOException
Gets the contents of the Resource as an InputSource in a null-safe manner.- Throws:
java.io.IOException
-
getAsDocument
public static org.w3c.dom.Document getAsDocument(Resource resource) throws java.io.UnsupportedEncodingException, org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
Reads parses the xml therein and returns the result as a Document- Throws:
java.io.UnsupportedEncodingExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionjavax.xml.parsers.ParserConfigurationException
-
getAsDocument
public static org.w3c.dom.Document getAsDocument(Resource resource, javax.xml.parsers.DocumentBuilder documentBuilder) throws java.io.UnsupportedEncodingException, org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
Reads the given resources inputstream, parses the xml therein and returns the result as a Document- Parameters:
resource-documentBuilder-- Returns:
- the document created from the given resource
- Throws:
java.io.UnsupportedEncodingExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionjavax.xml.parsers.ParserConfigurationException
-
-