com.darwinsys.util
Class PropertiesMap

java.lang.Object
  extended by com.darwinsys.util.PropertiesMap
All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.String>

public class PropertiesMap
extends java.lang.Object
implements java.util.Map<java.lang.String,java.lang.String>

PropertiesMap -- a Map that loads from a Properties file, but unlike Properties, preserves the ordering of the original file.

Written mainly as a demonstration of building a simple Map implementation from scratch, but useful when order matters and yet you want the convenience of Map acccess.

Version:
$Id: PropertiesMap.java,v 1.8 2006/04/20 20:03:00 ian Exp $
Author:
Ian F. Darwin

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
PropertiesMap()
           
 
Method Summary
 void clear()
          Discard all object references held in the collection, i.e., reset to its initial state.
 boolean containsKey(java.lang.Object obj)
          Return true if the given object is contained as a Key
 boolean containsValue(java.lang.Object obj)
          Return true if the given object is contained as a Value
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
          EntrySet (not implemented, returns null)
 java.lang.String get(java.lang.Object obj)
          Get a given object
 boolean isEmpty()
          Return true if the Map is empty
 java.util.Set<java.lang.String> keySet()
          Return the set of keys
 void load(java.lang.String fileName)
           
 java.lang.String put(java.lang.String n, java.lang.String v)
          Add a given object into this Map.
 void putAll(java.util.Map map)
          Merge all the values from another map into this map.
 java.lang.String remove(java.lang.Object obj)
          Remove a given object
 int size()
          Return the number of entries in the Map
 java.util.Collection<java.lang.String> values()
          Return a Collection containing the values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

PropertiesMap

public PropertiesMap()
Method Detail

load

public void load(java.lang.String fileName)
          throws java.io.IOException
Throws:
java.io.IOException

size

public int size()
Return the number of entries in the Map

Specified by:
size in interface java.util.Map<java.lang.String,java.lang.String>

isEmpty

public boolean isEmpty()
Return true if the Map is empty

Specified by:
isEmpty in interface java.util.Map<java.lang.String,java.lang.String>

containsKey

public boolean containsKey(java.lang.Object obj)
Return true if the given object is contained as a Key

Specified by:
containsKey in interface java.util.Map<java.lang.String,java.lang.String>

containsValue

public boolean containsValue(java.lang.Object obj)
Return true if the given object is contained as a Value

Specified by:
containsValue in interface java.util.Map<java.lang.String,java.lang.String>

get

public java.lang.String get(java.lang.Object obj)
Get a given object

Specified by:
get in interface java.util.Map<java.lang.String,java.lang.String>

put

public java.lang.String put(java.lang.String n,
                            java.lang.String v)
Add a given object into this Map.

Specified by:
put in interface java.util.Map<java.lang.String,java.lang.String>

remove

public java.lang.String remove(java.lang.Object obj)
Remove a given object

Specified by:
remove in interface java.util.Map<java.lang.String,java.lang.String>

putAll

public void putAll(java.util.Map map)
Merge all the values from another map into this map.

Specified by:
putAll in interface java.util.Map<java.lang.String,java.lang.String>

clear

public void clear()
Discard all object references held in the collection, i.e., reset to its initial state.

Specified by:
clear in interface java.util.Map<java.lang.String,java.lang.String>

keySet

public java.util.Set<java.lang.String> keySet()
Return the set of keys

Specified by:
keySet in interface java.util.Map<java.lang.String,java.lang.String>

values

public java.util.Collection<java.lang.String> values()
Return a Collection containing the values

Specified by:
values in interface java.util.Map<java.lang.String,java.lang.String>

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
EntrySet (not implemented, returns null)

Specified by:
entrySet in interface java.util.Map<java.lang.String,java.lang.String>


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.