All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.owasp.esapi.codecs.Trie Maven / Gradle / Ivy

Go to download

The Enterprise Security API (ESAPI) project is an OWASP project to create simple strong security controls for every web platform. Security controls are not simple to build. You can read about the hundreds of pitfalls for unwary developers on the OWASP website. By providing developers with a set of strong controls, we aim to eliminate some of the complexity of creating secure web applications. This can result in significant cost savings across the SDLC.

There is a newer version: 2.5.5.0
Show newest version
package org.owasp.esapi.codecs;

import java.io.IOException;
import java.io.PushbackReader;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

public interface Trie extends Map
{
	public Map.Entry getLongestMatch(CharSequence key);
	public Map.Entry getLongestMatch(PushbackReader keyIn) throws IOException;
	public int getMaxKeyLength();

	static class TrieProxy implements Trie
	{
		private Trie wrapped;

		TrieProxy(Trie toWrap)
		{
			wrapped = toWrap;
		}

		protected Trie getWrapped()
		{
			return wrapped;
		}

		public Map.Entry getLongestMatch(CharSequence key)
		{
			return wrapped.getLongestMatch(key);
		}

		public Map.Entry getLongestMatch(PushbackReader keyIn) throws IOException
		{
			return wrapped.getLongestMatch(keyIn);
		}

		public int getMaxKeyLength()
		{
			return wrapped.getMaxKeyLength();
		}

		/* java.util.Map: */

    		public int size()
		{
			return wrapped.size();
		}

    		public boolean isEmpty()
		{
			return wrapped.isEmpty();
		}

    		public boolean containsKey(Object key)
		{
			return wrapped.containsKey(key);
		}

    		public boolean containsValue(Object val)
		{
			return wrapped.containsValue(val);
		}

    		public T get(Object key)
		{
			return wrapped.get(key);
		}

    		public T put(CharSequence key, T value)
		{
			return wrapped.put(key, value);
		}

    		public T remove(Object key)
		{
			return wrapped.remove(key);
		}

    		public void putAll(Map t)
		{
			wrapped.putAll(t);
		}

    		public void clear()
		{
			wrapped.clear();
		}

    		public Set keySet()
		{
			return wrapped.keySet();
		}

    		public Collection values()
		{
			return wrapped.values();
		}

    		public Set> entrySet()
		{
			return wrapped.entrySet();
		}

    		public boolean equals(Object other)
		{
			return wrapped.equals(other);
		}

    		public int hashCode()
		{
			return wrapped.hashCode();
		}
	}

	static class Unmodifiable extends TrieProxy
	{
		Unmodifiable(Trie toWrap)
		{
			super(toWrap);
		}

    		public T put(CharSequence key, T value)
		{
			throw new UnsupportedOperationException("Unmodifiable Trie");
		}

    		public T remove(CharSequence key)
		{
			throw new UnsupportedOperationException("Unmodifiable Trie");
		}

    		public void putAll(Map t)
		{
			throw new UnsupportedOperationException("Unmodifiable Trie");
		}

    		public void clear()
		{
			throw new UnsupportedOperationException("Unmodifiable Trie");
		}

    		public Set keySet()
		{
			return Collections.unmodifiableSet(super.keySet());
		}

    		public Collection values()
		{
			return Collections.unmodifiableCollection(super.values());
		}

    		public Set> entrySet()
		{
			return Collections.unmodifiableSet(super.entrySet());
		}
	}

	public static class Util
	{
		private Util()
		{
		}

		static  Trie unmodifiable(Trie toWrap)
		{
			return new Unmodifiable(toWrap);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy