source: trunk/docx4j/src/main/java/org/docx4j/wml/CTCustomXmlPr.java @ 1437

Revision 1437, 6.9 KB checked in by jharrop, 15 months ago (diff)

Commit Richard's patch of 24 Feb. It includes:

  • update for the SdtElement? interface, which now extends child
  • update for SdtBlock?, SdtRun?, SdtRow?, SdtCell?, which now only extend SdtElement?
  • new CTCustomXmlElement interface, which is implemented by CTCustomXmlRun, CTCustomXmlBlock, CTCustomXmlCell, CTCustomXmlRow
  • fix for CTCustomXmlRun, CTCustomXmlBlock, CTCustomXmlCell, CTCustomXmlRow returning null properties
  • method added in CTAttr to find attribut by nam
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.Unmarshaller;
27import javax.xml.bind.annotation.XmlAccessType;
28import javax.xml.bind.annotation.XmlAccessorType;
29import javax.xml.bind.annotation.XmlAttribute;
30import javax.xml.bind.annotation.XmlTransient;
31import javax.xml.bind.annotation.XmlType;
32import org.jvnet.jaxb2_commons.ppp.Child;
33
34
35/**
36 * <p>Java class for CT_CustomXmlPr complex type.
37 *
38 * <p>The following schema fragment specifies the expected content contained within this class.
39 *
40 * <pre>
41 * &lt;complexType name="CT_CustomXmlPr">
42 *   &lt;complexContent>
43 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
44 *       &lt;sequence>
45 *         &lt;element name="placeholder" minOccurs="0">
46 *           &lt;complexType>
47 *             &lt;complexContent>
48 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
49 *                 &lt;attribute name="val" type="{http://www.w3.org/2001/XMLSchema}string" />
50 *               &lt;/restriction>
51 *             &lt;/complexContent>
52 *           &lt;/complexType>
53 *         &lt;/element>
54 *         &lt;element name="attr" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_Attr" maxOccurs="unbounded" minOccurs="0"/>
55 *       &lt;/sequence>
56 *     &lt;/restriction>
57 *   &lt;/complexContent>
58 * &lt;/complexType>
59 * </pre>
60 *
61 *
62 */
63@XmlAccessorType(XmlAccessType.FIELD)
64@XmlType(name = "CT_CustomXmlPr", propOrder = {
65    "placeholder",
66    "attr"
67})
68public class CTCustomXmlPr
69    implements Child
70{
71
72    protected CTCustomXmlPr.Placeholder placeholder;
73    protected List<CTAttr> attr;
74    @XmlTransient
75    private Object parent;
76
77    /**
78     * Gets the value of the placeholder property.
79     *
80     * @return
81     *     possible object is
82     *     {@link CTCustomXmlPr.Placeholder }
83     *     
84     */
85    public CTCustomXmlPr.Placeholder getPlaceholder() {
86        return placeholder;
87    }
88
89    /**
90     * Sets the value of the placeholder property.
91     *
92     * @param value
93     *     allowed object is
94     *     {@link CTCustomXmlPr.Placeholder }
95     *     
96     */
97    public void setPlaceholder(CTCustomXmlPr.Placeholder value) {
98        this.placeholder = value;
99    }
100
101    /**
102     * Gets the value of the attr property.
103     *
104     * <p>
105     * This accessor method returns a reference to the live list,
106     * not a snapshot. Therefore any modification you make to the
107     * returned list will be present inside the JAXB object.
108     * This is why there is not a <CODE>set</CODE> method for the attr property.
109     *
110     * <p>
111     * For example, to add a new item, do as follows:
112     * <pre>
113     *    getAttr().add(newItem);
114     * </pre>
115     *
116     *
117     * <p>
118     * Objects of the following type(s) are allowed in the list
119     * {@link CTAttr }
120     *
121     *
122     */
123    public List<CTAttr> getAttr() {
124        if (attr == null) {
125            attr = new ArrayList<CTAttr>();
126        }
127        return this.attr;
128    }
129   
130    /**
131     * Gets an attribut by name.
132     * @param attrName Name of the attribut
133     * @return {@link CTAttr} or {@code null}
134     */
135    public CTAttr getAttr(String attrName) {
136        if (attr == null) {
137            attr = new ArrayList<CTAttr>();
138        }
139       
140        for(CTAttr attr: this.attr) {
141            if(attr.getName().equals(attrName)) {
142                return attr;
143            }
144        }
145       
146        return null;
147    }
148
149    /**
150     * Gets the parent object in the object tree representing the unmarshalled xml document.
151     *
152     * @return
153     *     The parent object.
154     */
155    public Object getParent() {
156        return this.parent;
157    }
158
159    public void setParent(Object parent) {
160        this.parent = parent;
161    }
162
163    /**
164     * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
165     *
166     * @param parent
167     *     The parent object in the object tree.
168     * @param unmarshaller
169     *     The unmarshaller that generated the instance.
170     */
171    public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
172        setParent(parent);
173    }
174
175
176    /**
177     * <p>Java class for anonymous complex type.
178     *
179     * <p>The following schema fragment specifies the expected content contained within this class.
180     *
181     * <pre>
182     * &lt;complexType>
183     *   &lt;complexContent>
184     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
185     *       &lt;attribute name="val" type="{http://www.w3.org/2001/XMLSchema}string" />
186     *     &lt;/restriction>
187     *   &lt;/complexContent>
188     * &lt;/complexType>
189     * </pre>
190     *
191     *
192     */
193    @XmlAccessorType(XmlAccessType.FIELD)
194    @XmlType(name = "")
195    public static class Placeholder
196        implements Child
197    {
198
199        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
200        protected String val;
201        @XmlTransient
202        private Object parent;
203
204        /**
205         * Gets the value of the val property.
206         *
207         * @return
208         *     possible object is
209         *     {@link String }
210         *     
211         */
212        public String getVal() {
213            return val;
214        }
215
216        /**
217         * Sets the value of the val property.
218         *
219         * @param value
220         *     allowed object is
221         *     {@link String }
222         *     
223         */
224        public void setVal(String value) {
225            this.val = value;
226        }
227
228        /**
229         * Gets the parent object in the object tree representing the unmarshalled xml document.
230         *
231         * @return
232         *     The parent object.
233         */
234        public Object getParent() {
235            return this.parent;
236        }
237
238        public void setParent(Object parent) {
239            this.parent = parent;
240        }
241
242        /**
243         * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
244         *
245         * @param parent
246         *     The parent object in the object tree.
247         * @param unmarshaller
248         *     The unmarshaller that generated the instance.
249         */
250        public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
251            setParent(parent);
252        }
253
254    }
255
256}
Note: See TracBrowser for help on using the repository browser.