KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > action > PDFormFieldAdditionalActions


1 /**
2  * Copyright (c) 2004, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.interactive.action;
32
33 import org.pdfbox.cos.COSBase;
34 import org.pdfbox.cos.COSDictionary;
35
36 import org.pdfbox.pdmodel.common.COSObjectable;
37 import org.pdfbox.pdmodel.interactive.action.type.PDAction;
38
39 /**
40  * This class represents a form field's dictionary of actions
41  * that occur due to events.
42  *
43  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
44  * @author Panagiotis Toumasis (ptoumasis@mail.gr)
45  * @version $Revision: 1.2 $
46  */

47 public class PDFormFieldAdditionalActions implements COSObjectable
48 {
49     private COSDictionary actions;
50
51     /**
52      * Default constructor.
53      */

54     public PDFormFieldAdditionalActions()
55     {
56         actions = new COSDictionary();
57     }
58
59     /**
60      * Constructor.
61      *
62      * @param a The action dictionary.
63      */

64     public PDFormFieldAdditionalActions( COSDictionary a )
65     {
66         actions = a;
67     }
68
69     /**
70      * Convert this standard java object to a COS object.
71      *
72      * @return The cos object that matches this Java object.
73      */

74     public COSBase getCOSObject()
75     {
76         return actions;
77     }
78
79     /**
80      * Convert this standard java object to a COS object.
81      *
82      * @return The cos object that matches this Java object.
83      */

84     public COSDictionary getCOSDictionary()
85     {
86         return actions;
87     }
88
89     /**
90      * This will get a JavaScript action to be performed when the user
91      * types a keystroke into a text field or combo box or modifies the
92      * selection in a scrollable list box. This allows the keystroke to
93      * be checked for validity and rejected or modified.
94      *
95      * @return The K entry of form field's additional actions dictionary.
96      */

97     public PDAction getK()
98     {
99         COSDictionary k = (COSDictionary)actions.getDictionaryObject( "K" );
100         PDAction retval = null;
101         if( k != null )
102         {
103             retval = PDActionFactory.createAction( k );
104         }
105         return retval;
106     }
107
108     /**
109      * This will set a JavaScript action to be performed when the user
110      * types a keystroke into a text field or combo box or modifies the
111      * selection in a scrollable list box. This allows the keystroke to
112      * be checked for validity and rejected or modified.
113      *
114      * @param k The action to be performed.
115      */

116     public void setK( PDAction k )
117     {
118         actions.setItem( "K", k );
119     }
120
121     /**
122      * This will get a JavaScript action to be performed before
123      * the field is formatted to display its current value. This
124      * allows the field's value to be modified before formatting.
125      *
126      * @return The F entry of form field's additional actions dictionary.
127      */

128     public PDAction getF()
129     {
130         COSDictionary f = (COSDictionary)actions.getDictionaryObject( "F" );
131         PDAction retval = null;
132         if( f != null )
133         {
134             retval = PDActionFactory.createAction( f );
135         }
136         return retval;
137     }
138
139     /**
140      * This will set a JavaScript action to be performed before
141      * the field is formatted to display its current value. This
142      * allows the field's value to be modified before formatting.
143      *
144      * @param f The action to be performed.
145      */

146     public void setF( PDAction f )
147     {
148         actions.setItem( "F", f );
149     }
150
151     /**
152      * This will get a JavaScript action to be performed
153      * when the field's value is changed. This allows the
154      * new value to be checked for validity.
155      * The name V stands for "validate".
156      *
157      * @return The V entry of form field's additional actions dictionary.
158      */

159     public PDAction getV()
160     {
161         COSDictionary v = (COSDictionary)actions.getDictionaryObject( "V" );
162         PDAction retval = null;
163         if( v != null )
164         {
165             retval = PDActionFactory.createAction( v );
166         }
167         return retval;
168     }
169
170     /**
171      * This will set a JavaScript action to be performed
172      * when the field's value is changed. This allows the
173      * new value to be checked for validity.
174      * The name V stands for "validate".
175      *
176      * @param v The action to be performed.
177      */

178     public void setV( PDAction v )
179     {
180         actions.setItem( "V", v );
181     }
182
183     /**
184      * This will get a JavaScript action to be performed in order to recalculate
185      * the value of this field when that of another field changes. The order in which
186      * the document's fields are recalculated is defined by the CO entry in the
187      * interactive form dictionary.
188      * The name C stands for "calculate".
189      *
190      * @return The C entry of form field's additional actions dictionary.
191      */

192     public PDAction getC()
193     {
194         COSDictionary c = (COSDictionary)actions.getDictionaryObject( "C" );
195         PDAction retval = null;
196         if( c != null )
197         {
198             retval = PDActionFactory.createAction( c );
199         }
200         return retval;
201     }
202
203     /**
204      * This will set a JavaScript action to be performed in order to recalculate
205      * the value of this field when that of another field changes. The order in which
206      * the document's fields are recalculated is defined by the CO entry in the
207      * interactive form dictionary.
208      * The name C stands for "calculate".
209      *
210      * @param c The action to be performed.
211      */

212     public void setC( PDAction c )
213     {
214         actions.setItem( "C", c );
215     }
216 }
Popular Tags