Jeff Miller

Team to Create Outside the Box

Java’s missing TreeMap

One thing I have always found lacking in Java collections/containers is TreeMap. A simple class that takes a hierarchical approach to mapping data to a node.  Given a hierarchical string like “/java/myapp/javafx/config/phone” I can set the various objects relative to this on that node.

Java Preferences() class supports this hierarchical approach but it is limited to native data types. I have never understood why this has been missing from the JRE.  So I created my own implementation and here it is for anyone else looking.

Here is the code to let you place any kind of object on a specified node.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.