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