Class SimpleCitation

Object
SimpleCitation
All Implemented Interfaces:
CharSequence, Comparable<InternationalString>, Citation, InternationalString

public class SimpleCitation extends Object implements Citation, InternationalString
A Citation containing only a title attribute as an InternationalString. All other citation attributes are null or empty collections.

This class can also be used as an InternationalString implementation. Because there is only one attribute - the title - there is no ambiguity about the value represented by the citation or the international string.

Since:
3.1
  • Field Details

  • Constructor Details

    • SimpleCitation

      public SimpleCitation(String title)
      Creates a new citation having the given title. The given string will be returned, directly or indirectly, by the getTitle(), toString() and toString(Locale) methods.
      Parameters:
      title - the citation title to be returned indirectly by getTitle().
  • Method Details

    • length

      public int length()
      Returns the number of characters in the title.
      Specified by:
      length in interface CharSequence
      Returns:
      the number of chars in the title.
    • charAt

      public char charAt(int index)
      Returns the title character at the given index
      Specified by:
      charAt in interface CharSequence
      Parameters:
      index - the index of the char value to be returned.
      Returns:
      the specified char value.
    • subSequence

      public String subSequence(int start, int end)
      Returns a substring of the title for the given range of index.
      Specified by:
      subSequence in interface CharSequence
      Parameters:
      start - the start index, inclusive.
      end - the end index, exclusive.
      Returns:
      the specified substring of the title.
    • toString

      public String toString()
      Returns the title as an unlocalized string. This method returns directly the string given to the constructor.
      Specified by:
      toString in interface CharSequence
      Specified by:
      toString in interface InternationalString
      Overrides:
      toString in class Object
      Returns:
      the string given to the constructor.
      See Also:
    • toString

      public String toString(Locale locale)
      Returns the title, ignoring the given locale. For localization support, another class (or a subclass of this SimpleCitation class) is required.
      Specified by:
      toString in interface InternationalString
      Parameters:
      locale - ignored by the SimpleCitation implementation.
      Returns:
      the string given to the constructor, localized if supported by the implementation.
      See Also:
    • getTitle

      public InternationalString getTitle()
      Description copied from interface: Citation
      Name by which the cited resource is known.
      Specified by:
      getTitle in interface Citation
      Returns:
      the cited resource name.
    • compareTo

      public int compareTo(InternationalString object)
      Compares the title with the string representation of the given object for order.
      Specified by:
      compareTo in interface Comparable<InternationalString>
      Parameters:
      object - the object to be compared.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
    • equals

      public boolean equals(Object object)
      Returns true if the given object is a SimpleCitation having a title equals to this title.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare with this SimpleCitation, or null.
      Returns:
      true if the given object is equal to this SimpleCitation.
    • hashCode

      public int hashCode()
      Returns a hash code value for this citation. The hash code is computed from the title string given to the constructor.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this citation.