]> WPIA git - gigi.git/blob - lib/jetty/org/eclipse/jetty/util/Trie.java
updating jetty to jetty-9.2.16.v2016040
[gigi.git] / lib / jetty / org / eclipse / jetty / util / Trie.java
1 //
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.
8 //
9 //      The Eclipse Public License is available at
10 //      http://www.eclipse.org/legal/epl-v10.html
11 //
12 //      The Apache License v2.0 is available at
13 //      http://www.opensource.org/licenses/apache2.0.php
14 //
15 //  You may elect to redistribute this code under either of these licenses.
16 //  ========================================================================
17 //
18
19 package org.eclipse.jetty.util;
20
21 import java.nio.ByteBuffer;
22 import java.util.Set;
23
24
25 /* ------------------------------------------------------------ */
26 /** A Trie String lookup data structure.
27  * @param <V>
28  */
29 public interface Trie<V>
30 {
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.
36      */
37     public boolean put(String s, V v);
38     
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.
43      */
44     public boolean put(V v);
45
46     /* ------------------------------------------------------------ */
47     public V remove(String s);
48
49     /* ------------------------------------------------------------ */
50     /** Get and exact match from a String key
51      * @param s The key
52      */
53     public V get(String s);
54
55     /* ------------------------------------------------------------ */
56     /** Get and exact match from a String key
57      * @param s The key
58      * @param offset The offset within the string of the key
59      * @param len the length of the key
60      */
61     public V get(String s,int offset,int len);
62
63     /* ------------------------------------------------------------ */
64     /** Get and exact match from a segment of a ByteBuufer as key
65      * @param b The buffer
66      * @return The value or null if not found
67      */
68     public V get(ByteBuffer b);
69
70     /* ------------------------------------------------------------ */
71     /** Get and exact match from a segment of a ByteBuufer as key
72      * @param b The buffer
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
76      */
77     public V get(ByteBuffer b,int offset,int len);
78     
79     /* ------------------------------------------------------------ */
80     /** Get the best match from key in a String.
81      * @param s The string
82      * @return The value or null if not found
83      */
84     public V getBest(String s);
85     
86     /* ------------------------------------------------------------ */
87     /** Get the best match from key in a String.
88      * @param s The 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
92      */
93     public V getBest(String s,int offset,int len); 
94
95     /* ------------------------------------------------------------ */
96     /** Get the best match from key in a byte array.
97      * The key is assumed to by ISO_8859_1 characters.
98      * @param b The buffer
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
102      */
103     public V getBest(byte[] b,int offset,int len);
104
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
112      */
113     public V getBest(ByteBuffer b,int offset,int len);
114     
115     /* ------------------------------------------------------------ */
116     public Set<String> keySet();
117
118     /* ------------------------------------------------------------ */
119     public boolean isFull();
120
121     /* ------------------------------------------------------------ */
122     public boolean isCaseInsensitive();
123
124 }