Mercurial Hosting > luan
annotate src/org/eclipse/jetty/io/View.java @ 1029:4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 00:55:20 -0600 |
parents | cf0367978d8b |
children | 80cad9086593 |
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 /** |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 * A View on another buffer. Allows operations that do not change the _content or |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 * indexes of the backing buffer. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 * |
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 */ |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
28 public final class View extends AbstractBuffer |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 { |
1025
cf0367978d8b
remove View.CaseInsensitive
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
30 private Buffer _buffer; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 |
1005 | 32 /** |
33 * @param buffer The <code>Buffer</code> on which we are presenting a <code>View</code>. | |
34 * @param mark The initial value of the {@link Buffer#markIndex mark index} | |
35 * @param get The initial value of the {@link Buffer#getIndex get index} | |
36 * @param put The initial value of the {@link Buffer#putIndex put index} | |
37 * @param access The access level - one of the constants from {@link Buffer}. | |
38 */ | |
39 public View(Buffer buffer, int mark, int get, int put,int access) | |
40 { | |
41 super(READWRITE,!buffer.isImmutable()); | |
42 _buffer=buffer.buffer(); | |
43 setPutIndex(put); | |
44 setGetIndex(get); | |
45 setMarkIndex(mark); | |
46 _access=access; | |
47 } | |
48 | |
49 public View(Buffer buffer) | |
50 { | |
51 super(READWRITE,!buffer.isImmutable()); | |
52 _buffer=buffer.buffer(); | |
53 setPutIndex(buffer.putIndex()); | |
54 setGetIndex(buffer.getIndex()); | |
55 setMarkIndex(buffer.markIndex()); | |
56 _access=buffer.isReadOnly()?READONLY:READWRITE; | |
57 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 |
1005 | 59 public View() |
60 { | |
61 super(READWRITE,true); | |
62 } | |
63 | |
64 /** | |
65 * Update view to buffer | |
66 */ | |
67 public void update(Buffer buffer) | |
68 { | |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
69 _access = READWRITE; |
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
70 _buffer = buffer.buffer(); |
1005 | 71 setGetIndex(0); |
72 setPutIndex(buffer.putIndex()); | |
73 setGetIndex(buffer.getIndex()); | |
74 setMarkIndex(buffer.markIndex()); | |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
75 _access = buffer.isReadOnly()?READONLY:READWRITE; |
1005 | 76 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
77 |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
78 @Override |
1005 | 79 public byte[] array() |
80 { | |
81 return _buffer.array(); | |
82 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
83 |
1005 | 84 @Override |
85 public Buffer buffer() | |
86 { | |
87 return _buffer.buffer(); | |
88 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
89 |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
90 @Override |
1005 | 91 public int capacity() |
92 { | |
93 return _buffer.capacity(); | |
94 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
95 |
1005 | 96 @Override |
97 public void clear() | |
98 { | |
99 setMarkIndex(-1); | |
100 setGetIndex(0); | |
101 setPutIndex(_buffer.getIndex()); | |
102 setGetIndex(_buffer.getIndex()); | |
103 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
104 |
1005 | 105 @Override |
106 public void compact() | |
107 { | |
108 // TODO | |
109 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
110 |
1005 | 111 /* |
112 * (non-Javadoc) | |
113 * | |
114 * @see java.lang.Object#equals(java.lang.Object) | |
115 */ | |
116 @Override | |
117 public boolean equals(Object obj) | |
118 { | |
119 return this==obj ||((obj instanceof Buffer)&& obj.equals(this)) || super.equals(obj); | |
120 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
121 |
1005 | 122 @Override |
123 public boolean isReadOnly() | |
124 { | |
125 return _buffer.isReadOnly(); | |
126 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
127 |
1005 | 128 @Override |
129 public boolean isVolatile() | |
130 { | |
131 return true; | |
132 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
133 |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
134 @Override |
1005 | 135 public byte peek(int index) |
136 { | |
137 return _buffer.peek(index); | |
138 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
139 |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
140 @Override |
1005 | 141 public int peek(int index, byte[] b, int offset, int length) |
142 { | |
143 return _buffer.peek(index,b,offset,length); | |
144 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
145 |
1005 | 146 @Override |
147 public Buffer peek(int index, int length) | |
148 { | |
149 return _buffer.peek(index, length); | |
150 } | |
151 | |
152 @Override | |
153 public int poke(int index, Buffer src) | |
154 { | |
155 return _buffer.poke(index,src); | |
156 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
157 |
1029
4e5e9e3c25b3
remove Buffer.equalsIgnoreCase()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1025
diff
changeset
|
158 @Override |
1005 | 159 public void poke(int index, byte b) |
160 { | |
161 _buffer.poke(index,b); | |
162 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
163 |
1005 | 164 @Override |
165 public int poke(int index, byte[] b, int offset, int length) | |
166 { | |
167 return _buffer.poke(index,b,offset,length); | |
168 } | |
169 | |
170 @Override | |
171 public String toString() | |
172 { | |
173 if (_buffer==null) | |
174 return "INVALID"; | |
175 return super.toString(); | |
176 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
177 } |