]> _ Git - cubeextranet.git/blob
53c990790ba89757c316be1cd74887a515cbc8a1
[cubeextranet.git] /
1 /*\r
2  * Licensed to the Apache Software Foundation (ASF) under one or more\r
3  * contributor license agreements.  See the NOTICE file distributed with\r
4  * this work for additional information regarding copyright ownership.\r
5  * The ASF licenses this file to You under the Apache License, Version 2.0\r
6  * (the "License"); you may not use this file except in compliance with\r
7  * the License.  You may obtain a copy of the License at\r
8  *\r
9  *      http://www.apache.org/licenses/LICENSE-2.0\r
10  *\r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;\r
18 \r
19 import org.apache.pdfbox.cos.COSDictionary;\r
20 \r
21 /**\r
22  * A PrintField attribute object.\r
23  * \r
24  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>\r
25  * @version $Revision: $\r
26  */\r
27 public class PDPrintFieldAttributeObject extends PDStandardAttributeObject\r
28 {\r
29 \r
30     /**\r
31      * standard attribute owner: PrintField\r
32      */\r
33     public static final String OWNER_PRINT_FIELD = "PrintField";\r
34 \r
35     private static final String ROLE = "Role";\r
36     private static final String CHECKED = "checked";\r
37     private static final String DESC = "Desc";\r
38 \r
39     /**\r
40      * role: rb: Radio button\r
41      */\r
42     public static final String ROLE_RB = "rb";\r
43     /**\r
44      * role: cb: Check box\r
45      */\r
46     public static final String ROLE_CB = "cb";\r
47     /**\r
48      * role: pb: Push button\r
49      */\r
50     public static final String ROLE_PB = "pb";\r
51     /**\r
52      * role: tv: Text-value field\r
53      */\r
54     public static final String ROLE_TV = "tv";\r
55     /**\r
56      * checked state: on\r
57      */\r
58     public static final String CHECKED_STATE_ON = "on";\r
59     /**\r
60      * checked state: off\r
61      */\r
62     public static final String CHECKED_STATE_OFF = "off";\r
63     /**\r
64      * checked state: neutral\r
65      */\r
66     public static final String CHECKED_STATE_NEUTRAL = "neutral";\r
67 \r
68 \r
69     /**\r
70      * Default constructor.\r
71      */\r
72     public PDPrintFieldAttributeObject()\r
73     {\r
74         this.setOwner(OWNER_PRINT_FIELD);\r
75     }\r
76 \r
77     /**\r
78      * Creates a new PrintField attribute object with a given dictionary.\r
79      * \r
80      * @param dictionary the dictionary\r
81      */\r
82     public PDPrintFieldAttributeObject(COSDictionary dictionary)\r
83     {\r
84         super(dictionary);\r
85     }\r
86 \r
87 \r
88     /**\r
89      * Gets the role.\r
90      * \r
91      * @return the role\r
92      */\r
93     public String getRole()\r
94     {\r
95         return this.getName(ROLE);\r
96     }\r
97 \r
98     /**\r
99      * Sets the role. The value of Role shall be one of the following:\r
100      * <ul>\r
101      *   <li>{@link #ROLE_RB},</li>\r
102      *   <li>{@link #ROLE_CB},</li>\r
103      *   <li>{@link #ROLE_PB},</li>\r
104      *   <li>{@link #ROLE_TV}.</li>\r
105      * </ul>\r
106      * \r
107      * @param role the role\r
108      */\r
109     public void setRole(String role)\r
110     {\r
111         this.setName(ROLE, role);\r
112     }\r
113 \r
114     /**\r
115      * Gets the checked state. The default value is {@link #CHECKED_STATE_OFF}.\r
116      * \r
117      * @return the checked state\r
118      */\r
119     public String getCheckedState()\r
120     {\r
121         return this.getName(CHECKED, CHECKED_STATE_OFF);\r
122     }\r
123 \r
124     /**\r
125      * Sets the checked state. The value shall be one of:\r
126      * <ul>\r
127      *   <li>{@link #CHECKED_STATE_ON},</li>\r
128      *   <li>{@link #CHECKED_STATE_OFF} (default), or</li>\r
129      *   <li>{@link #CHECKED_STATE_NEUTRAL}.</li>\r
130      * </ul>\r
131      * \r
132      * @param checkedState the checked state\r
133      */\r
134     public void setCheckedState(String checkedState)\r
135     {\r
136         this.setName(CHECKED, checkedState);\r
137     }\r
138 \r
139     /**\r
140      * Gets the alternate name of the field (Desc).\r
141      * \r
142      * @return the alternate name of the field\r
143      */\r
144     public String getAlternateName()\r
145     {\r
146         return this.getString(DESC);\r
147     }\r
148 \r
149     /**\r
150      * Sets the alternate name of the field (Desc).\r
151      * \r
152      * @param alternateName the alternate name of the field\r
153      */\r
154     public void setAlternateName(String alternateName)\r
155     {\r
156         this.setString(DESC, alternateName);\r
157     }\r
158 \r
159     @Override\r
160     public String toString()\r
161     {\r
162         StringBuilder sb = new StringBuilder().append(super.toString());\r
163         if (this.isSpecified(ROLE))\r
164         {\r
165             sb.append(", Role=").append(this.getRole());\r
166         }\r
167         if (this.isSpecified(CHECKED))\r
168         {\r
169             sb.append(", Checked=").append(this.getCheckedState());\r
170         }\r
171         if (this.isSpecified(DESC))\r
172         {\r
173             sb.append(", Desc=").append(this.getAlternateName());\r
174         }\r
175         return sb.toString();\r
176     }\r
177 \r
178 }\r