KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > properties > EnumNumber


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: EnumNumber.java 488960 2006-12-20 08:34:28Z spepping $ */
19  
20 package org.apache.fop.fo.properties;
21
22 import java.util.Map JavaDoc;
23 import java.util.WeakHashMap JavaDoc;
24
25 /**
26  * A number quantity in XSL which is specified as an enum, such as "no-limit".
27  */

28 public class EnumNumber extends NumberProperty {
29
30     private static final Map JavaDoc cache = new WeakHashMap JavaDoc();
31
32     private final EnumProperty enumProperty;
33     
34     private EnumNumber(EnumProperty enumProperty) {
35         super(null);
36         this.enumProperty = enumProperty;
37     }
38
39     public static EnumNumber getInstance(Property enumProperty) {
40         EnumNumber en = (EnumNumber)cache.get(enumProperty);
41         if (en == null) {
42             en = new EnumNumber((EnumProperty)enumProperty);
43             cache.put(enumProperty, en);
44         }
45         return en;
46     }
47
48     public int getEnum() {
49         return enumProperty.getEnum();
50     }
51
52     /**
53      * Returns the length in 1/1000ths of a point (millipoints)
54      * @return the length in millipoints
55      */

56     public int getValue() {
57         log.error("getValue() called on " + enumProperty + " number");
58         return 0;
59     }
60
61     /**
62      * Returns the value as numeric.
63      * @return the length in millipoints
64      */

65     public double getNumericValue() {
66         log.error("getNumericValue() called on " + enumProperty + " number");
67         return 0;
68     }
69
70     /**
71      * @see org.apache.fop.fo.properties.Property#getString()
72      */

73     public String JavaDoc getString() {
74         return enumProperty.toString();
75     }
76
77     /**
78      * @see org.apache.fop.fo.properties.Property#getString()
79      */

80     public Object JavaDoc getObject() {
81         return enumProperty.getObject();
82     }
83
84
85 }
86
Popular Tags