KickJava   Java API By Example, From Geeks To Geeks.

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


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: CmapFormat.java,v 1.4 2004/09/01 09:35:23 deweese Exp $
25  * @author <a HREF="mailto:david@steadystate.co.uk">David Schweinsberg</a>
26  */

27 public abstract class CmapFormat {
28
29     protected int format;
30     protected int length;
31     protected int version;
32
33     protected CmapFormat(RandomAccessFile JavaDoc raf) throws IOException JavaDoc {
34         length = raf.readUnsignedShort();
35         version = raf.readUnsignedShort();
36     }
37
38     protected static CmapFormat create(int format, RandomAccessFile JavaDoc raf)
39     throws IOException JavaDoc {
40         switch(format) {
41             case 0:
42             return new CmapFormat0(raf);
43             case 2:
44             return new CmapFormat2(raf);
45             case 4:
46             return new CmapFormat4(raf);
47             case 6:
48             return new CmapFormat6(raf);
49         }
50         return null;
51     }
52
53     public int getFormat() {
54         return format;
55     }
56
57     public int getLength() {
58         return length;
59     }
60
61     public int getVersion() {
62         return version;
63     }
64
65     public abstract int mapCharCode(int charCode);
66
67     public abstract int getFirst();
68     public abstract int getLast();
69
70     public String JavaDoc toString() {
71         return new StringBuffer JavaDoc()
72         .append("format: ")
73         .append(format)
74         .append(", length: ")
75         .append(length)
76         .append(", version: ")
77         .append(version).toString();
78     }
79 }
80
Popular Tags