Package com.adobe.xfa.protocol
Class ProtocolUtils
java.lang.Object
com.adobe.xfa.protocol.ProtocolUtils
This class provides some utility methods to support some
protocol I/O capabilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamcheckUrl(String sBaseUrl, String sPath, boolean bTrusted, StringHolder sRealUrl) static StringgetTemplateBasePathFromConfig(Node contextNode) static StringgetTemplateUriPathFromConfig(Node contextNode) static booleanisAbsolute(String sPath) static byte[]mimeBoundary(String prefix) Generates a MIME boundary string given an optional prefix.static byte[]mimeSection(byte[] boundary, byte[] name, byte[] file, byte[] type, byte[] value) static byte[]mimeTrailer(byte[] boundary) static StringnormalizeBaseUrl(String sBaseUrl) Normalizes the given base URL.static InputStreamConvenience method for opening an input URL without worrying about all the additional parameters.static intread(InputStream is, byte[] b) Reads bytes from the input stream into the given array of bytes.static StringURL decodes the given string.static String
-
Method Details
-
read
Reads bytes from the input stream into the given array of bytes. This method blocks until all input data is available, end of file is detected, or an exception is thrown. Contrary toInputStream.read(byte[]), this method will block until a full buffer's worth of data is read.- Parameters:
b- the buffer into which the data is read.- Returns:
- the number of bytes read, or -1 when end of the stream has been reached.
- Throws:
IOException- See Also:
-
checkUrl
public static InputStream checkUrl(String sBaseUrl, String sPath, boolean bTrusted, StringHolder sRealUrl) -
isAbsolute
-
normalizeBaseUrl
Normalizes the given base URL. Base URLs are those from which relative URIs can be resolved.- Parameters:
sBaseUrl- a base URL.
-
openUrl
Convenience method for opening an input URL without worrying about all the additional parameters.- Parameters:
sUrl- Name of resource to open. This may be a local file or a remote location.- Returns:
- Input stream corresponding to the URL opened; null if the operation fails.
-
mimeBoundary
Generates a MIME boundary string given an optional prefix. -
mimeSection
public static byte[] mimeSection(byte[] boundary, byte[] name, byte[] file, byte[] type, byte[] value) -
mimeTrailer
public static byte[] mimeTrailer(byte[] boundary) -
urlEncode
-
urlDecode
URL decodes the given string.- Parameters:
src- the string to decode.- Returns:
- the decoded string.
-
getTemplateBasePathFromConfig
-
getTemplateUriPathFromConfig
-