KickJava   Java API By Example, From Geeks To Geeks.

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


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: KeepProperty.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.fo.properties;
21
22 import org.apache.fop.datatypes.CompoundDatatype;
23 import org.apache.fop.fo.FObj;
24 import org.apache.fop.fo.PropertyList;
25 import org.apache.fop.fo.expr.PropertyException;
26
27 /**
28  * Superclass for properties that wrap Keep values
29  */

30 public class KeepProperty extends Property implements CompoundDatatype {
31     private Property withinLine;
32     private Property withinColumn;
33     private Property withinPage;
34
35     /**
36      * Inner class for creating instances of KeepProperty
37      */

38     public static class Maker extends CompoundPropertyMaker {
39
40         /**
41          * @param propId the id of the property for which a Maker should be created
42          */

43         public Maker(int propId) {
44             super(propId);
45         }
46
47         /**
48          * Create a new empty instance of KeepProperty.
49          * @return the new instance.
50          */

51         public Property makeNewProperty() {
52             return new KeepProperty();
53         }
54
55         /**
56          * @see CompoundPropertyMaker#convertProperty
57          */

58         public Property convertProperty(Property p, PropertyList propertyList, FObj fo)
59             throws PropertyException
60         {
61             if (p instanceof KeepProperty) {
62                 return p;
63             }
64             return super.convertProperty(p, propertyList, fo);
65         }
66     }
67
68     /**
69      * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
70      */

71     public void setComponent(int cmpId, Property cmpnValue,
72                              boolean bIsDefault) {
73         if (cmpId == CP_WITHIN_LINE) {
74             setWithinLine(cmpnValue, bIsDefault);
75         } else if (cmpId == CP_WITHIN_COLUMN) {
76             setWithinColumn(cmpnValue, bIsDefault);
77         } else if (cmpId == CP_WITHIN_PAGE) {
78             setWithinPage(cmpnValue, bIsDefault);
79         }
80     }
81
82     /**
83      * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
84      */

85     public Property getComponent(int cmpId) {
86         if (cmpId == CP_WITHIN_LINE) {
87             return getWithinLine();
88         } else if (cmpId == CP_WITHIN_COLUMN) {
89             return getWithinColumn();
90         } else if (cmpId == CP_WITHIN_PAGE) {
91             return getWithinPage();
92         } else {
93             return null;
94         }
95     }
96
97     /**
98      * @param withinLine withinLine property to set
99      * @param bIsDefault not used (??)
100      */

101     public void setWithinLine(Property withinLine, boolean bIsDefault) {
102         this.withinLine = withinLine;
103     }
104
105     /**
106      * @param withinColumn withinColumn property to set
107      * @param bIsDefault not used (??)
108      */

109     protected void setWithinColumn(Property withinColumn,
110                                    boolean bIsDefault) {
111         this.withinColumn = withinColumn;
112     }
113
114     /**
115      * @param withinPage withinPage property to set
116      * @param bIsDefault not used (??)
117      */

118     public void setWithinPage(Property withinPage, boolean bIsDefault) {
119         this.withinPage = withinPage;
120     }
121
122     /**
123      * @return the withinLine property
124      */

125     public Property getWithinLine() {
126         return this.withinLine;
127     }
128
129     /**
130      * @return the withinColumn property
131      */

132     public Property getWithinColumn() {
133         return this.withinColumn;
134     }
135
136     /**
137      * @return the withinPage property
138      */

139     public Property getWithinPage() {
140         return this.withinPage;
141     }
142
143     /**
144      * Not sure what to do here. There isn't really a meaningful single value.
145      * @return String representation
146      */

147     public String JavaDoc toString() {
148         return "Keep[" +
149             "withinLine:" + getWithinLine().getObject() +
150             ", withinColumn:" + getWithinColumn().getObject() +
151             ", withinPage:" + getWithinPage().getObject() + "]";
152     }
153
154     /**
155      * @return this.keep
156      */

157     public KeepProperty getKeep() {
158         return this;
159     }
160
161     /**
162      * @return this.keep cast as Object
163      */

164     public Object JavaDoc getObject() {
165         return this;
166     }
167
168 }
169
Popular Tags