com.guiseframework
Class Bookmark

java.lang.Object
  extended by com.guiseframework.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
static class Bookmark.Parameter
          A bookmark parameter name/value pair.
 
Constructor Summary
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
 java.lang.Object clone()
          Creates a shallow clone of this object.
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 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()
          Returns a string representation of the bookmark.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

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&parameter2Name=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 is null.
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 is null.

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 is null.
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 is null.

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.
Throws:
java.lang.NullPointerException - if the given name and/or value is null.

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.
Throws:
java.lang.NullPointerException - if the given name is null.

clone

public java.lang.Object clone()
Creates a shallow clone of this object.

Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for the object.

equals

public boolean equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one. This implementation returns whether the given object is a bookmark with the same ID and parameters.

Overrides:
equals in class java.lang.Object
Parameters:
object - The reference object with which to compare.
Returns:
true if this object is equivalent to the given object.

toString

public java.lang.String toString()
Returns a string representation of the bookmark. The string is suitable for use as a URI query, in the form "?parameter1Name=parameter1Value&parameter2Name=parameter2Value…". Each name and value will be percent-encoded as appropriate for URIs.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the bookmark suitable for use as a URI query.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.