2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.util;
21 import java.nio.ByteBuffer;
25 /* ------------------------------------------------------------ */
26 /** A Trie String lookup data structure.
29 public interface Trie<V>
31 /* ------------------------------------------------------------ */
32 /** Put and entry into the Trie
33 * @param s The key for the entry
34 * @param v The value of the entry
35 * @return True if the Trie had capacity to add the field.
37 public boolean put(String s, V v);
39 /* ------------------------------------------------------------ */
40 /** Put a value as both a key and a value.
41 * @param v The value and key
42 * @return True if the Trie had capacity to add the field.
44 public boolean put(V v);
46 /* ------------------------------------------------------------ */
47 public V remove(String s);
49 /* ------------------------------------------------------------ */
50 /** Get and exact match from a String key
53 public V get(String s);
55 /* ------------------------------------------------------------ */
56 /** Get and exact match from a String key
58 * @param offset The offset within the string of the key
59 * @param len the length of the key
61 public V get(String s,int offset,int len);
63 /* ------------------------------------------------------------ */
64 /** Get and exact match from a segment of a ByteBuufer as key
66 * @return The value or null if not found
68 public V get(ByteBuffer b);
70 /* ------------------------------------------------------------ */
71 /** Get and exact match from a segment of a ByteBuufer as key
73 * @param offset The offset within the buffer of the key
74 * @param len the length of the key
75 * @return The value or null if not found
77 public V get(ByteBuffer b,int offset,int len);
79 /* ------------------------------------------------------------ */
80 /** Get the best match from key in a String.
82 * @return The value or null if not found
84 public V getBest(String s);
86 /* ------------------------------------------------------------ */
87 /** Get the best match from key in a String.
89 * @param offset The offset within the string of the key
90 * @param len the length of the key
91 * @return The value or null if not found
93 public V getBest(String s,int offset,int len);
95 /* ------------------------------------------------------------ */
96 /** Get the best match from key in a byte array.
97 * The key is assumed to by ISO_8859_1 characters.
99 * @param offset The offset within the array of the key
100 * @param len the length of the key
101 * @return The value or null if not found
103 public V getBest(byte[] b,int offset,int len);
105 /* ------------------------------------------------------------ */
106 /** Get the best match from key in a byte buffer.
107 * The key is assumed to by ISO_8859_1 characters.
108 * @param b The buffer
109 * @param offset The offset within the buffer of the key
110 * @param len the length of the key
111 * @return The value or null if not found
113 public V getBest(ByteBuffer b,int offset,int len);
115 /* ------------------------------------------------------------ */
116 public Set<String> keySet();
118 /* ------------------------------------------------------------ */
119 public boolean isFull();
121 /* ------------------------------------------------------------ */
122 public boolean isCaseInsensitive();