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.interactive.action;
19 import org.apache.pdfbox.cos.COSBase;
20 import org.apache.pdfbox.cos.COSDictionary;
22 import org.apache.pdfbox.pdmodel.common.COSObjectable;
23 import org.apache.pdfbox.pdmodel.interactive.action.type.PDAction;
26 * This class represents a form field's dictionary of actions
27 * that occur due to events.
29 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
30 * @author Panagiotis Toumasis (ptoumasis@mail.gr)
31 * @version $Revision: 1.2 $
33 public class PDFormFieldAdditionalActions implements COSObjectable
35 private COSDictionary actions;
38 * Default constructor.
40 public PDFormFieldAdditionalActions()
42 actions = new COSDictionary();
48 * @param a The action dictionary.
50 public PDFormFieldAdditionalActions( COSDictionary a )
56 * Convert this standard java object to a COS object.
58 * @return The cos object that matches this Java object.
60 public COSBase getCOSObject()
66 * Convert this standard java object to a COS object.
68 * @return The cos object that matches this Java object.
70 public COSDictionary getCOSDictionary()
76 * This will get a JavaScript action to be performed when the user
77 * types a keystroke into a text field or combo box or modifies the
78 * selection in a scrollable list box. This allows the keystroke to
79 * be checked for validity and rejected or modified.
81 * @return The K entry of form field's additional actions dictionary.
83 public PDAction getK()
85 COSDictionary k = (COSDictionary)actions.getDictionaryObject( "K" );
86 PDAction retval = null;
89 retval = PDActionFactory.createAction( k );
95 * This will set a JavaScript action to be performed when the user
96 * types a keystroke into a text field or combo box or modifies the
97 * selection in a scrollable list box. This allows the keystroke to
98 * be checked for validity and rejected or modified.
100 * @param k The action to be performed.
102 public void setK( PDAction k )
104 actions.setItem( "K", k );
108 * This will get a JavaScript action to be performed before
109 * the field is formatted to display its current value. This
110 * allows the field's value to be modified before formatting.
112 * @return The F entry of form field's additional actions dictionary.
114 public PDAction getF()
116 COSDictionary f = (COSDictionary)actions.getDictionaryObject( "F" );
117 PDAction retval = null;
120 retval = PDActionFactory.createAction( f );
126 * This will set a JavaScript action to be performed before
127 * the field is formatted to display its current value. This
128 * allows the field's value to be modified before formatting.
130 * @param f The action to be performed.
132 public void setF( PDAction f )
134 actions.setItem( "F", f );
138 * This will get a JavaScript action to be performed
139 * when the field's value is changed. This allows the
140 * new value to be checked for validity.
141 * The name V stands for "validate".
143 * @return The V entry of form field's additional actions dictionary.
145 public PDAction getV()
147 COSDictionary v = (COSDictionary)actions.getDictionaryObject( "V" );
148 PDAction retval = null;
151 retval = PDActionFactory.createAction( v );
157 * This will set a JavaScript action to be performed
158 * when the field's value is changed. This allows the
159 * new value to be checked for validity.
160 * The name V stands for "validate".
162 * @param v The action to be performed.
164 public void setV( PDAction v )
166 actions.setItem( "V", v );
170 * This will get a JavaScript action to be performed in order to recalculate
171 * the value of this field when that of another field changes. The order in which
172 * the document's fields are recalculated is defined by the CO entry in the
173 * interactive form dictionary.
174 * The name C stands for "calculate".
176 * @return The C entry of form field's additional actions dictionary.
178 public PDAction getC()
180 COSDictionary c = (COSDictionary)actions.getDictionaryObject( "C" );
181 PDAction retval = null;
184 retval = PDActionFactory.createAction( c );
190 * This will set a JavaScript action to be performed in order to recalculate
191 * the value of this field when that of another field changes. The order in which
192 * the document's fields are recalculated is defined by the CO entry in the
193 * interactive form dictionary.
194 * The name C stands for "calculate".
196 * @param c The action to be performed.
198 public void setC( PDAction c )
200 actions.setItem( "C", c );