Package com.adobe.xfa.protocol
Class ProtocolUtils
- java.lang.Object
-
- com.adobe.xfa.protocol.ProtocolUtils
-
public final class ProtocolUtils extends Object
This class provides some utility methods to support some protocol I/O capabilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InputStream
checkUrl(String sBaseUrl, String sPath, boolean bTrusted, StringHolder sRealUrl)
static String
getTemplateBasePathFromConfig(Node contextNode)
static String
getTemplateUriPathFromConfig(Node contextNode)
static boolean
isAbsolute(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 String
normalizeBaseUrl(String sBaseUrl)
Normalizes the given base URL.static InputStream
openUrl(String sUrl)
Convenience method for opening an input URL without worrying about all the additional parameters.static int
read(InputStream is, byte[] b)
Reads bytes from the input stream into the given array of bytes.static String
urlDecode(String src)
URL decodes the given string.static String
urlEncode(String src)
-
-
-
Method Detail
-
read
public static int read(InputStream is, byte[] b) throws IOException
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:
InputStream.read(byte[])
-
checkUrl
public static InputStream checkUrl(String sBaseUrl, String sPath, boolean bTrusted, StringHolder sRealUrl)
-
isAbsolute
public static boolean isAbsolute(String sPath)
-
normalizeBaseUrl
public static String normalizeBaseUrl(String sBaseUrl)
Normalizes the given base URL. Base URLs are those from which relative URIs can be resolved.- Parameters:
sBaseUrl
- a base URL.
-
openUrl
public static InputStream openUrl(String sUrl)
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
public static byte[] mimeBoundary(String prefix)
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)
-
urlDecode
public static String urlDecode(String src)
URL decodes the given string.- Parameters:
src
- the string to decode.- Returns:
- the decoded string.
-
-