source: trunk/docx4j/src/main/java/org/docx4j/wml/CTSimpleField.java @ 1582

Revision 1582, 13.3 KB checked in by jharrop, 11 months ago (diff)

Temporary fix for MarshallException? in ShallowTraversor? caused by unwrapping CTSimpleField
(same problem is likely to occur for anything we unwrap which doesn't have an @XmlRootElement?).

Line 
1/*
2 *  Copyright 2007-2008, Plutext Pty Ltd.
3 *   
4 *  This file is part of docx4j.
5
6    docx4j is licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18
19 */
20
21
22package org.docx4j.wml;
23
24import java.util.ArrayList;
25import java.util.List;
26import javax.xml.bind.JAXBElement;
27import javax.xml.bind.Unmarshaller;
28import javax.xml.bind.annotation.XmlAccessType;
29import javax.xml.bind.annotation.XmlAccessorType;
30import javax.xml.bind.annotation.XmlAttribute;
31import javax.xml.bind.annotation.XmlElementRef;
32import javax.xml.bind.annotation.XmlElementRefs;
33import javax.xml.bind.annotation.XmlRootElement;
34import javax.xml.bind.annotation.XmlTransient;
35import javax.xml.bind.annotation.XmlType;
36import org.docx4j.math.CTOMath;
37import org.docx4j.math.CTOMathPara;
38import org.jvnet.jaxb2_commons.ppp.Child;
39
40
41/**
42 * <p>Java class for CT_SimpleField complex type.
43 *
44 * <p>The following schema fragment specifies the expected content contained within this class.
45 *
46 * <pre>
47 * &lt;complexType name="CT_SimpleField">
48 *   &lt;complexContent>
49 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
50 *       &lt;sequence>
51 *         &lt;element name="fldData" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_Text" minOccurs="0"/>
52 *         &lt;group ref="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}EG_PContent" maxOccurs="unbounded" minOccurs="0"/>
53 *       &lt;/sequence>
54 *       &lt;attribute name="instr" use="required" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
55 *       &lt;attribute name="fldLock" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
56 *       &lt;attribute name="dirty" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
57 *     &lt;/restriction>
58 *   &lt;/complexContent>
59 * &lt;/complexType>
60 * </pre>
61 *
62 *
63 */
64@XmlAccessorType(XmlAccessType.FIELD)
65@XmlType(name = "CT_SimpleField", propOrder = {
66    "fldData",
67    "paragraphContent"
68})
69@XmlRootElement(name = "fldSimple")
70public class CTSimpleField
71    implements Child, ContentAccessor
72{
73
74    protected Text fldData;
75    @XmlElementRefs({
76        @XmlElementRef(name = "bookmarkEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
77        @XmlElementRef(name = "commentRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeStart.class),
78        @XmlElementRef(name = "customXmlDelRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
79        @XmlElementRef(name = "sdt", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
80        @XmlElementRef(name = "ins", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunIns.class),
81        @XmlElementRef(name = "moveFrom", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
82        @XmlElementRef(name = "moveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
83        @XmlElementRef(name = "customXmlMoveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
84        @XmlElementRef(name = "oMath", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
85        @XmlElementRef(name = "customXmlMoveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
86        @XmlElementRef(name = "r", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = R.class),
87        @XmlElementRef(name = "customXmlInsRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
88        @XmlElementRef(name = "fldSimple", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
89        @XmlElementRef(name = "customXml", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
90        @XmlElementRef(name = "moveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
91        @XmlElementRef(name = "customXmlMoveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
92        @XmlElementRef(name = "commentRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeEnd.class),
93        @XmlElementRef(name = "moveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
94        @XmlElementRef(name = "smartTag", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
95        @XmlElementRef(name = "proofErr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = ProofErr.class),
96        @XmlElementRef(name = "del", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunDel.class),
97        @XmlElementRef(name = "permEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
98        @XmlElementRef(name = "bookmarkStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
99        @XmlElementRef(name = "customXmlInsRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
100        @XmlElementRef(name = "oMathPara", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
101        @XmlElementRef(name = "subDoc", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
102        @XmlElementRef(name = "moveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
103        @XmlElementRef(name = "moveTo", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
104        @XmlElementRef(name = "permStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
105        @XmlElementRef(name = "hyperlink", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
106        @XmlElementRef(name = "customXmlMoveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
107        @XmlElementRef(name = "customXmlDelRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class)
108    })
109    protected List<Object> paragraphContent;
110    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", required = true)
111    protected String instr;
112    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
113    protected Boolean fldLock;
114    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
115    protected Boolean dirty;
116    @XmlTransient
117    private Object parent;
118
119    /**
120     * Gets the value of the fldData property.
121     *
122     * @return
123     *     possible object is
124     *     {@link Text }
125     *     
126     */
127    public Text getFldData() {
128        return fldData;
129    }
130
131    /**
132     * Sets the value of the fldData property.
133     *
134     * @param value
135     *     allowed object is
136     *     {@link Text }
137     *     
138     */
139    public void setFldData(Text value) {
140        this.fldData = value;
141    }
142
143    /**
144     * Gets the value of the paragraphContent property.
145     *
146     * <p>
147     * This accessor method returns a reference to the live list,
148     * not a snapshot. Therefore any modification you make to the
149     * returned list will be present inside the JAXB object.
150     * This is why there is not a <CODE>set</CODE> method for the paragraphContent property.
151     *
152     * <p>
153     * For example, to add a new item, do as follows:
154     * <pre>
155     *    getParagraphContent().add(newItem);
156     * </pre>
157     *
158     *
159     * <p>
160     * Objects of the following type(s) are allowed in the list
161     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
162     * {@link CommentRangeStart }
163     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
164     * {@link JAXBElement }{@code <}{@link SdtRun }{@code >}
165     * {@link RunIns }
166     * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
167     * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
168     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
169     * {@link JAXBElement }{@code <}{@link CTOMath }{@code >}
170     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
171     * {@link R }
172     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
173     * {@link JAXBElement }{@code <}{@link CTSimpleField }{@code >}
174     * {@link JAXBElement }{@code <}{@link CTCustomXmlRun }{@code >}
175     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
176     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
177     * {@link CommentRangeEnd }
178     * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
179     * {@link JAXBElement }{@code <}{@link CTSmartTagRun }{@code >}
180     * {@link ProofErr }
181     * {@link RunDel }
182     * {@link JAXBElement }{@code <}{@link CTPerm }{@code >}
183     * {@link JAXBElement }{@code <}{@link CTBookmark }{@code >}
184     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
185     * {@link JAXBElement }{@code <}{@link CTOMathPara }{@code >}
186     * {@link JAXBElement }{@code <}{@link CTRel }{@code >}
187     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
188     * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
189     * {@link JAXBElement }{@code <}{@link RangePermissionStart }{@code >}
190     * {@link JAXBElement }{@code <}{@link org.docx4j.wml.P.Hyperlink }{@code >}
191     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
192     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
193     *
194     *
195     */
196    @Deprecated
197    public List<Object> getParagraphContent() {
198        if (paragraphContent == null) {
199            paragraphContent = new ArrayList<Object>();
200        }
201        return this.paragraphContent;
202    }
203
204    /**
205     * Get the content of this element.
206     * @since 2.7
207     */   
208    public List<Object> getContent() {
209        if (paragraphContent == null) {
210            paragraphContent = new ArrayList<Object>();
211        }
212        return this.paragraphContent;
213    }
214   
215    /**
216     * Gets the value of the instr property.
217     *
218     * @return
219     *     possible object is
220     *     {@link String }
221     *     
222     */
223    public String getInstr() {
224        return instr;
225    }
226
227    /**
228     * Sets the value of the instr property.
229     *
230     * @param value
231     *     allowed object is
232     *     {@link String }
233     *     
234     */
235    public void setInstr(String value) {
236        this.instr = value;
237    }
238
239    /**
240     * Gets the value of the fldLock property.
241     *
242     * @return
243     *     possible object is
244     *     {@link Boolean }
245     *     
246     */
247    public boolean isFldLock() {
248        if (fldLock == null) {
249            return true;
250        } else {
251            return fldLock;
252        }
253    }
254
255    /**
256     * Sets the value of the fldLock property.
257     *
258     * @param value
259     *     allowed object is
260     *     {@link Boolean }
261     *     
262     */
263    public void setFldLock(Boolean value) {
264        this.fldLock = value;
265    }
266
267    /**
268     * Gets the value of the dirty property.
269     *
270     * @return
271     *     possible object is
272     *     {@link Boolean }
273     *     
274     */
275    public boolean isDirty() {
276        if (dirty == null) {
277            return true;
278        } else {
279            return dirty;
280        }
281    }
282
283    /**
284     * Sets the value of the dirty property.
285     *
286     * @param value
287     *     allowed object is
288     *     {@link Boolean }
289     *     
290     */
291    public void setDirty(Boolean value) {
292        this.dirty = value;
293    }
294
295    /**
296     * Gets the parent object in the object tree representing the unmarshalled xml document.
297     *
298     * @return
299     *     The parent object.
300     */
301    public Object getParent() {
302        return this.parent;
303    }
304
305    public void setParent(Object parent) {
306        this.parent = parent;
307    }
308
309    /**
310     * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
311     *
312     * @param parent
313     *     The parent object in the object tree.
314     * @param unmarshaller
315     *     The unmarshaller that generated the instance.
316     */
317    public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
318        setParent(parent);
319    }
320
321}
Note: See TracBrowser for help on using the repository browser.