public class DefaultDeviceInfo extends AbstractDeviceInfo
DeviceInfo
which will likely be
sufficient for most needs. A Properties
instance is used as the
backing store, with key/value pairs representing the data.Constructor and Description |
---|
DefaultDeviceInfo(DefaultDeviceType deviceType)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(String key)
Clears the property for the given key.
|
DeviceInfo |
evolve()
This method delegates to
DeviceType.evolve(com.hp.device.DeviceInfo) on the backing
device type, passing this instance as the context. |
String |
exportData()
Exports the contents of the device info into a string form.
|
String |
get(String key)
Returns the string value stored under the given key, or null if the key
does not exist.
|
String |
get(String key,
String defaultValue)
Returns the string value stored under the given key.
|
boolean |
getBoolean(String key)
Returns the boolean value stored under the given key, or null if the
key does not exist.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the boolean value stored under the given key.
|
int |
getGeneration()
Get the generation number of the device info.
|
int |
getInt(String key)
Returns the integer value stored under the given key, or null if the
key does not exist.
|
int |
getInt(String key,
int defaultValue)
Returns the string value stored under the given key.
|
long |
getLong(String key)
Returns the long value stored under the given key, or null if the
key does not exist.
|
long |
getLong(String key,
long defaultValue)
Returns the long value stored under the given key.
|
int |
getNodeCount(String key)
Returns the count of "subnodes" under the node for the given key.
|
boolean |
hasProperty(String key)
Gives an indication whether the property with the specified key is
present or not.
|
boolean |
importData(String data)
Imports the contents of the device info from the specified
export-encoded string.
|
void |
incrementGeneration()
Increments the generation number of the device info by 1.
|
Set<String> |
keys()
Returns the set of keys.
|
void |
set(String key,
boolean value)
Sets the given boolean value for the given key.
|
void |
set(String key,
int value)
Sets the given value for the given key.
|
void |
set(String key,
long value)
Sets the given value for the given key.
|
void |
set(String key,
String value)
Sets the given value for the given key.
|
String |
toDebugString()
Get the device info properties as an XML-encoded string.
|
String |
toString() |
getDeviceType, getFacet, getFacetClasses, getFacetClassNames, getType, getTypeName, isSupported, setDeviceType
public DefaultDeviceInfo(DefaultDeviceType deviceType)
deviceType
- the underlying (initial) device typepublic String toDebugString()
public DeviceInfo evolve()
DeviceType.evolve(com.hp.device.DeviceInfo)
on the backing
device type, passing this instance as the context.
It is the responsibility of the delegate to properly update the
generation number if the device type evolved. If the new instance is
also of DefaultDeviceInfo
class, this update should occur via
incrementGeneration()
.
public int getGeneration()
DeviceInfo
DeviceInfoProvider.create()
methods.public void incrementGeneration()
public String exportData()
This implementation produces an XML-encoded string of internal properties.
DeviceInfo.importData(String)
public boolean importData(String data)
There is no mandate to be able to import data exported from a device info of a different type.
This implementation loads the internal properties from the specified XML-encoded string.
data
- string previously encoded via DeviceInfo.exportData()
public boolean hasProperty(String key)
key
- the keypublic String get(String key)
key
- the keypublic String get(String key, String defaultValue)
key
- the keydefaultValue
- the default valuepublic int getInt(String key)
key
- the keypublic int getInt(String key, int defaultValue)
key
- the keydefaultValue
- the default valuepublic long getLong(String key)
key
- the keypublic long getLong(String key, long defaultValue)
key
- the keydefaultValue
- the default valuepublic boolean getBoolean(String key)
key
- the keypublic boolean getBoolean(String key, boolean defaultValue)
key
- the keydefaultValue
- the default valuepublic void set(String key, String value)
key
- the keyvalue
- the valuepublic void set(String key, int value)
key
- the keyvalue
- the valuepublic void set(String key, long value)
key
- the keyvalue
- the valuepublic void set(String key, boolean value)
key
- the keyvalue
- the valuepublic void clear(String key)
AbstractHierarchicalFileConfiguration.setProperty(String, Object)
key
- the keypublic int getNodeCount(String key)
key
- the keyCopyright © 2015. All Rights Reserved.