Hyperic HQ Plugin API v. 2.5.dev

net.hyperic.util.config
Class ConfigResponse

java.lang.Object
  extended bynet.hyperic.util.config.ConfigResponse
All Implemented Interfaces:
net.hyperic.util.GenericValueMap, java.io.Serializable

public class ConfigResponse
extends java.lang.Object
implements java.io.Serializable, net.hyperic.util.GenericValueMap

See Also:
Serialized Form

Field Summary
static byte[] EMPTY_CONFIG
          Empty, encoded ConfigResponse.
 
Constructor Summary
ConfigResponse()
          Create a ConfigResponse that will not be validated against any schema.
ConfigResponse(ConfigSchema schema)
          Create a ConfigResponse that will be validated against the specified schema.
ConfigResponse(java.util.Map attributes)
          Create a ConfigResponse that will not be validated against any schema.
 
Method Summary
static ConfigResponse decode(byte[] data)
          Decode a ConfigResponse from a byte array with no schema validation.
static ConfigResponse decode(ConfigSchema schema, byte[] data)
          Decode a ConfigResponse from a byte array according to the specified schema.
 byte[] encode()
           
 java.util.Set getKeys()
           
 java.lang.String getValue(java.lang.String key)
           
 java.lang.String getValue(java.lang.String key, java.lang.String defaultValue)
           
 void merge(ConfigResponse other, boolean overWrite)
          Merge the values from another ConfigResponse into this object.
static byte[] safeEncode(ConfigResponse cr)
           
 void setValue(java.lang.String key, java.lang.String value)
          Set the value for an option.
 int size()
           
 java.util.Properties toProperties()
          Clone the attribute set into a properties
 java.lang.String toString()
           
 void unsetValue(java.lang.String key)
          Set the value for an option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_CONFIG

public static final byte[] EMPTY_CONFIG
Empty, encoded ConfigResponse.

Constructor Detail

ConfigResponse

public ConfigResponse(ConfigSchema schema)
Create a ConfigResponse that will be validated against the specified schema. Any default values in the Schema will be set in the ConfigResponse

Parameters:
schema - The schema to validate option settings against. If this is null then no schema validation will be done, this is equivalent to using the no-argument constructor.

ConfigResponse

public ConfigResponse()
Create a ConfigResponse that will not be validated against any schema.


ConfigResponse

public ConfigResponse(java.util.Map attributes)
Create a ConfigResponse that will not be validated against any schema.

Parameters:
attributes - The config properties normally populated by setValue().
Method Detail

setValue

public void setValue(java.lang.String key,
                     java.lang.String value)
              throws InvalidOptionException,
                     InvalidOptionValueException
Set the value for an option.

Specified by:
setValue in interface net.hyperic.util.GenericValueMap
Parameters:
key - The name of the option to set
value - The value to set the option to.
Throws:
InvalidOptionException - If this ConfigResponse does not support the specified option.
InvalidOptionValueException - If the value supplied is not a legal/valid value for the option.

unsetValue

public void unsetValue(java.lang.String key)
                throws InvalidOptionException,
                       InvalidOptionValueException
Set the value for an option.

Parameters:
key - The name of the option to set
Throws:
InvalidOptionException - If this ConfigResponse does not support the specified option.
InvalidOptionValueException - If the value supplied is not a legal/valid value for the option.

getValue

public java.lang.String getValue(java.lang.String key)
Specified by:
getValue in interface net.hyperic.util.GenericValueMap

getValue

public java.lang.String getValue(java.lang.String key,
                                 java.lang.String defaultValue)

getKeys

public java.util.Set getKeys()
Specified by:
getKeys in interface net.hyperic.util.GenericValueMap

decode

public static ConfigResponse decode(byte[] data)
                             throws net.hyperic.util.config.EncodingException
Decode a ConfigResponse from a byte array with no schema validation.

Parameters:
data - The response data to decode.
Throws:
EncodingException - If the encoding is incorrect.

decode

public static ConfigResponse decode(ConfigSchema schema,
                                    byte[] data)
                             throws net.hyperic.util.config.EncodingException,
                                    InvalidOptionException,
                                    InvalidOptionValueException
Decode a ConfigResponse from a byte array according to the specified schema.

Parameters:
schema - The schema to validate against.
data - The response data to decode.
Throws:
EncodingException - If the encoding is incorrect.
InvalidOptionException - If the data specifies as option that is not valid for the given schema.
InvalidOptionValueException - If the data specifies an illegal/invalid value for one of the options it contains.

safeEncode

public static byte[] safeEncode(ConfigResponse cr)
                         throws net.hyperic.util.config.EncodingException
Returns:
the encoded config, or null if the ConfigResponse passed in is null. This is a handy method to avoid NPEs.
Throws:
net.hyperic.util.config.EncodingException

encode

public byte[] encode()
              throws net.hyperic.util.config.EncodingException
Throws:
net.hyperic.util.config.EncodingException

merge

public void merge(ConfigResponse other,
                  boolean overWrite)
Merge the values from another ConfigResponse into this object.

Parameters:
other - Other ConfigResponse to merge data from
overWrite - If true, values from the 'other' response will overwrite values with the same name in the object.

toProperties

public java.util.Properties toProperties()
Clone the attribute set into a properties


toString

public java.lang.String toString()

size

public int size()

Hyperic HQ Plugin API v. 2.5.dev

Copyright © 2004-2005 Hyperic LLC support@hyperic.net, All Rights Reserved.