public class MultiProtocolURL extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<MultiProtocolURL>
Modifier and Type | Class and Description |
---|---|
static class |
MultiProtocolURL.CharType |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
anchor |
private static java.util.regex.Pattern |
backPathPattern |
protected Classification.ContentDomain |
contentDomain |
private static java.lang.String[] |
hex |
protected java.lang.String |
host |
protected java.net.InetAddress |
hostAddress |
protected java.lang.String |
path |
private static java.util.regex.Pattern |
patternMail |
protected int |
port |
private static java.lang.Object |
PRESENT |
protected java.lang.String |
protocol |
protected java.lang.String |
searchpart |
private static long |
serialVersionUID |
private static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> |
sessionIDnames |
private static long |
SMB_TIMEOUT |
static java.util.regex.Pattern |
splitpattern |
private static java.lang.String |
splitrex |
static int |
TLD_any_zone_filter |
private static java.util.BitSet |
UNRESERVED_PATH |
private static java.util.BitSet |
UNRESERVED_RFC1738 |
protected java.lang.String |
userInfo |
Modifier | Constructor and Description |
---|---|
|
MultiProtocolURL()
initialization of a MultiProtocolURI to produce poison pills for concurrent blocking queues
|
|
MultiProtocolURL(java.io.File file) |
protected |
MultiProtocolURL(MultiProtocolURL url) |
|
MultiProtocolURL(MultiProtocolURL baseURL,
java.lang.String relPath) |
|
MultiProtocolURL(java.lang.String url)
Create MultiProtocolURL
decoding exception: if url string contains http url with char '%' the url string must be url encoded (percent-escaped) before
as internal encoding is skipped if url string contains '%'.
|
|
MultiProtocolURL(java.lang.String protocol,
java.lang.String host,
int port,
java.lang.String path)
creates MultiProtocolURL
if path contains '?' search part is automatically created by splitting input into path and searchpart
dto for anchor's ('#')
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead() |
boolean |
canWrite() |
private static MultiProtocolURL.CharType |
charType(char c) |
int |
compareTo(MultiProtocolURL h) |
boolean |
equals(java.lang.Object obj) |
private void |
escape()
Escapes the following parts of the url, this object already contains:
path: see
escape(String)
ref: same as above
quest: same as above without the ampersand ("&") and the equals symbol
|
static java.lang.StringBuilder |
escape(java.lang.String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced
with the UTF-8-in-URL proposal.
|
private void |
escapePath()
Url encode/escape the path part according to the allowed characters
(RFC1738 & RFC2396)
uses UTF-8 character codes for non-ASCII
|
private void |
escapeSearchpart() |
boolean |
exists() |
byte[] |
get(ClientIdentification.Agent agent,
java.lang.String username,
java.lang.String pass) |
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Evaluates url search part and returns attribute '=' value pairs
the returned values are in clear text (without urlencoding).
|
java.lang.String |
getAuthority() |
Classification.ContentDomain |
getContentDomainFromExt()
Get the content domain of a document according to the extension.
|
java.lang.String |
getFile()
get the hpath plus search field plus anchor.
|
java.lang.String |
getFile(boolean excludeAnchor,
boolean removeSessionID)
get the hpath plus search field plus anchor (if wanted)
see http://www.ietf.org/rfc/rfc1738.txt for naming.
|
static java.lang.String |
getFileExtension(java.lang.String fileName)
Get extension out of a filename
cuts off query part
|
java.lang.String |
getFileName() |
java.io.File |
getFSFile()
create a standard java File.
|
java.lang.String |
getHost() |
java.net.InetAddress |
getInetAddress() |
java.io.InputStream |
getInputStream(ClientIdentification.Agent agent,
java.lang.String username,
java.lang.String pass) |
java.util.Locale |
getLocale() |
java.io.File |
getLocalFile()
return the file object to a local file
this patches also 'strange' windows file paths
|
java.lang.String |
getName() |
java.lang.String |
getOrganization() |
java.lang.String |
getPath() |
java.lang.String[] |
getPaths() |
int |
getPort() |
java.lang.String |
getProtocol() |
java.lang.String |
getRef() |
java.lang.String |
getSearchpart() |
java.util.Map<java.lang.String,java.lang.String> |
getSearchpartMap()
Returns a search part parameter map key=value
in internal url encoded format
for unescaped return values
|
SmbFile |
getSmbFile()
create a smb File
Please call isSMB() before using this class
|
java.lang.String |
getTLD() |
java.net.URL |
getURL()
create a standard java URL.
|
java.lang.String |
getUserInfo()
the userInfo is the authentication part in front of the host; separated by '@'
|
int |
hashCode() |
private void |
identAnchor() |
private void |
identPort(java.lang.String inputURL,
int dflt) |
private void |
identSearchpart() |
static void |
initSessionIDNames(java.util.Set<java.lang.String> idNames) |
static boolean |
isCGI(java.lang.String extension) |
boolean |
isDirectory() |
boolean |
isFile() |
static boolean |
isFile(java.lang.String s) |
boolean |
isFTP() |
static boolean |
isFTP(java.lang.String s) |
boolean |
isHidden() |
boolean |
isHTTP() |
static boolean |
isHTTP(java.lang.String s) |
boolean |
isHTTPS() |
static boolean |
isHTTPS(java.lang.String s) |
static boolean |
isImage(java.lang.String extension)
Deprecated.
use a mimetype considering methode (e.g. Document.getContentDomain() == ContentDomain.IMAGE or else Classification.isImageExtension() )
|
boolean |
isIndividual() |
boolean |
isLocal() |
boolean |
isPOST() |
boolean |
isSMB() |
static boolean |
isSMB(java.lang.String s) |
java.lang.String |
language() |
long |
lastModified() |
long |
length() |
java.lang.String[] |
list()
Get directory listing of file or smb url
respects the hidden attribute of a directory (return null if hidden)
|
static void |
main(java.lang.String[] args) |
static MultiProtocolURL |
newURL(MultiProtocolURL baseURL,
java.lang.String relPath) |
static MultiProtocolURL |
newURL(java.lang.String baseURL,
java.lang.String relPath) |
private static java.util.Set<java.lang.String> |
parseCamelCase(java.lang.String s) |
static byte[] |
read(java.io.InputStream source) |
void |
removeRef() |
private static java.lang.String |
resolveBackpath(java.lang.String path) |
java.lang.String |
toNormalform(boolean excludeAnchor) |
java.lang.String |
toNormalform(boolean excludeAnchor,
boolean removeSessionID) |
static java.lang.String |
toPunycode(java.lang.String host) |
java.lang.String |
toString() |
java.lang.String |
toTokens()
Tokenized url as string (without the protocol)
|
static java.lang.String |
toTokens(java.lang.String s)
create word tokens for parser.
|
static java.lang.String |
unescape(java.lang.String s) |
static java.lang.String[] |
urlComps(java.lang.String normalizedURL) |
java.lang.String |
urlstub(boolean excludeAnchor,
boolean removeSessionID)
Generates a normal form of the url, without the protocol part,
except the skipped protocol part this is identical with toNormalform()
|
private static final long serialVersionUID
private static final long SMB_TIMEOUT
public static final int TLD_any_zone_filter
private static final java.util.regex.Pattern backPathPattern
private static final java.util.regex.Pattern patternMail
private static final java.util.BitSet UNRESERVED_RFC1738
private static final java.util.BitSet UNRESERVED_PATH
private static final java.lang.Object PRESENT
private static final java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> sessionIDnames
protected final java.lang.String protocol
protected final java.lang.String userInfo
protected java.lang.String host
protected java.lang.String path
protected java.lang.String searchpart
protected java.lang.String anchor
protected int port
protected java.net.InetAddress hostAddress
protected Classification.ContentDomain contentDomain
private static final java.lang.String[] hex
private static final java.lang.String splitrex
public static final java.util.regex.Pattern splitpattern
public MultiProtocolURL()
public MultiProtocolURL(java.io.File file) throws java.net.MalformedURLException
java.net.MalformedURLException
protected MultiProtocolURL(MultiProtocolURL url)
public MultiProtocolURL(java.lang.String url) throws java.net.MalformedURLException
url
- '%' char url encoded beforejava.net.MalformedURLException
public MultiProtocolURL(MultiProtocolURL baseURL, java.lang.String relPath) throws java.net.MalformedURLException
java.net.MalformedURLException
public MultiProtocolURL(java.lang.String protocol, java.lang.String host, int port, java.lang.String path) throws java.net.MalformedURLException
java.net.MalformedURLException
public static final void initSessionIDNames(java.util.Set<java.lang.String> idNames)
public static java.lang.String toPunycode(java.lang.String host) throws Punycode.PunycodeException
Punycode.PunycodeException
public static final boolean isHTTP(java.lang.String s)
public static final boolean isHTTPS(java.lang.String s)
public static final boolean isFTP(java.lang.String s)
public static final boolean isFile(java.lang.String s)
public static final boolean isSMB(java.lang.String s)
public final boolean isHTTP()
public final boolean isHTTPS()
public final boolean isFTP()
public final boolean isFile()
public final boolean isSMB()
public final Classification.ContentDomain getContentDomainFromExt()
public static MultiProtocolURL newURL(java.lang.String baseURL, java.lang.String relPath) throws java.net.MalformedURLException
java.net.MalformedURLException
public static MultiProtocolURL newURL(MultiProtocolURL baseURL, java.lang.String relPath) throws java.net.MalformedURLException
java.net.MalformedURLException
private static final java.lang.String resolveBackpath(java.lang.String path)
private void escape()
escape(String)
private void escapePath()
private void escapeSearchpart()
public static java.lang.StringBuilder escape(java.lang.String s)
s
- The string to be encodedpublic static java.lang.String unescape(java.lang.String s)
private void identPort(java.lang.String inputURL, int dflt) throws java.net.MalformedURLException
java.net.MalformedURLException
private void identAnchor()
private void identSearchpart()
public java.lang.String getFile()
public java.lang.String getFile(boolean excludeAnchor, boolean removeSessionID)
excludeAnchor
- removeSessionID
- public java.lang.String getFileName()
public static java.lang.String getFileExtension(java.lang.String fileName)
fileName
- public java.lang.String getPath()
public java.lang.String[] getPaths()
public java.io.File getLocalFile()
public java.lang.String getAuthority()
public java.lang.String getHost()
public java.lang.String getOrganization()
public java.lang.String getTLD()
public java.net.InetAddress getInetAddress()
public int getPort()
public java.lang.String getProtocol()
public java.lang.String getRef()
public void removeRef()
public java.lang.String getUserInfo()
public java.lang.String getSearchpart()
public java.util.Map<java.lang.String,java.lang.String> getSearchpartMap()
getAttributes()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toTokens()
public static java.lang.String toTokens(java.lang.String s)
private static java.util.Set<java.lang.String> parseCamelCase(java.lang.String s)
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
getSearchpartMap()
private static MultiProtocolURL.CharType charType(char c)
public java.lang.String toNormalform(boolean excludeAnchor)
public java.lang.String toNormalform(boolean excludeAnchor, boolean removeSessionID)
public java.lang.String urlstub(boolean excludeAnchor, boolean removeSessionID)
excludeAnchor,
- exclude anchor partremoveSessionID,
- exclude session idtoNormalform(boolean)
,
toNormalform(boolean, boolean)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(MultiProtocolURL h)
compareTo
in interface java.lang.Comparable<MultiProtocolURL>
public boolean isPOST()
public static final boolean isCGI(java.lang.String extension)
@Deprecated public static final boolean isImage(java.lang.String extension)
public final boolean isIndividual()
public boolean isLocal()
public final java.lang.String language()
public java.net.URL getURL() throws java.net.MalformedURLException
java.net.MalformedURLException
public java.io.File getFSFile() throws java.net.MalformedURLException
java.net.MalformedURLException
public SmbFile getSmbFile() throws java.net.MalformedURLException
java.net.MalformedURLException
public boolean exists() throws java.io.IOException
java.io.IOException
public boolean canRead() throws java.io.IOException
java.io.IOException
public boolean canWrite() throws java.io.IOException
java.io.IOException
public boolean isHidden() throws java.io.IOException
java.io.IOException
public boolean isDirectory() throws java.io.IOException
java.io.IOException
public long length()
public long lastModified() throws java.io.IOException
java.io.IOException
public java.lang.String getName() throws java.io.IOException
java.io.IOException
public java.lang.String[] list() throws java.io.IOException
java.io.IOException
public java.io.InputStream getInputStream(ClientIdentification.Agent agent, java.lang.String username, java.lang.String pass) throws java.io.IOException
java.io.IOException
public byte[] get(ClientIdentification.Agent agent, java.lang.String username, java.lang.String pass) throws java.io.IOException
java.io.IOException
public static byte[] read(java.io.InputStream source) throws java.io.IOException
java.io.IOException
public java.util.Locale getLocale()
public static java.lang.String[] urlComps(java.lang.String normalizedURL)
public static void main(java.lang.String[] args)