KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fonts > CIDFontType


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 /* $Id: CIDFontType.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.fonts;
21
22 import org.apache.avalon.framework.ValuedEnum;
23
24 /**
25  * This class enumerates all supported CID font types.
26  */

27 public class CIDFontType extends ValuedEnum {
28
29     /**
30      * CID Font Type 0
31      */

32     public static final CIDFontType CIDTYPE0 = new CIDFontType("CIDFontType0", 0);
33
34     /**
35      * CID Font Type 2
36      */

37     public static final CIDFontType CIDTYPE2 = new CIDFontType("CIDFontType2", 1);
38
39
40     /**
41      * @see org.apache.avalon.framework.Enum#Enum(String)
42      */

43     protected CIDFontType(String JavaDoc name, int value) {
44         super(name, value);
45     }
46
47
48     /**
49      * Returns the CIDFontType by name.
50      * @param name Name of the CID font type to look up
51      * @return FontType the CID font type
52      */

53     public static CIDFontType byName(String JavaDoc name) {
54         if (name.equalsIgnoreCase(CIDFontType.CIDTYPE0.getName())) {
55             return CIDFontType.CIDTYPE0;
56         } else if (name.equalsIgnoreCase(CIDFontType.CIDTYPE2.getName())) {
57             return CIDFontType.CIDTYPE2;
58         } else {
59             throw new IllegalArgumentException JavaDoc("Invalid CID font type: " + name);
60         }
61     }
62     
63     
64     /**
65      * Returns the CID FontType by value.
66      * @param value Value of the CID font type to look up
67      * @return FontType the CID font type
68      */

69     public static CIDFontType byValue(int value) {
70         if (value == CIDFontType.CIDTYPE0.getValue()) {
71             return CIDFontType.CIDTYPE0;
72         } else if (value == CIDFontType.CIDTYPE2.getValue()) {
73             return CIDFontType.CIDTYPE2;
74         } else {
75             throw new IllegalArgumentException JavaDoc("Invalid CID font type: " + value);
76         }
77     }
78     
79 }
80
Popular Tags