annotate src/org/eclipse/jetty/io/BufferCache.java @ 836:e161dca40760

remove StringMap
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 16 Sep 2016 12:35:17 -0600
parents 3428c60d7cfc
children 3ff59e08a1b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.io;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.util.ArrayList;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.util.HashMap;
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
23 import java.util.Map;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
24 import java.util.TreeMap;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 /* ------------------------------------------------------------------------------- */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 * Stores a collection of {@link Buffer} objects.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 * Buffers are stored in an ordered collection and can retreived by index or value
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 public class BufferCache
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 {
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
35 private final HashMap _bufferMap=new HashMap();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
36 private final TreeMap _stringMap = new TreeMap();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
37 private final ArrayList _index= new ArrayList();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
39 /* ------------------------------------------------------------------------------- */
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
40 /** Add a buffer to the cache at the specified index.
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
41 * @param value The content of the buffer.
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
42 */
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
43 public CachedBuffer add(String value, int ordinal)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
44 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
45 CachedBuffer buffer= new CachedBuffer(value, ordinal);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
46 _bufferMap.put(buffer, buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
47 _stringMap.put(value.toLowerCase(), buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
48 while ((ordinal - _index.size()) >= 0)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
49 _index.add(null);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
50 if (_index.get(ordinal)==null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
51 _index.add(ordinal, buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
52 return buffer;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
53 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
55 public CachedBuffer get(int ordinal)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
56 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
57 if (ordinal < 0 || ordinal >= _index.size())
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
58 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
59 return (CachedBuffer)_index.get(ordinal);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
60 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
62 public CachedBuffer get(Buffer buffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
63 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
64 return (CachedBuffer)_bufferMap.get(buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
65 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
67 public CachedBuffer get(String value)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
68 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
69 return (CachedBuffer)_stringMap.get(value.toLowerCase());
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
70 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
71
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
72 public Buffer lookup(Buffer buffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
73 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
74 if (buffer instanceof CachedBuffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
75 return buffer;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
76
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
77 Buffer b= get(buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
78 if (b == null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
79 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 if (buffer instanceof Buffer.CaseInsensitve)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
81 return buffer;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
82 return new ByteArrayBuffer.CaseInsensitive(buffer.asArray(),0,buffer.length(),Buffer.IMMUTABLE);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
83 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
84
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
85 return b;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 public CachedBuffer getBest(byte[] value, int offset, int maxLength)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 String key = new String(value,offset,maxLength).toLowerCase();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
91 CachedBuffer buffer = (CachedBuffer)_stringMap.get(key);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 if( buffer != null )
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 return buffer;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 Map.Entry floor = _stringMap.floorEntry(key);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
95 Map.Entry ceiling = _stringMap.ceilingEntry(key);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 if( floor==null ) {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
97 if( ceiling==null )
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
98 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
99 String ceilingKey = (String)ceiling.getKey();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
100 return key.charAt(0) == ceilingKey.charAt(0) ? (CachedBuffer)ceiling.getValue() : null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
101 } else {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 String floorKey = (String)floor.getKey();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
103 if( ceiling==null )
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
104 return key.charAt(0) == floorKey.charAt(0) ? (CachedBuffer)floor.getValue() : null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 String ceilingKey = (String)ceiling.getKey();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
106 int n = Math.min( key.length(), Math.min( floorKey.length(), ceilingKey.length() ) );
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
107 int i = 0;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
108 while( ++i <= n && key.regionMatches(0,floorKey,0,i) && key.regionMatches(0,ceilingKey,0,i) );
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
109 i--;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 if( i==0 )
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
111 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
112 return i==0 ? null : key.regionMatches(0,floorKey,0,i) ? (CachedBuffer)floor.getValue() : (CachedBuffer)ceiling.getValue();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
113 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
114 /*
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
115 Entry entry = _stringMap.getBestEntry(value, offset, maxLength);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
116 if (entry!=null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
117 return (CachedBuffer)entry.getValue();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
118 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 */
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
121
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 public Buffer lookup(String value)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
124 Buffer b= get(value);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 if (b == null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
126 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
127 return new CachedBuffer(value,-1);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
128 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
129 return b;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
131
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 public String toString(Buffer buffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
133 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
134 return lookup(buffer).toString();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
135 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
136
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
137 public int getOrdinal(String value)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 CachedBuffer buffer = (CachedBuffer)_stringMap.get(value.toLowerCase());
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 return buffer==null?-1:buffer.getOrdinal();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
141 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
142
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 public int getOrdinal(Buffer buffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 if (buffer instanceof CachedBuffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
146 return ((CachedBuffer)buffer).getOrdinal();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
147 buffer=lookup(buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 if (buffer!=null && buffer instanceof CachedBuffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 return ((CachedBuffer)buffer).getOrdinal();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 return -1;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
151 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
152
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 public static class CachedBuffer extends ByteArrayBuffer.CaseInsensitive
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 private final int _ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 private HashMap _associateMap=null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 public CachedBuffer(String value, int ordinal)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
159 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 super(value);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 _ordinal= ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
162 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
163
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 public int getOrdinal()
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
165 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
166 return _ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
168
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 public CachedBuffer getAssociate(Object key)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
170 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 if (_associateMap==null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
172 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
173 return (CachedBuffer)_associateMap.get(key);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
175
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 // TODO Replace Associate with a mime encoding specific solution
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 public void setAssociate(Object key, CachedBuffer associate)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 if (_associateMap==null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180 _associateMap=new HashMap();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181 _associateMap.put(key,associate);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
182 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
183 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
185
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 @Override
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 public String toString()
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 return "CACHE["+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
190 "bufferMap="+_bufferMap+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 ",stringMap="+_stringMap+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
192 ",index="+_index+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
193 "]";
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
194 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
195 }