X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Futil%2FAbstractTrie.java;fp=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Futil%2FAbstractTrie.java;h=b49bec11e8a979eb792dc8aa82a608ea222eed41;hp=0000000000000000000000000000000000000000;hb=73ef54a38e3930a1a789cdc6b5fa23cdd4c9d086;hpb=515007c7c1351045420669d65b59c08fa46850f2 diff --git a/lib/jetty/org/eclipse/jetty/util/AbstractTrie.java b/lib/jetty/org/eclipse/jetty/util/AbstractTrie.java new file mode 100644 index 00000000..b49bec11 --- /dev/null +++ b/lib/jetty/org/eclipse/jetty/util/AbstractTrie.java @@ -0,0 +1,85 @@ +// +// ======================================================================== +// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.util; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + + +/* ------------------------------------------------------------ */ +/** Abstract Trie implementation. + *

Provides some common implementations, which may not be the most + * efficient. For byte operations, the assumption is made that the charset + * is ISO-8859-1

+ * @param + */ +public abstract class AbstractTrie implements Trie +{ + final boolean _caseInsensitive; + + protected AbstractTrie(boolean insensitive) + { + _caseInsensitive=insensitive; + } + + @Override + public boolean put(V v) + { + return put(v.toString(),v); + } + + @Override + public V remove(String s) + { + V o=get(s); + put(s,null); + return o; + } + + @Override + public V get(String s) + { + return get(s,0,s.length()); + } + + @Override + public V get(ByteBuffer b) + { + return get(b,0,b.remaining()); + } + + @Override + public V getBest(String s) + { + return getBest(s,0,s.length()); + } + + @Override + public V getBest(byte[] b, int offset, int len) + { + return getBest(new String(b,offset,len,StandardCharsets.ISO_8859_1)); + } + + @Override + public boolean isCaseInsensitive() + { + return _caseInsensitive; + } + +}