Top Description Fields Constructors Methods
net.fortuna.ical4j.util

public final Class Uris

extends Object
Class Inheritance
Imports
java.net.URI, .URISyntaxException, java.util.regex.Pattern

$Id$ Created on 11/09/2005 Utility methods for working with URIs.
Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
private static final Pattern
public static final String
INVALID_SCHEME

URI Scheme used when relaxed parsing is enabled and the given input stream lead to an invalid URI.

private static final Pattern

Constructor Summary

AccessConstructor and Description
private
Uris()

Constructor made private to enforce static nature.

Method Summary

Modifier and TypeMethod and Description
public static URI

Returns:

a URI instance, which may not correspond to the URI string if a valid URI string is not specified and relaxed parsing is enabled.
create
(final String
a string representation of a URI.
s
)

Attempts to create a URI instance and will optionally swallow any resulting URISyntaxException depending on configured CompatibilityHints.

public static String

Returns:

an encoded URI string
decode
(final String
a URI string
s
)

Decodes the specified URI string using the UTF-8 charset.

public static String

Returns:

an encoded URI string
encode
(final String
a URI string
s
)

Encodes the specified URI string using the UTF-8 charset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CID_PATTERNback to summary
private static final Pattern CID_PATTERN
INVALID_SCHEMEback to summary
public static final String INVALID_SCHEME

URI Scheme used when relaxed parsing is enabled and the given input stream lead to an invalid URI.

NOTES_CID_REPLACEMENT_PATTERNback to summary
private static final Pattern NOTES_CID_REPLACEMENT_PATTERN

Constructor Detail

Urisback to summary
private Uris()

Constructor made private to enforce static nature.

Method Detail

createback to summary
public static URI create(final String s) throws URISyntaxException

Attempts to create a URI instance and will optionally swallow any resulting URISyntaxException depending on configured CompatibilityHints. Will also automatically attempt encoding of the string representation for greater compatibility.

When relaxed parsing is enabled and if the string representation is not valid, a second URI creation attempt is made by extracting the scheme from the scheme specific part and URI encoding that later part. For example, "mailto: joe [email protected]" becomes "mailto:joe%[email protected]".

If the second attempts also leads to a URISyntaxException, an opaque URI is constructed with a scheme of Uris.INVALID_SCHEME and a value corresponding to the initial representation.

Parameters
s:String

a string representation of a URI.

Returns:URI

a URI instance, which may not correspond to the URI string if a valid URI string is not specified and relaxed parsing is enabled.

Exceptions
URISyntaxException:
if a valid URI string is not specified and relaxed parsing is disabled
decodeback to summary
public static String decode(final String s)

Decodes the specified URI string using the UTF-8 charset. In the event that an exception is thrown, the specifed URI string is returned unmodified.

Parameters
s:String

a URI string

Returns:String

an encoded URI string

encodeback to summary
public static String encode(final String s)

Encodes the specified URI string using the UTF-8 charset. In the event that an exception is thrown, the specifed URI string is returned unmodified.

Parameters
s:String

a URI string

Returns:String

an encoded URI string