Class Bookmark

java.lang.Object
io.guise.framework.Bookmark
All Implemented Interfaces:
Cloneable

public class Bookmark extends Object implements Cloneable
An identification of a saved state at a navigation point. The bookmark is relative to the navigation path.
Author:
Garret Wilson
  • Constructor Details

    • Bookmark

      public Bookmark(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:
      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(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:
      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:
      NullPointerException - if the given parameters array is null.
  • Method Details

    • getParameters

      public Set<Bookmark.Parameter> getParameters()
      Returns:
      A read-only set of parameters.
    • getParameterValue

      public String getParameterValue(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:
      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(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(String name, 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:
      NullPointerException - if the given name and/or value is null.
    • removeParameter

      public Bookmark removeParameter(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:
      NullPointerException - if the given name is null.
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)

      This implementation returns whether the given object is a bookmark with the same ID and parameters.

      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object