View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package com.isenshi.util.extlib;
17  
18  import com.lowagie.text.SplitCharacter;
19  import com.lowagie.text.pdf.PdfChunk;
20  
21  public class CJKSplitCharacter implements SplitCharacter {
22  
23  	public boolean isSplitCharacter(int start, int current, int end, char[] cc,
24  			PdfChunk[] ck) {
25  
26  		// copy form PDFChunk;
27  
28  		char c;
29  		if (ck == null)
30  			c = cc[current];
31  		else
32  			c = ck[Math.min(current, ck.length - 1)]
33  					.getUnicodeEquivalent(cc[current]);
34  		if (c <= ' ' || c == '-') {
35  			return true;
36  		}
37  		if (c < 0x2e80)
38  			return false;
39  
40  		
41  		//handle japanese character added by tuigwaa
42  		if(cc.length>current+1){
43  			char c2 = cc[current+1];
44  			if (c2 == 0x3001 || c2 == 0x3002) {
45  				return false;
46  			}
47  		}
48  		//handle japanese character   added by tuigwaa
49  
50  		return ((c >= 0x2e80 && c < 0xd7a0) || (c >= 0xf900 && c < 0xfb00)
51  				|| (c >= 0xfe30 && c < 0xfe50) || (c >= 0xff61 && c < 0xffa0));
52  
53  	}
54  }