root / branches / Mobile_Compatible_Hito_1 / libFMap / src-comp / org / gvsig / datasources / impljme / BigByteBufferJME.java @ 21606
History | View | Annotate | Download (4.18 KB)
1 | 21606 | jldominguez | /*
|
---|---|---|---|
2 | * Created on 11-jul-2005
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | *
|
||
6 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
21 | *
|
||
22 | * For more information, contact:
|
||
23 | *
|
||
24 | * Generalitat Valenciana
|
||
25 | * Conselleria d'Infraestructures i Transport
|
||
26 | * Av. Blasco Ib??ez, 50
|
||
27 | * 46010 VALENCIA
|
||
28 | * SPAIN
|
||
29 | *
|
||
30 | * +34 963862235
|
||
31 | * gvsig@gva.es
|
||
32 | * www.gvsig.gva.es
|
||
33 | *
|
||
34 | * or
|
||
35 | *
|
||
36 | * IVER T.I. S.A
|
||
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | *
|
||
41 | * +34 963163400
|
||
42 | * dac@iver.es
|
||
43 | */
|
||
44 | package org.gvsig.datasources.impljme; |
||
45 | |||
46 | import java.io.IOException; |
||
47 | import java.nio.ByteOrder; |
||
48 | |||
49 | import org.apache.log4j.Logger; |
||
50 | import org.gvsig.datasources.common.IBigByteBuffer; |
||
51 | import org.gvsig.datasources.common.IRandomAccessFile; |
||
52 | import org.gvsig.datasources.common.IRandomFileChannel; |
||
53 | |||
54 | import es.prodevelop.gvsig.mobile.fmap.MapContext; |
||
55 | |||
56 | public class BigByteBufferJME implements IBigByteBuffer { |
||
57 | |||
58 | private static Logger logger = Logger.getLogger(BigByteBufferJME.class); |
||
59 | // private ByteBufferJME bigBuffer = null;
|
||
60 | private RandomFileChannelJME raf = null; |
||
61 | |||
62 | private BigByteBufferJME(IRandomFileChannel ch, int m) throws IOException { |
||
63 | |||
64 | // logger.debug("Instanciamos BigByteBufferJME: " + System.currentTimeMillis());
|
||
65 | |||
66 | if (ch instanceof RandomFileChannelJME) { |
||
67 | raf = (RandomFileChannelJME) ch; |
||
68 | // bigBuffer = new ByteBufferJME((int) aux.size());
|
||
69 | // bigBuffer = aux.map(IRandomFileChannel.ACCESS_MODE_READ_ONLY, 0, 0);
|
||
70 | |||
71 | } else {
|
||
72 | logger.error("Unexpected instance of IRandomFileChannel: " +
|
||
73 | ch.getClass().getName()); |
||
74 | } |
||
75 | } |
||
76 | |||
77 | public void position(long p) { |
||
78 | |||
79 | // logger.debug("IBigByteBufferJME, position(" + p + "): " + System.currentTimeMillis());
|
||
80 | try {
|
||
81 | raf.position((int) p);
|
||
82 | } catch (IOException e) { |
||
83 | logger.error("While doing position in RAF: " + e.getMessage());
|
||
84 | } |
||
85 | // bigBuffer.position((int) p);
|
||
86 | } |
||
87 | |||
88 | public int position() { |
||
89 | // logger.debug("IBigByteBufferJME, position() = :" + System.currentTimeMillis());
|
||
90 | |||
91 | int resp = 0; |
||
92 | try {
|
||
93 | resp = (int) raf.getPosition();
|
||
94 | } catch (IOException e) { |
||
95 | logger.error("While getting position in RAF: " + e.getMessage() + " (returned 0)"); |
||
96 | } |
||
97 | return resp;
|
||
98 | } |
||
99 | |||
100 | public byte get() { |
||
101 | |||
102 | byte resp = 0; |
||
103 | try {
|
||
104 | resp = raf.get(); |
||
105 | } catch (IOException e) { |
||
106 | logger.error("While getting byte: " + e.getMessage());
|
||
107 | } |
||
108 | return resp;
|
||
109 | } |
||
110 | |||
111 | public byte getByte(int ind) { |
||
112 | return raf.get(ind);
|
||
113 | // logger.debug("IBigByteBufferJME, getByte(" + ind + ") :" + System.currentTimeMillis());
|
||
114 | // return bigBuffer.get(ind);
|
||
115 | } |
||
116 | |||
117 | public int getInt() { |
||
118 | // logger.debug("IBigByteBufferJME, getInt() : " + System.currentTimeMillis());
|
||
119 | return raf.getInt();
|
||
120 | // return bigBuffer.getInt();
|
||
121 | } |
||
122 | |||
123 | public short getShort() { |
||
124 | return raf.getShort();
|
||
125 | // logger.debug("IBigByteBufferJME, getShort() :" + System.currentTimeMillis());
|
||
126 | // return bigBuffer.getShort();
|
||
127 | } |
||
128 | |||
129 | public int getInt(int index) { |
||
130 | // logger.debug("IBigByteBufferJME, getInt(" + index + ") :" + System.currentTimeMillis());
|
||
131 | return raf.getInt(index);
|
||
132 | } |
||
133 | |||
134 | public void get(byte[] out) { |
||
135 | // logger.debug("IBigByteBufferJME, get(out, " + out.length + " bytes) :" + System.currentTimeMillis());
|
||
136 | // bigBuffer.get(out);
|
||
137 | raf.get(out); |
||
138 | } |
||
139 | |||
140 | public double getDouble() { |
||
141 | // logger.debug("IBigByteBufferJME, getDouble() :" + System.currentTimeMillis());
|
||
142 | return raf.getDouble();
|
||
143 | } |
||
144 | |||
145 | |||
146 | public void order(ByteOrder o) { |
||
147 | // logger.debug("IBigByteBufferJME, order() :" + System.currentTimeMillis());
|
||
148 | // bigBuffer.order(o);
|
||
149 | raf.order(o); |
||
150 | } |
||
151 | |||
152 | |||
153 | } |