org.apache.batik.util

Class ParsedURLData

public class ParsedURLData extends Object

Holds the data for more URLs.
Field Summary
protected static ListacceptedEncodings
StringcontentEncoding
StringcontentType
protected StringcontentTypeCharset
The extracted charset parameter from the Content-Type header.
protected StringcontentTypeMediaType
The extracted type/subtype from the Content-Type header.
static byte[]GZIP_MAGIC
GZIP header magic number bytes, like found in a gzipped files, which are encoded in Intel format (i.e. little indian).
booleanhasBeenOpened
Stringhost
protected static StringHTTP_ACCEPT_ENCODING_HEADER
protected static StringHTTP_ACCEPT_HEADER
protected static StringHTTP_ACCEPT_LANGUAGE_HEADER
protected static StringHTTP_USER_AGENT_HEADER
Stringpath
intport
Stringprotocol
Since the Data instance is 'hidden' in the ParsedURL instance we make all our methods public.
Stringref
InputStreamstream
Constructor Summary
ParsedURLData()
Void constructor
ParsedURLData(URL url)
Build from an existing URL.
Method Summary
protected URLbuildURL()
Attempts to build a normal java.net.URL instance from this URL.
static InputStreamcheckGZIP(InputStream is)
This is a utility function others can call that checks if is is a GZIP stream if so it returns a GZIPInputStream that will decode the contents, otherwise it returns (or a buffered version of is) untouched.
booleancomplete()
Returns true if the URL looks well formed and complete.
booleanequals(Object obj)
Implement Object.equals for ParsedURLData.
protected voidextractContentTypeParts(String userAgent)
Extracts the type/subtype and charset parameter from the Content-Type header.
StringgetContentEncoding(String userAgent)
Returns the content encoding if available.
StringgetContentType(String userAgent)
Returns the content type if available.
StringgetContentTypeCharset(String userAgent)
Returns the content type's charset parameter, if available.
StringgetContentTypeMediaType(String userAgent)
Returns the content type's type/subtype, if available.
StringgetPortStr()
Returns the URL up to and include the port number on the host.
booleanhasContentTypeParameter(String userAgent, String param)
Returns whether the Content-Type header has the given parameter.
inthashCode()
Implement Object.hashCode.
InputStreamopenStream(String userAgent, Iterator mimeTypes)
Open the stream and check for common compression types.
protected InputStreamopenStreamInternal(String userAgent, Iterator mimeTypes, Iterator encodingTypes)
InputStreamopenStreamRaw(String userAgent, Iterator mimeTypes)
Open the stream and returns it.
protected booleansameFile(ParsedURLData other)
StringtoString()
Return a string representation of the data.

Field Detail

acceptedEncodings

protected static List acceptedEncodings

contentEncoding

public String contentEncoding

contentType

public String contentType

contentTypeCharset

protected String contentTypeCharset
The extracted charset parameter from the Content-Type header.

contentTypeMediaType

protected String contentTypeMediaType
The extracted type/subtype from the Content-Type header.

GZIP_MAGIC

public static final byte[] GZIP_MAGIC
GZIP header magic number bytes, like found in a gzipped files, which are encoded in Intel format (i.e. little indian).

hasBeenOpened

public boolean hasBeenOpened

host

public String host

HTTP_ACCEPT_ENCODING_HEADER

protected static final String HTTP_ACCEPT_ENCODING_HEADER

HTTP_ACCEPT_HEADER

protected static final String HTTP_ACCEPT_HEADER

HTTP_ACCEPT_LANGUAGE_HEADER

protected static final String HTTP_ACCEPT_LANGUAGE_HEADER

HTTP_USER_AGENT_HEADER

protected static final String HTTP_USER_AGENT_HEADER

path

public String path

port

public int port

protocol

public String protocol
Since the Data instance is 'hidden' in the ParsedURL instance we make all our methods public. This makes it easy for the various Protocol Handlers to update an instance as parsing proceeds.

ref

public String ref

stream

public InputStream stream

Constructor Detail

ParsedURLData

public ParsedURLData()
Void constructor

ParsedURLData

public ParsedURLData(URL url)
Build from an existing URL.

Method Detail

buildURL

protected URL buildURL()
Attempts to build a normal java.net.URL instance from this URL.

checkGZIP

public static InputStream checkGZIP(InputStream is)
This is a utility function others can call that checks if is is a GZIP stream if so it returns a GZIPInputStream that will decode the contents, otherwise it returns (or a buffered version of is) untouched.

Parameters: is Stream that may potentially be a GZIP stream.

complete

public boolean complete()
Returns true if the URL looks well formed and complete. This does not garuntee that the stream can be opened but is a good indication that things aren't totally messed up.

equals

public boolean equals(Object obj)
Implement Object.equals for ParsedURLData.

extractContentTypeParts

protected void extractContentTypeParts(String userAgent)
Extracts the type/subtype and charset parameter from the Content-Type header.

getContentEncoding

public String getContentEncoding(String userAgent)
Returns the content encoding if available. This is only available for some protocols.

getContentType

public String getContentType(String userAgent)
Returns the content type if available. This is only available for some protocols.

getContentTypeCharset

public String getContentTypeCharset(String userAgent)
Returns the content type's charset parameter, if available. This is only available for some protocols.

getContentTypeMediaType

public String getContentTypeMediaType(String userAgent)
Returns the content type's type/subtype, if available. This is only available for some protocols.

getPortStr

public String getPortStr()
Returns the URL up to and include the port number on the host. Does not include the path or fragment pieces.

hasContentTypeParameter

public boolean hasContentTypeParameter(String userAgent, String param)
Returns whether the Content-Type header has the given parameter.

hashCode

public int hashCode()
Implement Object.hashCode.

openStream

public InputStream openStream(String userAgent, Iterator mimeTypes)
Open the stream and check for common compression types. If the stream is found to be compressed with a standard compression type it is automatically decompressed.

Parameters: userAgent The user agent opening the stream (may be null). mimeTypes The expected mime types of the content in the returned InputStream (mapped to Http accept header among other possability). The elements of the iterator must be strings (may be null)

openStreamInternal

protected InputStream openStreamInternal(String userAgent, Iterator mimeTypes, Iterator encodingTypes)

openStreamRaw

public InputStream openStreamRaw(String userAgent, Iterator mimeTypes)
Open the stream and returns it. No checks are made to see if the stream is compressed or encoded in any way.

Parameters: userAgent The user agent opening the stream (may be null). mimeTypes The expected mime types of the content in the returned InputStream (mapped to Http accept header among other possability). The elements of the iterator must be strings (may be null)

sameFile

protected boolean sameFile(ParsedURLData other)

toString

public String toString()
Return a string representation of the data.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.