de.mklinger.qetcher.client.jetty.util.AbstractTrie Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qetcher-client-bundle Show documentation
Show all versions of qetcher-client-bundle Show documentation
Qetcher Java client, OSGi bundle, minimal dependencies
//
// ========================================================================
// Copyright (c) 1995-2018 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 the type of object that the Trie holds
*/
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;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy