Class StringLabel

    • Constructor Detail

      • StringLabel

        public StringLabel()
        Create a new StringLabel with a null content (i.e., str).
      • StringLabel

        public StringLabel​(String str)
        Create a new StringLabel with the given content.
        Parameters:
        str - The new label's content
      • StringLabel

        public StringLabel​(String str,
                           int beginPosition,
                           int endPosition)
        Create a new StringLabel with the given content.
        Parameters:
        str - The new label's content
        beginPosition - Start offset in original text
        endPosition - End offset in original text
      • StringLabel

        public StringLabel​(Label label)
        Create a new StringLabel with the value() of another label as its label.
        Parameters:
        label - The other label
    • Method Detail

      • value

        public String value()
        Return the word value of the label (or null if none).
        Specified by:
        value in interface Label
        Overrides:
        value in class ValueLabel
        Returns:
        String the word value for the label
      • setValue

        public void setValue​(String value)
        Set the value for the label.
        Specified by:
        setValue in interface Label
        Overrides:
        setValue in class ValueLabel
        Parameters:
        value - The value for the label
      • toString

        public String toString()
        Description copied from class: ValueLabel
        Return a string representation of the label. This will just be the value() if it is non-null, and the empty string otherwise.
        Specified by:
        toString in interface Label
        Overrides:
        toString in class ValueLabel
        Returns:
        The string representation
      • labelFactory

        public LabelFactory labelFactory()
        Return a factory for this kind of label (i.e., StringLabel). The factory returned is always the same one (a singleton).
        Specified by:
        labelFactory in interface Label
        Specified by:
        labelFactory in class ValueLabel
        Returns:
        The label factory
      • factory

        public static LabelFactory factory()
        Return a factory for this kind of label.
        Returns:
        The label factory
      • beginPosition

        public int beginPosition()
        Description copied from interface: HasOffset
        Return the beginning char offset of the label (or -1 if none). Note that these are currently measured in terms of UTF-16 char offsets, not codepoints, so that when non-BMP Unicode characters are present, such a character will add 2 to the position. On the other hand, these values will work with String#substring() and you can then calculate the number of codepoints in a substring.
        Specified by:
        beginPosition in interface HasOffset
        Returns:
        the beginning position for the label
      • endPosition

        public int endPosition()
        Description copied from interface: HasOffset
        Return the ending char offset of the label (or -1 if none). As usual in Java, this is the offset of the char after this token. Note that these are currently measured in terms of UTF-16 char offsets, not codepoints, so that when non-BMP Unicode characters are present, such a character will add 2 to the position. On the other hand, these values will work with String#substring() and you can then calculate the number of codepoints in a substring.
        Specified by:
        endPosition in interface HasOffset
        Returns:
        the end position for the label
      • setBeginPosition

        public void setBeginPosition​(int beginPosition)
        Description copied from interface: HasOffset
        Set the beginning character offset for the label. Setting this key to "-1" can be used to indicate no valid value.
        Specified by:
        setBeginPosition in interface HasOffset
        Parameters:
        beginPosition - The beginning position
      • setEndPosition

        public void setEndPosition​(int endPosition)
        Description copied from interface: HasOffset
        Set the ending character offset of the label (or -1 if none).
        Specified by:
        setEndPosition in interface HasOffset
        Parameters:
        endPosition - The end character offset for the label