Mercurial Hosting > luan
view src/org/eclipse/jetty/io/StringCache.java @ 1021:e350c11242be
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 31 Oct 2016 22:49:25 -0600 |
parents | 6be43ef1eb96 |
children | 3718afd99988 |
line wrap: on
line source
// to replace BufferCache package org.eclipse.jetty.io; import java.util.HashMap; import java.util.Map; import org.eclipse.jetty.util.StringUtil; public final class StringCache { private final Map<String,Integer> stringToOrdinal = new HashMap<String,Integer>(); // private final Map<Integer,String> ordinalToString = new HashMap<Integer,String>(); public byte[] add(String value, int ordinal) { stringToOrdinal.put(value.toLowerCase(), ordinal); // ordinalToString.put(ordinal, value); return StringUtil.getBytes(value); } public int getOrdinal(String value) { Integer i = stringToOrdinal.get(value.toLowerCase()); return i==null ? -1 : i; } public boolean contains(String value) { return stringToOrdinal.containsKey(value.toLowerCase()); } }