public class Properties extends Object implements Serializable, Cloneable, Encodable
Modifier and Type | Class and Description |
---|---|
private static class |
Properties.EmptyEnumerator
A hashtable enumerator class for empty hash tables, specializes
the general Enumerator
|
private static class |
Properties.Entry
Properties collision list.
|
private class |
Properties.Enumerator
A hashtable enumerator class.
|
Modifier and Type | Field and Description |
---|---|
private int |
count
The total number of entries in the hash table.
|
private static Properties.EmptyEnumerator |
emptyEnumerator |
private static int |
ENTRIES |
private static int |
KEYS |
private float |
loadFactor
The load factor for the hashtable.
|
private static org.objectweb.util.monolog.api.Logger |
logger |
private int |
modCount
The number of times this Properties has been structurally modified
Structural modifications are those that change the number of entries in
the Properties or otherwise modify its internal structure (e.g.,
rehash).
|
private Properties.Entry[] |
table
The hash table data.
|
private int |
threshold
The table is rehashed when its size exceeds this threshold.
|
private static int |
VALUES |
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
Constructor and Description |
---|
Properties()
Constructs a new, empty hashtable with a default initial capacity (11)
and load factor, which is 0.75.
|
Properties(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity
and default load factor, which is 0.75.
|
Properties(int initialCapacity,
float loadFactor)
Constructs a new, empty hashtable with the specified initial
capacity and the specified load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this hashtable so that it contains no keys.
|
Object |
clone()
Creates a shallow copy of this hashtable.
|
boolean |
containsKey(String key)
Tests if the specified object is a key in this hashtable.
|
void |
copyInto(Map h) |
void |
decode(Decoder decoder)
Decodes the content of this object
|
Enumeration |
elements()
Returns an enumeration of the values in this hashtable.
|
void |
encode(Encoder encoder)
Encodes the content of this object
|
Object |
get(String key)
Returns the value to which the specified key is mapped in this hashtable.
|
int |
getEncodableClassId()
Returns a unique class identifier.
|
int |
getEncodedSize()
Returns the size of the byte array that results
from the encoding of this object.
|
private Enumeration |
getEnumeration(int type) |
int |
hashCode()
Returns the hash code value for this Map as per the definition in the
Map interface.
|
private void |
initialize(int initialCapacity,
float loadFactor) |
boolean |
isEmpty()
Tests if this hashtable maps no keys to values.
|
Enumeration |
keys()
Returns an enumeration of the keys in this hashtable.
|
Object |
put(String key,
Object value)
Maps the specified
key to the specified value
in this hashtable. |
static Properties |
readFrom(InputStream is)
The object implements the readFrom method to restore its contents from
the input stream.
|
void |
readFrom(InputStream is,
int count) |
private void |
readObject(ObjectInputStream in) |
protected void |
rehash()
Increases the capacity of and internally reorganizes this
hashtable, in order to accommodate and access its entries more
efficiently.
|
Object |
remove(String key)
Removes the key (and its corresponding value) from this
hashtable.
|
Object |
setProperty(String key,
Object value)
Calls the method put.
|
int |
size()
Returns the number of keys in this hashtable.
|
String |
toString()
Returns a string representation of this Properties object
in the form of a set of entries, enclosed in braces and separated
by the ASCII characters ", " (comma and space).
|
private void |
writeObject(ObjectOutputStream out)
***** ***** ***** ***** ***** ***** *****
Serializable interface
***** ***** ***** ***** ***** ***** ***** *****
|
void |
writeTo(OutputStream os)
The object implements the writeTo method to write its contents to
the output stream.
|
private static org.objectweb.util.monolog.api.Logger logger
private transient int count
private transient Properties.Entry[] table
private transient int threshold
private transient float loadFactor
private transient int modCount
private static final int KEYS
private static final int VALUES
private static final int ENTRIES
private static Properties.EmptyEnumerator emptyEnumerator
public Properties(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity of the hashtable.loadFactor
- the load factor of the hashtable.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.public Properties(int initialCapacity)
initialCapacity
- the initial capacity of the hashtable.IllegalArgumentException
- if the initial capacity is less
than zero.public Properties()
private void initialize(int initialCapacity, float loadFactor)
public int size()
public boolean isEmpty()
true
if this hashtable maps no keys to values;
false
otherwise.public Enumeration keys()
Enumeration
,
elements()
public Enumeration elements()
Enumeration
,
Map
public boolean containsKey(String key)
key
- possible key.true
if and only if the specified object
is a key in this hashtable, as determined by the
equals method; false
otherwise.NullPointerException
- if the key is null
.public Object get(String key)
key
- a key in the hashtable.null
if the key is not mapped to any value in
this hashtable.NullPointerException
- if the key is null
.protected void rehash()
public Object setProperty(String key, Object value) throws ClassCastException
Provided to Enforce the use of primitive type for values. The value returned is the result of the call to put.
key
- the key to be placed into this property object.value
- the value corresponding to key.ClassCastException
public Object put(String key, Object value)
key
to the specified value
in this hashtable. Neither the key nor the value can be null
.
The value can be retrieved by calling the get
method with a
key that is equal to the original key.
Be careful only primitive type can be used as value, in the other case an
exception will be thrown at serialization.
key
- the hashtable key.value
- the value.null
if it did not have one.NullPointerException
- if the key or value is
null
.Object.equals(Object)
public Object remove(String key)
key
- the key that needs to be removed.null
if the key did not have a mapping.NullPointerException
- if the key is null
.public void clear()
public Object clone()
public String toString()
Overrides to toString method of Object.
private Enumeration getEnumeration(int type)
public int hashCode()
hashCode
in class Object
Map.hashCode()
public void copyInto(Map h)
public void writeTo(OutputStream os) throws IOException
os
- the stream to write the object toIOException
public static Properties readFrom(InputStream is) throws IOException
is
- the stream to read data from in order to restore the objectIOException
public void readFrom(InputStream is, int count) throws IOException
IOException
private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
ClassNotFoundException
IOException
public int getEncodedSize() throws IOException
Encodable
getEncodedSize
in interface Encodable
IOException
public int getEncodableClassId()
Encodable
getEncodableClassId
in interface Encodable
public void encode(Encoder encoder) throws Exception
Encodable
Copyright © 2016 ScalAgent D.T.. All Rights Reserved.