KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > textmining > text > extraction > WordTextBuffer


1 /* Copyright 2004 Ryan Ackley
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

15 package org.textmining.text.extraction;
16
17
18 /**
19  * This class acts as a StringBuffer for text from a word document. It allows
20  * processing of character before they
21  * @author Ryan Ackley
22  * @version 1.0
23  */

24 public class WordTextBuffer
25 {
26   StringBuffer JavaDoc _buf;
27   boolean _hold;
28
29   public WordTextBuffer()
30   {
31     _buf = new StringBuffer JavaDoc();
32     _hold = false;
33   }
34
35   public void append(String JavaDoc text)
36   {
37     char[] letters = text.toCharArray();
38     for (int x = 0; x < letters.length; x++)
39     {
40       switch(letters[x])
41       {
42         case '\r':
43           _buf.append("\r\n");
44           break;
45         case 0x13:
46           _hold = true;
47           break;
48         case 0x14:
49           _hold = false;
50           break;
51         default:
52           if (!_hold)
53           {
54             _buf.append(letters[x]);
55           }
56           break;
57       }
58     }
59   }
60
61   public String JavaDoc toString()
62   {
63     return _buf.toString();
64   }
65
66 }
Popular Tags