chtdecoder.datastructures
Class AbstractCHTCode

java.lang.Object
  extended bychtdecoder.datastructures.AbstractCHTCode
All Implemented Interfaces:
CHTCode

public abstract class AbstractCHTCode
extends java.lang.Object
implements CHTCode

An abstract implementation of a CHTCode.

Version:
1.1, 09/14/04
Author:
John David Ratliff

Constructor Summary
AbstractCHTCode()
           
 
Method Summary
static CHTCode createCHTCode(java.lang.String name, int address, int value, boolean active)
          A factory method for creating CHTCode objects.
 int getAddress()
          Gets the address of this CHTCode.
 java.lang.String getName()
          Gets the name of this CHTCode.
 int getValue()
          Gets the value of this CHTCode.
 boolean isActive()
          Asks if this CHTCode is active (turned ON).
static CHTCode parseCHTCode(byte[] rawdata)
          Parses a 28-byte raw CHT bitstring into a CHTCode.
 void setActive(boolean active)
          Sets whether this CHTCode is active or not.
 void setAddress(int address)
          Sets the address of this CHTCode.
 void setName(java.lang.String name)
          Sets the name of this CHTCode (18 characters max).
 void setValue(int value)
          Sets the value of this CHTCode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCHTCode

public AbstractCHTCode()
Method Detail

createCHTCode

public static CHTCode createCHTCode(java.lang.String name,
                                    int address,
                                    int value,
                                    boolean active)
A factory method for creating CHTCode objects.

Parameters:
name - The name of the CHTCode.
address - The address of the CHTCode.
value - The value of the CHTCode.
active - Whether this code is active or not.
Returns:
Returns a CHTCode object.

parseCHTCode

public static CHTCode parseCHTCode(byte[] rawdata)
                            throws InvalidCHTCodeDataException
Parses a 28-byte raw CHT bitstring into a CHTCode.

Parameters:
rawdata - The raw CHT bitstring.
Returns:
The parsed CHTCode.
Throws:
InvalidCHTCodeDataException - if the rawdata isn't a valid raw CHT bitstring.

isActive

public boolean isActive()
Asks if this CHTCode is active (turned ON).

Specified by:
isActive in interface CHTCode
Returns:
true if this CHTCode is active; false otherwise.

setActive

public void setActive(boolean active)
Sets whether this CHTCode is active or not.

Specified by:
setActive in interface CHTCode
Parameters:
active - true for active (ON); false for inactive (OFF).

getAddress

public int getAddress()
Gets the address of this CHTCode.

Specified by:
getAddress in interface CHTCode
Returns:
The address.

setAddress

public void setAddress(int address)
                throws InvalidAddressException
Sets the address of this CHTCode.

Specified by:
setAddress in interface CHTCode
Parameters:
address - The address.
Throws:
InvalidAddressException - if the address is outside the range 0-16777215 (2^24 - 1).

getValue

public int getValue()
Gets the value of this CHTCode.

Specified by:
getValue in interface CHTCode
Returns:
The value.

setValue

public void setValue(int value)
              throws InvalidValueException
Sets the value of this CHTCode.

Specified by:
setValue in interface CHTCode
Parameters:
value - The value.
Throws:
InvalidValueException - if the value is outside the range 0-255 (2^8 - 1).

getName

public java.lang.String getName()
Gets the name of this CHTCode.

Specified by:
getName in interface CHTCode
Returns:
The name.

setName

public void setName(java.lang.String name)
             throws NameTooLongException
Sets the name of this CHTCode (18 characters max).

Specified by:
setName in interface CHTCode
Parameters:
name - The name.
Throws:
NameTooLongException - if the new name is longer than 18 characters.