Class URLParser
java.lang.Object
org.archive.url.URLParser
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]array of static Strings for all "known" schemesstatic final Patternstatic final charstatic final Stringstatic final StringDefault scheme to assume if unspecified.static final StringARC/WARC specific DNS resolution record.static final StringARC header record.static final StringFTPstatic final StringHTTPstatic final StringHTTPSstatic final StringMMSstatic final charstatic final PatternRFC 2396-inspired regex.static final StringRTSPstatic final Stringstatic final Stringgo brewsterstatic final StringWARC header record. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddDefaultSchemeIfNeeded(String urlString) static HandyURLstatic StringurlToScheme(String url) Attempt to find the scheme (http://, https://, etc) from a given URL.
-
Field Details
-
RFC2396REGEX
RFC 2396-inspired regex. From the RFC Appendix B:URI Generic Syntax August 1998 B. Parsing a URI Reference with a Regular Expression As described in Section 4.3, the generic URI syntax is not sufficient to disambiguate the components of some forms of URI. Since the "greedy algorithm" described in that section is identical to the disambiguation method used by POSIX regular expressions, it is natural and commonplace to use a regular expression for parsing the potential four components and fragment identifier of a URI reference. The following line is the regular expression for breaking-down a URI reference into its components. ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? 12 3 4 5 6 7 8 9 The numbers in the second line above are only to assist readability; they indicate the reference points for each subexpression (i.e., each paired parenthesis). We refer to the value matched for subexpression <n> as $<n>. For example, matching the above expression to http://www.ics.uci.edu/pub/ietf/uri/#Related results in the following subexpression matches: $1 = http: $2 = http $3 = //www.ics.uci.edu $4 = www.ics.uci.edu $5 = /pub/ietf/uri/ $6 = <undefined> $7 = <undefined> $8 = #Related $9 = Related where <undefined> indicates that the component is not present, as is the case for the query component in the above example. Therefore, we can determine the value of the four components and fragment as scheme = $2 authority = $4 path = $5 query = $7 fragment = $9
--Below differs from the rfc regex in that... (1) it has java escaping of regex characters (2) we allow a URI made of a fragment only (Added extra group so indexing is off by one after scheme). (3) scheme is limited to legal scheme characters
-
COMMERCIAL_AT
- See Also:
-
PERCENT_SIGN
public static final char PERCENT_SIGN- See Also:
-
COLON
public static final char COLON- See Also:
-
STRAY_SPACING
- See Also:
-
DNS_SCHEME
-
FILEDESC_SCHEME
-
WARCINFO_SCHEME
-
HTTP_SCHEME
-
HTTPS_SCHEME
-
FTP_SCHEME
-
MMS_SCHEME
-
RTSP_SCHEME
-
DEFAULT_SCHEME
Default scheme to assume if unspecified. No context implied...- See Also:
-
WAIS_SCHEME
-
ALL_SCHEMES
array of static Strings for all "known" schemes -
ALL_SCHEMES_PATTERN
-
-
Constructor Details
-
URLParser
public URLParser()
-
-
Method Details
-
urlToScheme
-
addDefaultSchemeIfNeeded
-
parse
- Throws:
URISyntaxException
-