Mercurial > projects > dwt-addons
annotate dwtx/jface/internal/text/html/SingleCharReader.d @ 158:25f1f92fa3df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 26 Aug 2008 02:46:34 +0200 |
parents | 93a6ec48fd28 |
children | 1a5b8f8129df |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.internal.text.html.SingleCharReader; | |
14 | |
131 | 15 import dwtx.jface.internal.text.html.HTML2TextReader; // packageimport |
16 import dwtx.jface.internal.text.html.HTMLPrinter; // packageimport | |
17 import dwtx.jface.internal.text.html.BrowserInformationControl; // packageimport | |
18 import dwtx.jface.internal.text.html.SubstitutionTextReader; // packageimport | |
19 import dwtx.jface.internal.text.html.HTMLTextPresenter; // packageimport | |
20 import dwtx.jface.internal.text.html.BrowserInput; // packageimport | |
21 import dwtx.jface.internal.text.html.BrowserInformationControlInput; // packageimport | |
22 import dwtx.jface.internal.text.html.HTMLMessages; // packageimport | |
23 | |
24 | |
129 | 25 import dwt.dwthelper.utils; |
26 | |
27 /** | |
28 * <p> | |
29 * Moved into this package from <code>dwtx.jface.internal.text.revisions</code>.</p> | |
30 */ | |
31 public abstract class SingleCharReader : Reader { | |
32 | |
33 /** | |
34 * @see Reader#read() | |
35 */ | |
139
93a6ec48fd28
Regexp throws removal in interfaces
Frank Benoit <benoit@tionex.de>
parents:
136
diff
changeset
|
36 public abstract int read() ; |
129 | 37 |
38 /** | |
39 * @see Reader#read(char[],int,int) | |
40 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
134
diff
changeset
|
41 public int read(char cbuf[], int off, int len) { |
129 | 42 int end= off + len; |
43 for (int i= off; i < end; i++) { | |
44 int ch= read(); | |
45 if (ch is -1) { | |
46 if (i is off) | |
47 return -1; | |
48 return i - off; | |
49 } | |
134 | 50 cbuf[i]= cast(wchar)ch; |
129 | 51 } |
52 return len; | |
53 } | |
54 | |
55 /** | |
56 * @see Reader#ready() | |
57 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
134
diff
changeset
|
58 public bool ready() { |
129 | 59 return true; |
60 } | |
61 | |
62 /** | |
63 * Returns the readable content as string. | |
64 * @return the readable content as string | |
65 * @exception IOException in case reading fails | |
66 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
134
diff
changeset
|
67 public String getString() { |
129 | 68 StringBuffer buf= new StringBuffer(); |
69 int ch; | |
70 while ((ch= read()) !is -1) { | |
134 | 71 buf.append(cast(wchar)ch); |
129 | 72 } |
73 return buf.toString(); | |
74 } | |
75 } |