All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDPrintFieldAttributeObject Maven / Gradle / Ivy

Go to download

The Apache PDFBox library is an open source Java tool for working with PDF documents.

There is a newer version: 3.0.2
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;

import org.apache.pdfbox.cos.COSDictionary;

/**
 * A PrintField attribute object.
 * 
 * @author Johannes Koch
 */
public class PDPrintFieldAttributeObject extends PDStandardAttributeObject
{

    /**
     * standard attribute owner: PrintField
     */
    public static final String OWNER_PRINT_FIELD = "PrintField";

    private static final String ROLE = "Role";
    private static final String CHECKED = "checked";
    private static final String DESC = "Desc";

    /**
     * role: rb: Radio button
     */
    public static final String ROLE_RB = "rb";
    /**
     * role: cb: Check box
     */
    public static final String ROLE_CB = "cb";
    /**
     * role: pb: Push button
     */
    public static final String ROLE_PB = "pb";
    /**
     * role: tv: Text-value field
     */
    public static final String ROLE_TV = "tv";
    /**
     * checked state: on
     */
    public static final String CHECKED_STATE_ON = "on";
    /**
     * checked state: off
     */
    public static final String CHECKED_STATE_OFF = "off";
    /**
     * checked state: neutral
     */
    public static final String CHECKED_STATE_NEUTRAL = "neutral";


    /**
     * Default constructor.
     */
    public PDPrintFieldAttributeObject()
    {
        this.setOwner(OWNER_PRINT_FIELD);
    }

    /**
     * Creates a new PrintField attribute object with a given dictionary.
     * 
     * @param dictionary the dictionary
     */
    public PDPrintFieldAttributeObject(COSDictionary dictionary)
    {
        super(dictionary);
    }


    /**
     * Gets the role.
     * 
     * @return the role
     */
    public String getRole()
    {
        return this.getName(ROLE);
    }

    /**
     * Sets the role. The value of Role shall be one of the following:
     * 
    *
  • {@link #ROLE_RB},
  • *
  • {@link #ROLE_CB},
  • *
  • {@link #ROLE_PB},
  • *
  • {@link #ROLE_TV}.
  • *
* * @param role the role */ public void setRole(String role) { this.setName(ROLE, role); } /** * Gets the checked state. The default value is {@link #CHECKED_STATE_OFF}. * * @return the checked state */ public String getCheckedState() { return this.getName(CHECKED, CHECKED_STATE_OFF); } /** * Sets the checked state. The value shall be one of: *
    *
  • {@link #CHECKED_STATE_ON},
  • *
  • {@link #CHECKED_STATE_OFF} (default), or
  • *
  • {@link #CHECKED_STATE_NEUTRAL}.
  • *
* * @param checkedState the checked state */ public void setCheckedState(String checkedState) { this.setName(CHECKED, checkedState); } /** * Gets the alternate name of the field (Desc). * * @return the alternate name of the field */ public String getAlternateName() { return this.getString(DESC); } /** * Sets the alternate name of the field (Desc). * * @param alternateName the alternate name of the field */ public void setAlternateName(String alternateName) { this.setString(DESC, alternateName); } @Override public String toString() { StringBuilder sb = new StringBuilder().append(super.toString()); if (this.isSpecified(ROLE)) { sb.append(", Role=").append(this.getRole()); } if (this.isSpecified(CHECKED)) { sb.append(", Checked=").append(this.getCheckedState()); } if (this.isSpecified(DESC)) { sb.append(", Desc=").append(this.getAlternateName()); } return sb.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy