View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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       * @return
53       */
54      public V get(String s);
55      
56      /* ------------------------------------------------------------ */
57      /** Get and exact match from a segment of a ByteBuufer as key
58       * @param b The buffer
59       * @param offset The offset within the buffer of the key
60       * @param len the length of the key
61       * @return The value or null if not found
62       */
63      public V get(ByteBuffer b,int offset,int len);
64  
65      /* ------------------------------------------------------------ */
66      /** Get the best match from key in a byte array.
67       * The key is assumed to by ISO_8859_1 characters.
68       * @param b The buffer
69       * @param offset The offset within the array of the key
70       * @param len the length of the key
71       * @return The value or null if not found
72       */
73      public V getBest(byte[] b,int offset,int len);
74  
75      /* ------------------------------------------------------------ */
76      /** Get the best match from key in a byte buffer.
77       * The key is assumed to by ISO_8859_1 characters.
78       * @param b The buffer
79       * @param offset The offset within the buffer of the key
80       * @param len the length of the key
81       * @return The value or null if not found
82       */
83      public V getBest(ByteBuffer b,int offset,int len);
84  
85      /* ------------------------------------------------------------ */
86      public Set<String> keySet();
87      
88      public boolean isFull();
89      
90  }