java.lang.Object
io.sf.carte.echosvg.util.ParsedURLData
- All Implemented Interfaces:
- Serializable
Holds the data for more URLs.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected StringThe extracted charset parameter from the Content-Type header.protected StringThe extracted type/subtype from the Content-Type header.static final byte[]GZIP header magic number bytes, like found in a gzipped files, which are encoded in Intel format (i.e. little indian).booleanprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringintprotected URLThe URL that was ultimately used to fetch the resource.Since the Data instance is 'hidden' in the ParsedURL instance we make all our methods public.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected 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.booleanImplement Object.equals for ParsedURLData.protected voidextractContentTypeParts(String userAgent) Extracts the type/subtype and charset parameter from the Content-Type header.static intGets the connect timeout.getContentEncoding(String userAgent) Returns the content encoding if available.getContentType(String userAgent) Returns the content type if available.getContentTypeCharset(String userAgent) Returns the content type's charset parameter, if available.getContentTypeMediaType(String userAgent) Returns the content type's type/subtype, if available.Returns the URL up to and include the port number on the host.Returns the URL that was ultimately used to fetch the resource represented by theParsedURL.static intGets the read timeout.booleanhasContentTypeParameter(String userAgent, String param) Returns whether the Content-Type header has the given parameter.inthashCode()Implement Object.hashCode.openStream(String userAgent, Iterator<String> mimeTypes) Open the stream and check for common compression types.protected InputStreamopenStreamRaw(String userAgent, Iterator<String> mimeTypes) Open the stream and returns it.protected booleansameFile(ParsedURLData other) static voidsetConnectTimeout(int connectTimeout) Sets the connect timeout.static voidsetReadTimeout(int readTimeout) Sets the read timeout.toString()Return a string representation of the data.
- 
Field Details- 
HTTP_USER_AGENT_HEADER- See Also:
 
- 
HTTP_ACCEPT_HEADER- See Also:
 
- 
HTTP_ACCEPT_LANGUAGE_HEADER- See Also:
 
- 
HTTP_ACCEPT_ENCODING_HEADER- See Also:
 
- 
acceptedEncodings
- 
GZIP_MAGICpublic static final byte[] GZIP_MAGICGZIP header magic number bytes, like found in a gzipped files, which are encoded in Intel format (i.e. little indian).
- 
protocolSince 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.
- 
host
- 
portpublic int port
- 
path
- 
ref
- 
contentType
- 
contentEncoding
- 
stream
- 
hasBeenOpenedpublic transient boolean hasBeenOpened
- 
contentTypeMediaTypeThe extracted type/subtype from the Content-Type header.
- 
contentTypeCharsetThe extracted charset parameter from the Content-Type header.
- 
postConnectionURLThe URL that was ultimately used to fetch the resource.
 
- 
- 
Constructor Details- 
ParsedURLDatapublic ParsedURLData()Void constructor
- 
ParsedURLDataBuild from an existing URL.
 
- 
- 
Method Details- 
checkGZIPThis 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.
- Throws:
- IOException
 
- 
buildURLAttempts to build a normal java.net.URL instance from this URL.- Throws:
- MalformedURLException
 
- 
getConnectTimeoutpublic static int getConnectTimeout()Gets the connect timeout.- Returns:
- the connect timeout.
 
- 
setConnectTimeoutpublic static void setConnectTimeout(int connectTimeout) Sets the connect timeout.Default is 10 seconds. - Parameters:
- connectTimeout- the connect timeout.
- Throws:
- IllegalArgumentException- if the argument is negative.
 
- 
getReadTimeoutpublic static int getReadTimeout()Gets the read timeout.- Returns:
- the read timeout.
 
- 
setReadTimeoutpublic static void setReadTimeout(int readTimeout) Sets the read timeout.- Parameters:
- readTimeout- the read timeout.
- Throws:
- IllegalArgumentException- if the argument is negative.
 
- 
hashCodepublic int hashCode()Implement Object.hashCode.
- 
equalsImplement Object.equals for ParsedURLData.
- 
getContentTypeReturns the content type if available. This is only available for some protocols.
- 
getContentTypeMediaTypeReturns the content type's type/subtype, if available. This is only available for some protocols.
- 
getContentTypeCharsetReturns the content type's charset parameter, if available. This is only available for some protocols.
- 
hasContentTypeParameterReturns whether the Content-Type header has the given parameter.
- 
extractContentTypePartsExtracts the type/subtype and charset parameter from the Content-Type header.
- 
getContentEncodingReturns the content encoding if available. This is only available for some protocols.
- 
completepublic 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.
- 
openStreamOpen 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)
- Throws:
- IOException
 
- 
openStreamRawOpen 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)
- Throws:
- IOException
 
- 
openStreamInternalprotected InputStream openStreamInternal(String userAgent, Iterator<String> mimeTypes, Iterator<String> encodingTypes) throws IOException - Throws:
- IOException
 
- 
getPortStrReturns the URL up to and include the port number on the host. Does not include the path or fragment pieces.
- 
sameFile
- 
toStringReturn a string representation of the data.
- 
getPostConnectionURLReturns the URL that was ultimately used to fetch the resource represented by theParsedURL.
 
-