Cumulus4j API
(1.2.0)

org.cumulus4j.keystore.prop
Class Property<T>

java.lang.Object
  extended by org.cumulus4j.keystore.prop.Property<T>
Type Parameters:
T - the type of the property-value.
All Implemented Interfaces:
Comparable<Property<?>>
Direct Known Subclasses:
Long2LongSortedMapProperty, LongProperty, StringProperty

public abstract class Property<T>
extends Object
implements Comparable<Property<?>>

Base class for all properties.

The KeyStore supports managing arbitrary properties in the form of name-value-pairs. The names are plain-text, but the values are encrypted. A property-value can be of any type for which a subclass of Property exists.

Important: Do not instantiate properties yourself! Use KeyStore.getProperty(String, char[], Class, String) instead!

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Constructor Summary
Property()
           
 
Method Summary
 int compareTo(Property<?> o)
           
 boolean equals(Object obj)
           
 String getName()
           Get the property's unique name.
 T getValue()
          Get the property's value.
abstract  byte[] getValueEncoded()
           Get the property's value encoded as byte-array or null, if the property is empty.
 UUID getXxx()
          Internal value used to detect improper usage of the API.
 int hashCode()
           
 void setName(String name)
           Set the property's unique name.
 void setValue(T value)
          Set the property's value.
abstract  void setValueEncoded(byte[] encodedValue)
           Set the property's value encoded as byte-array or null, if the property shall be empty.
 void setXxx(UUID xxx)
          Internal value used to detect improper usage of the API.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Property

public Property()
Method Detail

getName

public String getName()

Get the property's unique name.

This name is used as key to uniquely identify a property in the key store.

Returns:
the property's name.

setName

public void setName(String name)

Set the property's unique name.

You should never call this method directly. The name is set by KeyStore.getProperty(String, char[], Class, String).

Parameters:
name - the property's name.

getValue

public T getValue()
Get the property's value.

Returns:
the value or null.
See Also:
setValue(Object)

setValue

public void setValue(T value)
Set the property's value.

Parameters:
value - the value or null.
See Also:
getValue()

getValueEncoded

public abstract byte[] getValueEncoded()

Get the property's value encoded as byte-array or null, if the property is empty. Note, that this might be null, even though getValue() returns a non-null value; for example an empty Collection might cause this.

This method must encode the value in a way that can be decoded by setValueEncoded(byte[]).

Returns:
the byte-array-representation of the property-value or null.
See Also:
setValueEncoded(byte[])

setValueEncoded

public abstract void setValueEncoded(byte[] encodedValue)
                              throws IllegalArgumentException

Set the property's value encoded as byte-array or null, if the property shall be empty.

This method must be symmetric to getValueEncoded(), i.e. every possible result of getValueEncoded() must be understood by this method. A byte-array that is not understood should cause an IllegalArgumentException.

Parameters:
encodedValue - the byte-array-representation of the property-value or null.
Throws:
IllegalArgumentException - if the encodedValue cannot be parsed.
See Also:
getValueEncoded()

toString

public String toString()
Overrides:
toString in class Object

getXxx

public UUID getXxx()

Internal value used to detect improper usage of the API.

Important: This method is not part of the API! Do not use this method!

Returns:
the internal value.
See Also:
KeyStore.getProperty(String, char[], Class, String)

setXxx

public void setXxx(UUID xxx)

Internal value used to detect improper usage of the API.

Important: This method is not part of the API! Do not use this method!

Parameters:
xxx - the internal value.
See Also:
KeyStore.getProperty(String, char[], Class, String)

compareTo

public int compareTo(Property<?> o)
Specified by:
compareTo in interface Comparable<Property<?>>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Cumulus4j API
(1.2.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.