KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > font > table > CmapIndexEntry


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

18 package org.apache.batik.svggen.font.table;
19
20 import java.io.IOException JavaDoc;
21 import java.io.RandomAccessFile JavaDoc;
22
23 /**
24  * @version $Id: CmapIndexEntry.java,v 1.3 2004/08/18 07:15:20 vhardy Exp $
25  * @author <a HREF="mailto:david@steadystate.co.uk">David Schweinsberg</a>
26  */

27 public class CmapIndexEntry {
28
29     private int platformId;
30     private int encodingId;
31     private int offset;
32
33     protected CmapIndexEntry(RandomAccessFile JavaDoc raf) throws IOException JavaDoc {
34         platformId = raf.readUnsignedShort();
35         encodingId = raf.readUnsignedShort();
36         offset = raf.readInt();
37     }
38
39     public int getEncodingId() {
40         return encodingId;
41     }
42
43     public int getOffset() {
44         return offset;
45     }
46
47     public int getPlatformId() {
48         return platformId;
49     }
50
51     public String JavaDoc toString() {
52         String JavaDoc platform;
53         String JavaDoc encoding = "";
54
55         switch (platformId) {
56             case 1: platform = " (Macintosh)"; break;
57             case 3: platform = " (Windows)"; break;
58             default: platform = "";
59         }
60         if (platformId == 3) {
61             // Windows specific encodings
62
switch (encodingId) {
63                 case 0: encoding = " (Symbol)"; break;
64                 case 1: encoding = " (Unicode)"; break;
65                 case 2: encoding = " (ShiftJIS)"; break;
66                 case 3: encoding = " (Big5)"; break;
67                 case 4: encoding = " (PRC)"; break;
68                 case 5: encoding = " (Wansung)"; break;
69                 case 6: encoding = " (Johab)"; break;
70                 default: encoding = "";
71             }
72         }
73         return new StringBuffer JavaDoc()
74         .append( "platform id: " )
75         .append( platformId )
76         .append( platform )
77         .append( ", encoding id: " )
78         .append( encodingId )
79         .append( encoding )
80         .append( ", offset: " )
81         .append( offset ).toString();
82     }
83 }
84
Popular Tags