Documentation of 'com.jstatcom.model.JSCInt' Java class
JSCInt
com.jstatcom.model

Class JSCInt

  • All Implemented Interfaces:
    JSCData


    public final class JSCInt
    extends AbstractJSCData
    An integer representation that conforms to the JSCData interface. Values are stored as Integer objects.

    Whenever the value of this data object changes, registered JSCDataListeners are notified via a JSCDataEvent. If not otherwise stated, the event objects always contain the values before the change and after the change.

    This class is thread-safe. All access to mutable data is synchronized. All events are fired outside the synchronized blocks.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static XmlFormat<JSCInt> JSCInt_XML
      XML format field for (de)serialization.
    • Constructor Summary

      Constructors 
      Constructor and Description
      JSCInt(java.lang.String name)
      Creates an empty JSCInt.
      JSCInt(java.lang.String name, boolean value)
      Creates a JSCInt from a boolean value.
      JSCInt(java.lang.String name, int value)
      Creates a JSCInt from an integer value.
      JSCInt(java.lang.String name, java.lang.Integer value)
      Creates a JSCInt from value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear()
      Clears this data object.
      JSCInt copy()
      Gets a copy of the current object.
      double doubleVal()
      Gets the stored integer as a double.
      java.lang.Integer getInt()
      Gets the stored Integer value.
      int intVal()
      Gets the stored integer.
      boolean isEmpty()
      Gets whether this is empty.
      boolean isEqual(JSCData o)
      Gets whether the values of this data object and other are logically equal.
      boolean isNonZero()
      Gets whether the stored value is not zero.
      java.lang.String name()
      Gets the name of the data object.
      void setInt(java.lang.Integer newValue)
      Sets the value of this to newValue and fires a JSCDataEvent of type: JSCDataEventTypes.VALUE_CHANGED if !newValue.equals(getNumber()) JSCDataEventTypes.EMPTY_STATE if newValue != null and this was empty before JSCDataEventTypes.EMPTY_STATE if newValue == null and this was not empty before
      void setVal(int newInt)
      Sets the value of this to newInt.
      JSCTypes type()
      Gets the type of this JSCData object.
      java.lang.Object value()
      Gets the underlying value, which is stored as a Double.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • JSCInt_XML

        public static final XmlFormat<JSCInt> JSCInt_XML
        XML format field for (de)serialization.
    • Constructor Detail

      • JSCInt

        public JSCInt(java.lang.String name)
        Creates an empty JSCInt.
        Parameters:
        name - the identifier of that object
        Throws:
        java.lang.IllegalArgumentException - if name is not valid or if (name == null)
        See Also:
        JSCConstants.isValidName(java.lang.String)
      • JSCInt

        public JSCInt(java.lang.String name,
                      int value)
        Creates a JSCInt from an integer value.
        Parameters:
        name - the identifier of that object
        value - the int to be used as value
        Throws:
        java.lang.IllegalArgumentException - if name is not valid or if (name == null)
        See Also:
        JSCConstants.isValidName(java.lang.String)
      • JSCInt

        public JSCInt(java.lang.String name,
                      boolean value)
        Creates a JSCInt from a boolean value.
        Parameters:
        name - the identifier of that object
        value - if true, set integer value to 1, if false set integer value to 0
        Throws:
        java.lang.IllegalArgumentException - if name is not valid or if (name == null)
        See Also:
        JSCConstants.isValidName(java.lang.String)
      • JSCInt

        public JSCInt(java.lang.String name,
                      java.lang.Integer value)
        Creates a JSCInt from value.
        Parameters:
        name - the identifier of that object
        value - the Integer to be used as value
        Throws:
        java.lang.IllegalArgumentException - if name is not valid or if (name == null)
        See Also:
        JSCConstants.isValidName(java.lang.String)
    • Method Detail

      • clear

        public void clear()
        Clears this data object. Fires:
        • JSCDataEventTypes.EMPTY_STATE event
        • JSCDataEventTypes.VALUE_CHANGED event
        if it was not empty before. After calling this method isEmpty returns true.
      • copy

        public JSCInt copy()
        Description copied from interface: JSCData
        Gets a copy of the current object. Implementations of this method must fulfil the two conditions:
        • a.isEqual(a.copy())- compares values
        • a.getName().equals(a.copy().getName())- compares name
        JSCDataListeners attached to the original object should not be copied.
        Returns:
        a clonelike copy of the original object
        See Also:
        JSCData
      • doubleVal

        public double doubleVal()
        Gets the stored integer as a double.
        Returns:
        the value as double
        Throws:
        java.lang.IllegalStateException - if object is empty
      • getInt

        public java.lang.Integer getInt()
        Gets the stored Integer value.
        Returns:
        a Integer or null if empty
      • intVal

        public int intVal()
        Gets the stored integer.
        Returns:
        the int values
        Throws:
        java.lang.IllegalStateException - if object is empty
      • isEmpty

        public boolean isEmpty()
        Gets whether this is empty. This method returns true, if value returns null.
        Returns:
        true if empty
      • isEqual

        public boolean isEqual(JSCData o)
        Description copied from interface: JSCData
        Gets whether the values of this data object and other are logically equal.
        Returns:
        true if considered equal according to the logic of the representation
        See Also:
        JSCData
      • name

        public java.lang.String name()
        Description copied from interface: JSCData
        Gets the name of the data object. It must fulfil the requirements for variable names defined in JSCConstants.
        Returns:
        the name
        See Also:
        JSCData
      • setInt

        public void setInt(java.lang.Integer newValue)
        Sets the value of this to newValue and fires a JSCDataEvent of type:
        • JSCDataEventTypes.VALUE_CHANGED if !newValue.equals(getNumber())
        • JSCDataEventTypes.EMPTY_STATE if newValue != null and this was empty before
        • JSCDataEventTypes.EMPTY_STATE if newValue == null and this was not empty before
        Parameters:
        newValue - the new value
      • setVal

        public void setVal(int newInt)
        Sets the value of this to newInt. Fires a JSCDataEvent of type:
        • JSCDataEventTypes.VALUE_CHANGED if the new value is not equal to the previous
        • JSCDataEventTypes.EMPTY_STATE if this was empty before
        Parameters:
        newInt - the new int
      • type

        public JSCTypes type()
        Gets the type of this JSCData object.
        Returns:
        JSCTypes.INT
        See Also:
        JSCTypes
      • value

        public java.lang.Object value()
        Gets the underlying value, which is stored as a Double.
        Returns:
        the value object or null if this is empty
      • isNonZero

        public boolean isNonZero()
        Gets whether the stored value is not zero.
        Returns:
        true if not equal to zero, false otherwise
        Throws:
        java.lang.IllegalStateException - if object is empty

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.