root / trunk / libraries / libArcIMS / src / org / gvsig / remoteClient / arcims / utils / ArcImsReader.java @ 8109
History | View | Annotate | Download (2.9 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*/
|
43 |
|
44 |
package org.gvsig.remoteClient.arcims.utils; |
45 |
|
46 |
import java.io.IOException; |
47 |
import java.io.InputStream; |
48 |
import java.io.InputStreamReader; |
49 |
|
50 |
|
51 |
public class ArcImsReader extends InputStreamReader { |
52 |
private char codigoB; |
53 |
private char codigoM; |
54 |
|
55 |
public ArcImsReader(InputStream in, char codigoB, char codigoM) { |
56 |
super(in);
|
57 |
this.codigoB = codigoB;
|
58 |
this.codigoM = codigoM;
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* Read a single character.
|
63 |
*
|
64 |
* @return The character read, or -1 if the end of the stream has been
|
65 |
* reached
|
66 |
*
|
67 |
* @exception IOException If an I/O error occurs
|
68 |
*/
|
69 |
public int read() throws IOException { |
70 |
int sup = super.read(); |
71 |
|
72 |
if (sup == (int) codigoM) { |
73 |
return (int) codigoB; |
74 |
} else {
|
75 |
return sup;
|
76 |
} |
77 |
} |
78 |
|
79 |
/**
|
80 |
* Read characters into a portion of an array.
|
81 |
*
|
82 |
* @param cbuf Destination buffer
|
83 |
* @param offset Offset at which to start storing characters
|
84 |
* @param length Maximum number of characters to read
|
85 |
*
|
86 |
* @return The number of characters read, or -1 if the end of the
|
87 |
* stream has been reached
|
88 |
*
|
89 |
* @exception IOException If an I/O error occurs
|
90 |
*/
|
91 |
public int read(char[] cbuf, int off, int len) throws IOException { |
92 |
synchronized (lock) {
|
93 |
int n = super.read(cbuf, off, len); |
94 |
|
95 |
for (int i = off; i < (off + n); i++) { |
96 |
char c = cbuf[i];
|
97 |
|
98 |
if (c == codigoM) {
|
99 |
cbuf[i] = codigoB; |
100 |
} |
101 |
} |
102 |
|
103 |
return n;
|
104 |
} |
105 |
} |
106 |
} |