annotate src/org/eclipse/jetty/io/BufferCache.java @ 843:9485ed9d1276

remove IPAddressMap
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 19 Sep 2016 14:37:21 -0600
parents 3ff59e08a1b7
children 74b9daf2826c
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) );
837
3ff59e08a1b7 fix last commit
Franklin Schmidt <fschmidt@gmail.com>
parents: 836
diff changeset
109 return key.regionMatches(0,floorKey,0,i) ? (CachedBuffer)floor.getValue() : key.regionMatches(0,ceilingKey,0,i) || i > 1 ? (CachedBuffer)ceiling.getValue() : null;
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
111 /*
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
112 Entry entry = _stringMap.getBestEntry(value, offset, maxLength);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
113 if (entry!=null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
114 return (CachedBuffer)entry.getValue();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
115 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
116 */
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
117 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
118
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 public Buffer lookup(String value)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 Buffer b= get(value);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 if (b == null)
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 return new CachedBuffer(value,-1);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
126 return b;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
127 }
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 public String toString(Buffer buffer)
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 return lookup(buffer).toString();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
133
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
134 public int getOrdinal(String value)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
135 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 CachedBuffer buffer = (CachedBuffer)_stringMap.get(value.toLowerCase());
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
137 return buffer==null?-1:buffer.getOrdinal();
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
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 public int getOrdinal(Buffer buffer)
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 if (buffer instanceof CachedBuffer)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 return ((CachedBuffer)buffer).getOrdinal();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 buffer=lookup(buffer);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 if (buffer!=null && 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 return -1;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 public static class CachedBuffer extends ByteArrayBuffer.CaseInsensitive
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 private final int _ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 private HashMap _associateMap=null;
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 public CachedBuffer(String value, int ordinal)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 super(value);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 _ordinal= ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
159 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
160
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 public int getOrdinal()
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
162 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
163 return _ordinal;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
165
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
166 public CachedBuffer getAssociate(Object key)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
168 if (_associateMap==null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 return null;
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
170 return (CachedBuffer)_associateMap.get(key);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
172
836
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
173 // TODO Replace Associate with a mime encoding specific solution
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 public void setAssociate(Object key, CachedBuffer associate)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
175 {
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 if (_associateMap==null)
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 _associateMap=new HashMap();
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 _associateMap.put(key,associate);
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180 }
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181
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 @Override
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184 public String toString()
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 return "CACHE["+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 "bufferMap="+_bufferMap+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 ",stringMap="+_stringMap+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 ",index="+_index+
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
190 "]";
e161dca40760 remove StringMap
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
192 }