Class Properties

    • Field Detail

      • count

        private transient int count
        The total number of entries in the hash table.
      • threshold

        private transient int threshold
        The table is rehashed when its size exceeds this threshold. (The value of this field is (int)(capacity * loadFactor).)
      • loadFactor

        private transient float loadFactor
        The load factor for the hashtable.
    • Constructor Detail

      • Properties

        public Properties​(int initialCapacity,
                          float loadFactor)
        Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
        Parameters:
        initialCapacity - the initial capacity of the hashtable.
        loadFactor - the load factor of the hashtable.
        Throws:
        IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
      • Properties

        public Properties​(int initialCapacity)
        Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75.
        Parameters:
        initialCapacity - the initial capacity of the hashtable.
        Throws:
        IllegalArgumentException - if the initial capacity is less than zero.
      • Properties

        public Properties()
        Constructs a new, empty hashtable with a default initial capacity (11) and load factor, which is 0.75.
    • Method Detail

      • initialize

        private void initialize​(int initialCapacity,
                                float loadFactor)
      • size

        public int size()
        Returns the number of keys in this hashtable.
        Returns:
        the number of keys in this hashtable.
      • isEmpty

        public boolean isEmpty()
        Tests if this hashtable maps no keys to values.
        Returns:
        true if this hashtable maps no keys to values; false otherwise.
      • keys

        public Enumeration keys()
        Returns an enumeration of the keys in this hashtable.
        Returns:
        an enumeration of the keys in this hashtable.
        See Also:
        Enumeration, elements()
      • elements

        public Enumeration elements()
        Returns an enumeration of the values in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.
        Returns:
        an enumeration of the values in this hashtable.
        See Also:
        Enumeration, Map
      • containsKey

        public boolean containsKey​(String key)
        Tests if the specified object is a key in this hashtable.
        Parameters:
        key - possible key.
        Returns:
        true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.
        Throws:
        NullPointerException - if the key is null.
      • get

        public Object get​(String key)
        Returns the value to which the specified key is mapped in this hashtable.
        Parameters:
        key - a key in the hashtable.
        Returns:
        the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.
        Throws:
        NullPointerException - if the key is null.
      • rehash

        protected void rehash()
        Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.
      • setProperty

        public Object setProperty​(String key,
                                  Object value)
                           throws ClassCastException
        Calls the method put.

        Provided to Enforce the use of primitive type for values. The value returned is the result of the call to put.

        Parameters:
        key - the key to be placed into this property object.
        value - the value corresponding to key.
        Returns:
        the previous value of the specified key in this property object, or null if it did not have one.
        Throws:
        ClassCastException
      • put

        public Object put​(String key,
                          Object value)
        Maps the specified 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.

        Parameters:
        key - the hashtable key.
        value - the value.
        Returns:
        the previous value of the specified key in this hashtable, or null if it did not have one.
        Throws:
        NullPointerException - if the key or value is null.
        See Also:
        Object.equals(Object)
      • remove

        public Object remove​(String key)
        Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.
        Parameters:
        key - the key that needs to be removed.
        Returns:
        the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.
        Throws:
        NullPointerException - if the key is null.
      • clear

        public void clear()
        Clears this hashtable so that it contains no keys.
      • clone

        public Object clone()
        Creates a shallow copy of this hashtable. All the structure of the hashtable itself is copied, but the keys and values are not cloned. This is a relatively expensive operation.
        Overrides:
        clone in class Object
        Returns:
        a clone of the hashtable.
      • toString

        public 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). Each entry is rendered as the key, an equals sign =, and the associated element, where the toString method is used to convert the key and element to strings.

        Overrides to toString method of Object.

        Overrides:
        toString in class Object
        Returns:
        a string representation of this hashtable.
      • getEnumeration

        private Enumeration getEnumeration​(int type)
      • hashCode

        public int hashCode()
        Returns the hash code value for this Map as per the definition in the Map interface.
        Overrides:
        hashCode in class Object
        Since:
        1.2
        See Also:
        Map.hashCode()
      • copyInto

        public void copyInto​(Map h)
      • writeTo

        public void writeTo​(OutputStream os)
                     throws IOException
        The object implements the writeTo method to write its contents to the output stream.
        Parameters:
        os - the stream to write the object to.
        Throws:
        IOException - an error occurs during writing.
      • readFrom

        public static Properties readFrom​(InputStream is)
                                   throws IOException
        The object implements the readFrom method to restore its contents from the input stream.
        Parameters:
        is - the stream to read data from in order to restore the object
        Returns:
        the properties object read.
        Throws:
        IOException - an error occurs during writing.
      • getEncodedSize

        public int getEncodedSize()
                           throws IOException
        Description copied from interface: Encodable
        Returns the size of the byte array that results from the encoding of this object.
        Specified by:
        getEncodedSize in interface Encodable
        Returns:
        the size of the encoded byte array
        Throws:
        IOException
      • getEncodableClassId

        public int getEncodableClassId()
        Description copied from interface: Encodable
        Returns a unique class identifier.
        Specified by:
        getEncodableClassId in interface Encodable
        Returns:
        a unique class identifier
      • encode

        public void encode​(Encoder encoder)
                    throws Exception
        Description copied from interface: Encodable
        Encodes the content of this object
        Specified by:
        encode in interface Encodable
        Parameters:
        encoder - the encoder to be used for the encoding
        Throws:
        Exception - if an error occurs
      • decode

        public void decode​(Decoder decoder)
                    throws Exception
        Description copied from interface: Encodable
        Decodes the content of this object
        Specified by:
        decode in interface Encodable
        Parameters:
        decoder - the decoder to be used for the decoding
        Throws:
        Exception - if an error occurs