thredds.util
Class PathMatcher

java.lang.Object
  extended by thredds.util.PathMatcher

public class PathMatcher
extends java.lang.Object

A Collection of (String key, Object value) which is sorted on key. match( String path) returns the Object whose key is the longest that matches path. Match means that path.startsWith( key). Matching is thread-safe, as long as put() is no longer being called.


Constructor Summary
PathMatcher()
           
 
Method Summary
 java.lang.Object get(java.lang.String key)
          See if this object already exists in the collection, using equals().
 java.util.Iterator iterator()
          Get an iterator over the values, in sorted order.
static void main(java.lang.String[] args)
           
 java.lang.Object match(java.lang.String path)
          Find the longest match.
 void put(java.lang.String key, java.lang.Object value)
          Add an object to the collection to be searched by a String key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathMatcher

public PathMatcher()
Method Detail

put

public void put(java.lang.String key,
                java.lang.Object value)
Add an object to the collection to be searched by a String key.

Parameters:
key - sort key
value - add this object to the list to be searched.

get

public java.lang.Object get(java.lang.String key)
See if this object already exists in the collection, using equals().

Parameters:
key - find object that has this key
Returns:
existing object, else null.

iterator

public java.util.Iterator iterator()
Get an iterator over the values, in sorted order.

Returns:
iterator

match

public java.lang.Object match(java.lang.String path)
Find the longest match.

Parameters:
path - find object with longeth match where path.startsWith( key)
Returns:
the value whose key is the longest that matches path, or null if none

main

public static void main(java.lang.String[] args)