Package io.guise.framework
Class Bookmark
- java.lang.Object
-
- io.guise.framework.Bookmark
-
- All Implemented Interfaces:
java.lang.Cloneable
public class Bookmark extends java.lang.Object implements java.lang.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
Nested Classes Modifier and Type Class Description static class
Bookmark.Parameter
A bookmark parameter name/value pair.
-
Constructor Summary
Constructors Constructor Description Bookmark(Bookmark.Parameter... parameters)
Parameter array constructor.Bookmark(java.lang.CharSequence bookmark)
String constructor.Bookmark(java.util.List<Bookmark.Parameter> parameters)
Parameter list constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
boolean
equals(java.lang.Object object)
java.util.Set<Bookmark.Parameter>
getParameters()
java.lang.String
getParameterValue(java.lang.String parameterName)
Returns the value associated with the first parameter of the given name.int
hashCode()
Bookmark
removeParameter(java.lang.String name)
Creates a new bookmark with the given parameter removed.Bookmark
setParameter(java.lang.String name, java.lang.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(java.util.List<Bookmark.Parameter> parameters)
Sets bookmark parameters.java.lang.String
toString()
-
-
-
Constructor Detail
-
Bookmark
public Bookmark(java.lang.CharSequence bookmark) throws com.globalmentor.text.ArgumentSyntaxException
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:
java.lang.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
public Bookmark(java.util.List<Bookmark.Parameter> parameters)
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:
java.lang.NullPointerException
- if the given parameters list isnull
.
-
Bookmark
public Bookmark(Bookmark.Parameter... parameters)
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:
java.lang.NullPointerException
- if the given parameters array isnull
.
-
-
Method Detail
-
getParameters
public java.util.Set<Bookmark.Parameter> getParameters()
- Returns:
- A read-only set of parameters.
-
getParameterValue
public java.lang.String getParameterValue(java.lang.String parameterName)
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:
java.lang.NullPointerException
- if the given name isnull
.
-
setParameters
protected void setParameters(Bookmark.Parameter... parameters)
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
protected void setParameters(java.util.List<Bookmark.Parameter> parameters)
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
public Bookmark setParameter(java.lang.String name, java.lang.String value)
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:
java.lang.NullPointerException
- if the given name and/or value isnull
.
-
removeParameter
public Bookmark removeParameter(java.lang.String name)
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:
java.lang.NullPointerException
- if the given name isnull
.
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
This implementation returns whether the given object is a bookmark with the same ID and parameters.
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-