Package io.guise.framework
Class Bookmark
java.lang.Object
io.guise.framework.Bookmark
- All Implemented Interfaces:
Cloneable
An identification of a saved state at a navigation point. The bookmark is relative to the navigation path.
- Author:
- Garret Wilson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A bookmark parameter name/value pair. -
Constructor Summary
ConstructorDescriptionBookmark
(Bookmark.Parameter... parameters) Parameter array constructor.Bookmark
(CharSequence bookmark) String constructor.Bookmark
(List<Bookmark.Parameter> parameters) Parameter list constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
getParameterValue
(String parameterName) Returns the value associated with the first parameter of the given name.int
hashCode()
removeParameter
(String name) Creates a new bookmark with the given parameter removed.setParameter
(String name, String value) Creates a new bookmark with the given parameter set to the given value.protected void
setParameters
(Bookmark.Parameter... parameters) Sets bookmark parameters.protected void
setParameters
(List<Bookmark.Parameter> parameters) Sets bookmark parameters.toString()
-
Constructor Details
-
Bookmark
String constructor. The string must be suitable for use as a URI query, in the form "?parameter1Name=parameter1Value¶meter2Name=parameter2Value…". The parameter names and values should be percent-encoded as required for URIs. If there are parameters with duplicate names, only the first ones are used and the rest with the same name are ignored.- Parameters:
bookmark
- A string representation of the bookmark, beginning with '?'.- Throws:
NullPointerException
- if the given bookmark string isnull
.com.globalmentor.text.ArgumentSyntaxException
- if the bookmark does not begin with '?' or otherwise is not in the correct format.
-
Bookmark
Parameter list constructor. If there are parameters with duplicate names, only the first ones are used and the rest with the same name are ignored.- Parameters:
parameters
- The bookmark parameters.- Throws:
NullPointerException
- if the given parameters list isnull
.
-
Bookmark
Parameter array constructor. If there are parameters with duplicate names, only the first ones are used and the rest with the same name are ignored.- Parameters:
parameters
- The optional bookmark parameters.- Throws:
NullPointerException
- if the given parameters array isnull
.
-
-
Method Details
-
getParameters
- Returns:
- A read-only set of parameters.
-
getParameterValue
Returns the value associated with the first parameter of the given name.- Parameters:
parameterName
- The name of the parameter.- Returns:
- The value of the first parameter with the given name, or
null
if there is no parameter with the given name. - Throws:
NullPointerException
- if the given name isnull
.
-
setParameters
Sets bookmark parameters. If there are parameters with duplicate names, only the first ones are used and the rest with the same name are ignored. This method should only be called during constructor initialization.- Parameters:
parameters
- The optional bookmark parameters.
-
setParameters
Sets bookmark parameters. If there are parameters with duplicate names, only the first ones are used and the rest with the same name are ignored. This method should only be called during constructor initialization.- Parameters:
parameters
- The optional bookmark parameters.
-
setParameter
Creates a new bookmark with the given parameter set to the given value. If the named parameter does not exist, it will be added. If this bookmark already contains a parameter with the given value, this bookmark will be returned.- Parameters:
name
- The parameter name.value
- The parameter value.- Returns:
- The new bookmark with the given parameter set to the given value.
- Throws:
NullPointerException
- if the given name and/or value isnull
.
-
removeParameter
Creates a new bookmark with the given parameter removed. If this bookmark does not contains the given parameter, this bookmark will be returned.- Parameters:
name
- The parameter name.- Returns:
- The new bookmark with the given parameter removed.
- Throws:
NullPointerException
- if the given name isnull
.
-
clone
-
hashCode
public int hashCode() -
equals
This implementation returns whether the given object is a bookmark with the same ID and parameters.
-
toString
-