Class Watch


  • public final class Watch
    extends Packet
    Represents the Watch packet type which is used in the watch methods in the Session classes.

    A Watch is responsible for sending variables and their values to the Console. These key/value pairs will be displayed in the Watches toolbox. If a Watch with the same name is sent twice, the old value is overwritten and the Watches toolbox displays the most current value.

    Note: This class is not guaranteed to be thread safe. However, instances of this class will normally only be used in the context of a single thread.

    • Constructor Detail

      • Watch

        public Watch()
        Overloaded. Creates and initializes a Watch instance.
      • Watch

        public Watch​(WatchType watchType)
        Overloaded. Creates and initializes a Watch instance with a custom watch type.

        If the watchType argument is a null reference a NullPointerException will be thrown.

        Parameters:
        watchType - The type of the new Watch describes the variable type (String, Integer and so on). Please see the WatchType enum for more information. Not allowed to be null
        Throws:
        NullPointerException - if the watchType argument is null
    • Method Detail

      • getSize

        public int getSize()
        Overridden. Returns the total occupied memory size of this Watch packet. The total occupied memory size of this Watch is the size of memory occupied by all strings and any internal data structures of this Watch.
        Specified by:
        getSize in class Packet
        Returns:
        The total occupied memory size of this Watch
      • getPacketType

        public PacketType getPacketType()
        Overridden. Returns PacketType.Watch.
        Specified by:
        getPacketType in class Packet
        Returns:
        PacketType.Watch. For a complete list of available packet types, please refer to the documentation of the PacketType enum
      • getName

        public String getName()
        Returns the name of this Watch.

        If a Watch with the same name is sent twice, the old value is overwritten and the Watches toolbox displays the most current value.

        This method can return null if this Watch does not contain a name. If this is the case, it will be empty in the SmartInspect Console.

        Returns:
        The name of this Watch or null if the name of this Watch has not been set
      • setName

        public void setName​(String name)
        Sets the name of this Watch.

        If a Watch with the same name is sent twice, the old value is overwritten and the Watches toolbox displays the most current value. The name of this Watch will be empty in the SmartInspect Console when this method gets a null reference as argument.

        Parameters:
        name - The new name of this Watch, can be null
      • getValue

        public String getValue()
        Returns the value of this Watch. The value of a Watch is always sent as String. To view the type of this variable Watch, please have a look at the getWatchType method. This method can return null if this Watch does not contain a value. If this is the case, it will be empty in the SmartInspect Console.
        Returns:
        The value of this Watch or null if the value of this Watch has not been set
      • setValue

        public void setValue​(String value)
        Sets the value of this Watch.

        The value of a Watch is always sent as String. To change the type of this variable Watch, please have a look at the setWatchType method.

        The value of this Watch will be empty in the SmartInspect Console when this method gets a null reference as argument.

        Parameters:
        value - The new value of this Watch, can be null
      • getWatchType

        public WatchType getWatchType()
        Returns the type of this Watch.
        Returns:
        The type of this Watch. It describes the variable type (String, Integer and so on). Please see the WatchType enum for more information.
      • setWatchType

        public void setWatchType​(WatchType watchType)
        Sets the type of this Watch.

        The type of this Watch describes the variable type (String, Integer and so on). Please see the WatchType enum for more information.

        If the watchType argument is a null reference a NullPointerException will be thrown.

        Parameters:
        watchType - The new type of this Watch. Not allowed to be null.
        Throws:
        NullPointerException - The watchType argument is null.
      • getTimestamp

        public long getTimestamp()
        Returns the timestamp of this Watch object.
        Returns:
        the creation time of this Watch object as returned by the SmartInspect.now() method
      • setTimestamp

        public void setTimestamp​(long timestamp)
        Sets the timestamp of this Watch object.
        Parameters:
        timestamp - The new timestamp of this Watch object. The passed value should represent the local date and time in microseconds since January 1, 1970. See SmartInspect.now() for more information