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;
22 import java.nio.charset.StandardCharsets;
25 /* ------------------------------------------------------------ */
26 /** Abstract Trie implementation.
27 * <p>Provides some common implementations, which may not be the most
28 * efficient. For byte operations, the assumption is made that the charset
32 public abstract class AbstractTrie<V> implements Trie<V>
34 final boolean _caseInsensitive;
36 protected AbstractTrie(boolean insensitive)
38 _caseInsensitive=insensitive;
42 public boolean put(V v)
44 return put(v.toString(),v);
48 public V remove(String s)
56 public V get(String s)
58 return get(s,0,s.length());
62 public V get(ByteBuffer b)
64 return get(b,0,b.remaining());
68 public V getBest(String s)
70 return getBest(s,0,s.length());
74 public V getBest(byte[] b, int offset, int len)
76 return getBest(new String(b,offset,len,StandardCharsets.ISO_8859_1));
80 public boolean isCaseInsensitive()
82 return _caseInsensitive;