Class CodeItemImpl

  • All Implemented Interfaces:
    ICodeItem, java.lang.Cloneable

    public class CodeItemImpl
    extends java.lang.Object
    implements ICodeItem, java.lang.Cloneable
    The code item implementation.
    Author:
    Christopher Mindus
    • Field Summary

    • Constructor Summary

      Constructors 
      ConstructorDescription
      CodeItemImpl​(KString value)
      Constructor for an item without code.
      CodeItemImpl​(java.lang.String value)
      Constructor for an item without code.
      CodeItemImpl​(java.lang.String code, KString value)
      Constructor for an item with code and value.
      CodeItemImpl​(java.lang.String code, java.lang.String value)
      Constructor for an item with code and value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      CodeItemImplclone()
      Clones the instance.
      booleanequals​(java.lang.Object o)
      Checks for equality.
      java.lang.StringgetCode()
      Gets the code string.
      KStringgetKString()
      Gets the item text as a KString.
      java.lang.StringgetString()
      Gets the item text as a String.
      java.lang.ObjectgetValue()
      Gets the value.
      booleanhasCode()
      Checks if this item has a code.
      booleanisKString()
      Returns whether the item is a KString or not.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CodeItemImpl

        public CodeItemImpl​(java.lang.String value)
        Constructor for an item without code.
        Parameters:
        value - The item value, never null.
        Throws:
        java.lang.NullPointerException - If item value is null.
      • CodeItemImpl

        public CodeItemImpl​(java.lang.String code,
                            java.lang.String value)
        Constructor for an item with code and value.
        Parameters:
        code - The code, perhaps null for none.
        value - The item value, never null.
        Throws:
        java.lang.NullPointerException - If item value is null.
      • CodeItemImpl

        public CodeItemImpl​(KString value)
        Constructor for an item without code.
        Parameters:
        value - The item value, never null.
        Throws:
        java.lang.NullPointerException - If item value is null.
      • CodeItemImpl

        public CodeItemImpl​(java.lang.String code,
                            KString value)
        Constructor for an item with code and value.
        Parameters:
        code - The code, perhaps null for none.
        value - The item value, never null.
        Throws:
        java.lang.NullPointerException - If item value is null.
    • Method Detail

      • clone

        public CodeItemImpl clone()
        Clones the instance.
        Overrides:
        clone in class java.lang.Object
        Returns:
        The cloned instance if it contains a KString, otherwise "this" instance.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks for equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - Another object.
        Returns:
        true if equal, false otherwise.
      • hasCode

        public boolean hasCode()
        Checks if this item has a code.
        Specified by:
        hasCode in interface ICodeItem
        Returns:
        true if code is present, false otherwise.
      • isKString

        public boolean isKString()
        Returns whether the item is a KString or not.
        Specified by:
        isKString in interface ICodeItem
        Returns:
        true if item is a KString, false for String.
      • getCode

        public java.lang.String getCode()
        Gets the code string.
        Specified by:
        getCode in interface ICodeItem
        Returns:
        The optional code string, perhaps null for none.
      • getString

        public java.lang.String getString()
        Gets the item text as a String.
        Specified by:
        getString in interface ICodeItem
        Returns:
        The item String, potentially converted from KString.
      • getKString

        public KString getKString()
        Gets the item text as a KString.
        Specified by:
        getKString in interface ICodeItem
        Returns:
        The item KString, potentially converted from String.
      • getValue

        public java.lang.Object getValue()
        Gets the value.
        Specified by:
        getValue in interface ICodeItem
        Returns:
        Either a String or a KString.