About Milestones Me Mail Service Impressum Werner Diwischek
action4java logo




Different Things

Map

Here follows a short description of the map container. It implements something similar to the hashes of hashes.

Table of Contents

1. Directory like Map

JTreeMapString could be best seen as a directory for data. Its just the combination a simple flat hash which is structured by lists.

Its an easy way to store and accessing data in Java without the heck of modelling each table as an own class. Obviously the classical model approach make sense but it needs time, sometimes a lot of time. For a prototype or a quick solution JTreeMap could make life programming Java a bit easier.

I use JTreeMap as a base for the templating solution action4JAVA here. This wouldn't be possible in this small size and flexibility with a classical approach.

2.1 Simple Values

The setter methods has different input arguments. They can be set with a single string, HashMap with a locally defined pointer or

2.1.1 void insert(String dir, String key,T value)

Puts a single value in JTreeMap under the key. If parent directory does not exist an exception will be thrown.

2.1.2 void insert(String dir, String key ,T value, boolean force)

Puts a single value in JTreeMap under the key. If parent directory does not exist it will created if force is true otherwise an exception will be thrown.

2.1.3 String read(String key)

Gets the values stored in the map under a combination of the instance pointer and key.

2.1.4 String rm(String key)

Deletes a value defined by key.

2.2 HashMaps

Will store or get a complete Hashmap stored under the directory.

2.2.1 void insert(String dir,HashMap values)

Stores the hash under a directory. If the directory does not exist, an exception will be thrown.

2.2.2 void insert(String dir,HashMap values,boolean force)

Stores the hash values under a directory dir . If the directory does not exist, it will be created if force is true, else an exception will be thrown.

2.2.3 void insert(String dir,List values)

Stores the List under a directory with a number as key. If the directory does not exist, an exception will be thrown.

2.2.4 void readMap(String dir, boolean absoluteFlag)

Stores the List under a directory with a number as key. If the directory does not exist, an exception will be thrown.

2.3 Directories

This will create, remove or list the directory structure.

2.3.1 String pwd(String dir)

Returns the pointer of the map (actual directory)

2.3.2 void cd(String dir)

This will set the pointer to a certain directory. If its an absolute value, the value will be used directly, otherwise the value will added to the actual pointer.

2.3.3 mkdir(String dir)

Create a certain directory. Will not create it if parent directory does not exist.

2.3.4 mkdir(String dir,boolean force)

Create a certain directory. Will not create it if parent directory does not exist and boolean is false.

2.3.5 rmdir(String dir)

Remove a certain directory it its empty.

2.3.6 rmdir(String dir,boolean force)

Remove a certain directory with all values and subdirectories if boolean is true (force).

2.3.7 List ls()

Gets the list entries from the actual pointer.

2.3.8 List ls(String dir)

Gets the list entries of the directory relative.

2.3.9 List ls(String dir, boolean absoluteFlag)

Gets the list entries of the directory absolute if absolute flag is set, else relative paths.

2.5 Checks

Other methods described here

2.5.2 boolean is(String)

Is the pointer defined for a value or a list

2.5.3 boolean isListKey(String)

Checks if a key is set for a value.

2.5.4 boolean isValueKey(String)

Is the pointer defined for a value or a list

2.6 Other

Other methods described here

2.6.2 void format()

Remove all values from the directory.

2.6.3 void setForce(boolean force)

Set the default force instance value. Default is false.

3. JTreeMapString

This is a String implementation of the generic JTreeMap

3.1 void printValues(String dir)

Returns a sorted String of all values stored in the hash under the directory . Especially useful when debugging. The input value filter is for filter only values matching the pattern.

java duke with deers
created by Action4Java and JtreeMap (24.3.2013 22:57)
complexity is easy, simplicity not.