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
9 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
\r
19 import org.apache.pdfbox.cos.COSDictionary;
\r
22 * A PrintField attribute object.
\r
24 * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
\r
25 * @version $Revision: $
\r
27 public class PDPrintFieldAttributeObject extends PDStandardAttributeObject
\r
31 * standard attribute owner: PrintField
\r
33 public static final String OWNER_PRINT_FIELD = "PrintField";
\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
40 * role: rb: Radio button
\r
42 public static final String ROLE_RB = "rb";
\r
44 * role: cb: Check box
\r
46 public static final String ROLE_CB = "cb";
\r
48 * role: pb: Push button
\r
50 public static final String ROLE_PB = "pb";
\r
52 * role: tv: Text-value field
\r
54 public static final String ROLE_TV = "tv";
\r
58 public static final String CHECKED_STATE_ON = "on";
\r
60 * checked state: off
\r
62 public static final String CHECKED_STATE_OFF = "off";
\r
64 * checked state: neutral
\r
66 public static final String CHECKED_STATE_NEUTRAL = "neutral";
\r
70 * Default constructor.
\r
72 public PDPrintFieldAttributeObject()
\r
74 this.setOwner(OWNER_PRINT_FIELD);
\r
78 * Creates a new PrintField attribute object with a given dictionary.
\r
80 * @param dictionary the dictionary
\r
82 public PDPrintFieldAttributeObject(COSDictionary dictionary)
\r
93 public String getRole()
\r
95 return this.getName(ROLE);
\r
99 * Sets the role. The value of Role shall be one of the following:
\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
107 * @param role the role
\r
109 public void setRole(String role)
\r
111 this.setName(ROLE, role);
\r
115 * Gets the checked state. The default value is {@link #CHECKED_STATE_OFF}.
\r
117 * @return the checked state
\r
119 public String getCheckedState()
\r
121 return this.getName(CHECKED, CHECKED_STATE_OFF);
\r
125 * Sets the checked state. The value shall be one of:
\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
132 * @param checkedState the checked state
\r
134 public void setCheckedState(String checkedState)
\r
136 this.setName(CHECKED, checkedState);
\r
140 * Gets the alternate name of the field (Desc).
\r
142 * @return the alternate name of the field
\r
144 public String getAlternateName()
\r
146 return this.getString(DESC);
\r
150 * Sets the alternate name of the field (Desc).
\r
152 * @param alternateName the alternate name of the field
\r
154 public void setAlternateName(String alternateName)
\r
156 this.setString(DESC, alternateName);
\r
160 public String toString()
\r
162 StringBuilder sb = new StringBuilder().append(super.toString());
\r
163 if (this.isSpecified(ROLE))
\r
165 sb.append(", Role=").append(this.getRole());
\r
167 if (this.isSpecified(CHECKED))
\r
169 sb.append(", Checked=").append(this.getCheckedState());
\r
171 if (this.isSpecified(DESC))
\r
173 sb.append(", Desc=").append(this.getAlternateName());
\r
175 return sb.toString();
\r