Class 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
    • 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.
        Returns:
        The new bookmark with the given parameter set to the given 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.
        Returns:
        The new bookmark with the given parameter removed.
        Throws:
        java.lang.NullPointerException - if the given name is null.
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.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 class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object