Package org.opencms.util
Class CmsUriSplitter
java.lang.Object
org.opencms.util.CmsUriSplitter
Splits an URI String into separate components.
An URI is splitted into a prefix, a anchor and a query part.
-
Constructor Summary
ConstructorsConstructorDescriptionCmsUriSplitter(String uri) Creates a splitted URI using the strict parsing mode.CmsUriSplitter(String uri, boolean strict) Creates a splitted URI using the given parsing mode. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the anchor part of the uri, for examplesomeanchor, ornullif no anchor is available.Returns the prefix part of the uri, for examplehttps://www.opencms.org/some/path/, ornullif no prefix is available.Returns the URI protocol, for examplehttporhttps.getQuery()Returns the query part of the uri, for examplea=binvalid input: '&c'=d, ornullif no query is available.Returns the suffix part of the uri, a combination of query and anchor, for example?a=binvalid input: '&c'=d#someanchor, or the empty String if no suffix is available.getUri()Returns the URI String passed to this URI splitter.inthashCode()booleanReturnstrueif the URI was parsed error free in 'strict' mode, or if the simple mode was used.static booleanisValidUri(String uri) Checks if the given URI is well formed.toURI()Returns an URI object created from the original input String.
-
Constructor Details
-
CmsUriSplitter
Creates a splitted URI using the strict parsing mode.- Parameters:
uri- the URI to split
-
CmsUriSplitter
Creates a splitted URI using the given parsing mode.Using 'strict' parsing mode, all requirements for an URI are checked. If 'strict' is set to
false, then only some simple parsing rules are applied, in which case the result may not be 100% valid (but still usable). If 'strict' parsing generates an error, then simple parsing is used as a fallback.- Parameters:
uri- the URI to splitstrict- iftrue, then 'strict' parsing mode is used, otherwise a relaxed URI parsing is done
-
-
Method Details
-
isValidUri
Checks if the given URI is well formed.- Parameters:
uri- the URI to check- Returns:
trueif the given URI is well formed
-
equals
-
getAnchor
Returns the anchor part of the uri, for examplesomeanchor, ornullif no anchor is available.- Returns:
- the anchor part of the uri
-
getPrefix
Returns the prefix part of the uri, for examplehttps://www.opencms.org/some/path/, ornullif no prefix is available.- Returns:
- the prefix part of the uri
-
getProtocol
Returns the URI protocol, for examplehttporhttps.- Returns:
- the URI protocol
-
getQuery
Returns the query part of the uri, for examplea=binvalid input: '&c'=d, ornullif no query is available.- Returns:
- the query part of the uri
-
getSuffix
Returns the suffix part of the uri, a combination of query and anchor, for example?a=binvalid input: '&c'=d#someanchor, or the empty String if no suffix is available.- Returns:
- the suffix part of the uri
-
getUri
Returns the URI String passed to this URI splitter.- Returns:
- the URI String passed to this URI splitter
-
hashCode
-
isErrorFree
Returnstrueif the URI was parsed error free in 'strict' mode, or if the simple mode was used.- Returns:
trueif the URI was parsed error free in 'strict' mode, or if the simple mode was used
-
toURI
Returns an URI object created from the original input String.This method will do a "best effort" to convert the original input String to a legal URI. Most notably, it will be able to handle original input Strings that contain a space " " and other usually illegal characters.
- Returns:
- an URI object created from the original input String
- Throws:
URISyntaxException- in case no URI object can be created from the original input String
-