01: // @@
02: // @@
03: /*
04: * Wi.Ser Framework
05: *
06: * LGPL Version: 1.8.1, 20-September-2007
07: * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library located in LGPL.txt in the
21: * license directory; if not, write to the
22: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23: * Boston, MA 02111-1307, USA.
24: *
25: * If this agreement does not cover your requirements, please contact us
26: * via email to get detailed information about the commercial license
27: * or our service offerings!
28: *
29: */
30: // @@
31: package de.ug2t.connector;
32:
33: import java.io.*;
34: import java.nio.*;
35: import java.nio.channels.*;
36: import java.nio.charset.*;
37: import java.util.*;
38:
39: import de.ug2t.kernel.*;
40:
41: public class CoTextFileGetter extends ACoDataGetter {
42: private String pem_rootDir = "";
43: private Charset pem_cSet = null;
44:
45: // @@
46:
47: public CoTextFileGetter() {
48: pem_rootDir = de.ug2t.kernel.KeEnvironment.pcmf_getRootDir();
49: this .pem_cSet = KeEnvironment.pcmf_getCharacterSetObject();
50: };
51:
52: public CoTextFileGetter(String xRootDir) {
53: pem_rootDir = de.ug2t.kernel.KeEnvironment
54: .pcmf_buildPath(xRootDir);
55: this .pem_cSet = KeEnvironment.pcmf_getCharacterSetObject();
56:
57: return;
58: };
59:
60: public Object pcmf_getObj(String xId) throws Exception {
61: return (this .pcmf_getString(xId));
62: };
63:
64: // List eine ganze Datei in einen String (id ist der Filename)
65: public String pcmf_getString(String xId) throws Exception {
66: String l_fileName = pem_rootDir + xId;
67: String l_ret = null;
68:
69: // @@
70:
71: FileInputStream l_fis = new FileInputStream(pem_rootDir + xId);
72: FileChannel l_channel = l_fis.getChannel();
73: long l_size = l_channel.size();
74: ByteBuffer l_buffer = ByteBuffer.allocateDirect((int) l_size);
75: l_channel.read(l_buffer);
76: l_buffer.rewind();
77:
78: l_ret = pem_cSet.decode(l_buffer).toString();
79:
80: l_fis.close();
81:
82: // @@
83:
84: return (l_ret);
85: };
86:
87: public void pcmf_setCharacterSet(String xSet) {
88: this .pem_cSet = (Charset) Charset.availableCharsets().get(xSet);
89: };
90:
91: public void pcmf_reload() throws Exception {
92: // @@
93: }
94: }
|