]> _ Git - cubeextranet.git/blob
624261aa8aaa4cf16702d8800529530bcc0f7ba4
[cubeextranet.git] /
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 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
18
19 import org.apache.pdfbox.cos.COSDictionary;
20
21 /**
22  * A PrintField attribute object.
23  * 
24  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
25  * @version $Revision: $
26  */
27 public class PDPrintFieldAttributeObject extends PDStandardAttributeObject
28 {
29
30     /**
31      * standard attribute owner: PrintField
32      */
33     public static final String OWNER_PRINT_FIELD = "PrintField";
34
35     private static final String ROLE = "Role";
36     private static final String CHECKED = "checked";
37     private static final String DESC = "Desc";
38
39     /**
40      * role: rb: Radio button
41      */
42     public static final String ROLE_RB = "rb";
43     /**
44      * role: cb: Check box
45      */
46     public static final String ROLE_CB = "cb";
47     /**
48      * role: pb: Push button
49      */
50     public static final String ROLE_PB = "pb";
51     /**
52      * role: tv: Text-value field
53      */
54     public static final String ROLE_TV = "tv";
55     /**
56      * checked state: on
57      */
58     public static final String CHECKED_STATE_ON = "on";
59     /**
60      * checked state: off
61      */
62     public static final String CHECKED_STATE_OFF = "off";
63     /**
64      * checked state: neutral
65      */
66     public static final String CHECKED_STATE_NEUTRAL = "neutral";
67
68
69     /**
70      * Default constructor.
71      */
72     public PDPrintFieldAttributeObject()
73     {
74         this.setOwner(OWNER_PRINT_FIELD);
75     }
76
77     /**
78      * Creates a new PrintField attribute object with a given dictionary.
79      * 
80      * @param dictionary the dictionary
81      */
82     public PDPrintFieldAttributeObject(COSDictionary dictionary)
83     {
84         super(dictionary);
85     }
86
87
88     /**
89      * Gets the role.
90      * 
91      * @return the role
92      */
93     public String getRole()
94     {
95         return this.getName(ROLE);
96     }
97
98     /**
99      * Sets the role. The value of Role shall be one of the following:
100      * <ul>
101      *   <li>{@link #ROLE_RB},</li>
102      *   <li>{@link #ROLE_CB},</li>
103      *   <li>{@link #ROLE_PB},</li>
104      *   <li>{@link #ROLE_TV}.</li>
105      * </ul>
106      * 
107      * @param role the role
108      */
109     public void setRole(String role)
110     {
111         this.setName(ROLE, role);
112     }
113
114     /**
115      * Gets the checked state. The default value is {@link #CHECKED_STATE_OFF}.
116      * 
117      * @return the checked state
118      */
119     public String getCheckedState()
120     {
121         return this.getName(CHECKED, CHECKED_STATE_OFF);
122     }
123
124     /**
125      * Sets the checked state. The value shall be one of:
126      * <ul>
127      *   <li>{@link #CHECKED_STATE_ON},</li>
128      *   <li>{@link #CHECKED_STATE_OFF} (default), or</li>
129      *   <li>{@link #CHECKED_STATE_NEUTRAL}.</li>
130      * </ul>
131      * 
132      * @param checkedState the checked state
133      */
134     public void setCheckedState(String checkedState)
135     {
136         this.setName(CHECKED, checkedState);
137     }
138
139     /**
140      * Gets the alternate name of the field (Desc).
141      * 
142      * @return the alternate name of the field
143      */
144     public String getAlternateName()
145     {
146         return this.getString(DESC);
147     }
148
149     /**
150      * Sets the alternate name of the field (Desc).
151      * 
152      * @param alternateName the alternate name of the field
153      */
154     public void setAlternateName(String alternateName)
155     {
156         this.setString(DESC, alternateName);
157     }
158
159     @Override
160     public String toString()
161     {
162         StringBuilder sb = new StringBuilder().append(super.toString());
163         if (this.isSpecified(ROLE))
164         {
165             sb.append(", Role=").append(this.getRole());
166         }
167         if (this.isSpecified(CHECKED))
168         {
169             sb.append(", Checked=").append(this.getCheckedState());
170         }
171         if (this.isSpecified(DESC))
172         {
173             sb.append(", Desc=").append(this.getAlternateName());
174         }
175         return sb.toString();
176     }
177
178 }