/** * Subclasses can override these method to construct alternate * subclasses of ParsedURLData. * @param url the java.net.URL class we reference. */ protected ParsedURLData constructParsedURLData(URL url) { return new ParsedURLData(url); }
/** * 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. */ public boolean complete() { try { buildURL(); } catch (MalformedURLException mue) { return false; } return true; }
/** * 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. * @param is Stream that may potentially be a GZIP stream. */ public static InputStream checkGZIP(InputStream is) throws IOException { return ParsedURLData.checkGZIP(is); }
/** * 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. * @param userAgent The user agent opening the stream (may be null). * @param 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) */ public InputStream openStream(String userAgent, Iterator mimeTypes) throws IOException { InputStream raw = openStreamInternal(userAgent, mimeTypes, acceptedEncodings.iterator()); if (raw == null) return null; stream = null; return checkGZIP(raw); }
/** * Returns the content type if available. This is only available * for some protocols. */ public String getContentType() { return data.getContentType(userAgent); }
/** * Returns true if the URL looks well formed and complete. * This does not guarantee that the stream can be opened but * is a good indication that things aren't totally messed up. */ public boolean complete() { return data.complete(); }
/** * Returns the content encoding if available. This is only available * for some protocols. */ public String getContentEncoding() { return data.getContentEncoding(userAgent); }
/** * Implement Object.equals. * Relies heavily on the contained ParsedURLData's implementation * of equals. */ public boolean equals(Object obj) { if (obj == null) return false; if (! (obj instanceof ParsedURL)) return false; ParsedURL purl = (ParsedURL)obj; return data.equals(purl.data); }
/** * Returns the content type's type/subtype, if available. This is * only available for some protocols. */ public String getContentTypeMediaType(String userAgent) { if (contentTypeMediaType != null) { return contentTypeMediaType; } extractContentTypeParts(userAgent); return contentTypeMediaType; }
/** * Returns the content type's charset parameter, if available. This is * only available for some protocols. */ public String getContentTypeCharset() { return data.getContentTypeCharset(userAgent); }
/** * Returns the content type's type/subtype, if available. This is * only available for some protocols. */ public String getContentTypeMediaType() { return data.getContentTypeMediaType(userAgent); }
/** * 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. * @param userAgent The user agent opening the stream (may be null). * @param 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) */ public InputStream openStream(String userAgent, Iterator mimeTypes) throws IOException { InputStream raw = openStreamInternal(userAgent, mimeTypes, acceptedEncodings.iterator()); if (raw == null) return null; stream = null; return checkGZIP(raw); }
/** * Returns the content type if available. This is only available * for some protocols. */ public String getContentType() { return data.getContentType(userAgent); }
/** * Returns true if the URL looks well formed and complete. * This does not guarantee that the stream can be opened but * is a good indication that things aren't totally messed up. */ public boolean complete() { return data.complete(); }
/** * Returns the content encoding if available. This is only available * for some protocols. */ public String getContentEncoding() { return data.getContentEncoding(userAgent); }
/** * Implement Object.equals. * Relies heavily on the contained ParsedURLData's implementation * of equals. */ public boolean equals(Object obj) { if (obj == null) return false; if (! (obj instanceof ParsedURL)) return false; ParsedURL purl = (ParsedURL)obj; return data.equals(purl.data); }
/** * Returns the content type's charset parameter, if available. This is * only available for some protocols. */ public String getContentTypeCharset(String userAgent) { if (contentTypeMediaType != null) { return contentTypeCharset; } extractContentTypeParts(userAgent); return contentTypeCharset; }
/** * Returns the content type's charset parameter, if available. This is * only available for some protocols. */ public String getContentTypeCharset() { return data.getContentTypeCharset(userAgent); }
/** * Returns the content type's type/subtype, if available. This is * only available for some protocols. */ public String getContentTypeMediaType() { return data.getContentTypeMediaType(userAgent); }
/** * Subclasses can override these method to construct alternate * subclasses of ParsedURLData. */ protected ParsedURLData constructParsedURLData() { return new ParsedURLData(); }