public class XOPUtils extends Object
|Modifier and Type||Method and Description|
Extract the content ID from a URL following the cid scheme defined by RFC2392.
Build a cid URL from the given content ID as described in RFC2392.
Get an XOP encoded stream for a given stream reader.
url- the URL
IllegalArgumentException- if the URL doesn't use the cid scheme
Note that this implementation only encodes the percent character (replacing it by "%25"). The reason is given by the following quotes from RFC3986:
If a reserved character is found in a URI component and no delimiting role is known for that character, then it must be interpreted as representing the data octet corresponding to that character's encoding in US-ASCII. [...]
Under normal circumstances, the only time when octets within a URI are percent-encoded is during the process of producing the URI from its component parts. This is when an implementation determines which of the reserved characters are to be used as subcomponent delimiters and which can be safely used as data. [...]
Because the percent ("%") character serves as the indicator for percent-encoded octets, it must be percent-encoded as "%25" for that octet to be used as data within a URI.
Since RFC2392 doesn't define any subcomponents for the cid scheme and since RFC2045 specifies that only US-ASCII characters are allowed in content IDs, the percent character (which is specifically allowed by RFC2045) is the only character that needs URL encoding.
Another reason to strictly limit the set of characters to be encoded is that some applications fail to decode cid URLs correctly if they contain percent encoded octets.
contentID- the content ID (without enclosing angle brackets)
public static XOPEncodedStream getXOPEncodedStream(javax.xml.stream.XMLStreamReader reader)
XOPEncodingStreamReaderit will be preserved, since it is already XOP encoded.
XOPDecodingStreamReader, it will be unwrapped to give access to the underlying XOP encoded reader.
DataHandlerReaderextension, it will be wrapped in an
XOPEncodingStreamReaderso that optimized binary data can be transferred using XOP.
reader- the original reader
Copyright © The Apache Software Foundation. All Rights Reserved.