001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.pdf.fd;
031:
032: import java.util.List;
033: import de.intarsys.pdf.cos.COSArray;
034: import de.intarsys.pdf.cos.COSDictionary;
035: import de.intarsys.pdf.cos.COSName;
036: import de.intarsys.pdf.cos.COSObject;
037: import de.intarsys.pdf.cos.COSString;
038: import de.intarsys.pdf.pd.PDAcroFormNode;
039:
040: public class FDField extends FDObject {
041: public static final COSName DK_Kids = COSName.constant("Kids");
042:
043: public static final COSName DK_T = COSName.constant("T");
044:
045: public static final COSName DK_V = COSName.constant("V");
046:
047: public static final COSName DK_Ff = COSName.constant("Ff");
048:
049: public static final COSName DK_SetFf = COSName.constant("SetFf");
050:
051: public static final COSName DK_ClrFf = COSName.constant("ClrFf");
052:
053: public static final COSName DK_F = COSName.constant("F");
054:
055: public static final COSName DK_SetF = COSName.constant("SetF");
056:
057: public static final COSName DK_ClrF = COSName.constant("ClrF");
058:
059: public static final COSName DK_AP = COSName.constant("AP");
060:
061: public static final COSName DK_APRef = COSName.constant("APRef");
062:
063: public static final COSName DK_IF = COSName.constant("IF");
064:
065: public static final COSName DK_Opt = COSName.constant("Opt");
066:
067: public static final COSName DK_A = COSName.constant("A");
068:
069: public static final COSName DK_AA = COSName.constant("AA");
070:
071: public static final COSName DK_RV = COSName.constant("RV");
072:
073: /**
074: * The meta class implementation
075: */
076: static public class MetaClass extends PDAcroFormNode.MetaClass {
077: protected MetaClass(Class instanceClass) {
078: super (instanceClass);
079: }
080: }
081:
082: /** The meta class instance */
083: static public final MetaClass META = new MetaClass(MetaClass.class
084: .getDeclaringClass());
085:
086: protected FDField(COSObject object) {
087: super (object);
088: }
089:
090: public List getKids() {
091: return getFDObjects(DK_Kids, FDField.META);
092: }
093:
094: public void setFields(List fields) {
095: setFDObjects(DK_Kids, fields, true);
096: }
097:
098: public void addField(FDField field) {
099: cosAddKid(field.cosGetDict());
100: }
101:
102: public void cosAddKid(COSDictionary field) {
103: COSArray cosFields = cosGetField(DK_Kids).asArray();
104: if (cosFields == null) {
105: cosFields = COSArray.create();
106: cosSetField(DK_Kids, cosFields);
107: }
108: cosFields.add(field);
109: }
110:
111: public COSObject cosGetValue() {
112: return cosGetField(DK_V);
113: }
114:
115: public void cosSetValue(COSObject value) {
116: cosSetField(DK_V, value);
117: }
118:
119: public String getLocalName() {
120: COSString cosObject = cosGetField(DK_T).asString();
121: if (cosObject != null) {
122: return cosObject.stringValue();
123: }
124: return null;
125: }
126:
127: public void setLocalName(String name) {
128: setFieldString(DK_T, name);
129: }
130: }
|