source: trunk/docx4j/src/main/java/org/docx4j/wml/Document.java @ 1508

Revision 1508, 3.8 KB checked in by jharrop, 12 months ago (diff)

Implement ContentAccessor? (Convenience method to getBody().getContent() ).

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;
26
27import javax.xml.bind.Unmarshaller;
28import javax.xml.bind.annotation.XmlAccessType;
29import javax.xml.bind.annotation.XmlAccessorType;
30import javax.xml.bind.annotation.XmlRootElement;
31import javax.xml.bind.annotation.XmlTransient;
32import javax.xml.bind.annotation.XmlType;
33import org.jvnet.jaxb2_commons.ppp.Child;
34
35
36/**
37 * <p>Java class for anonymous complex type.
38 *
39 * <p>The following schema fragment specifies the expected content contained within this class.
40 *
41 * <pre>
42 * &lt;complexType>
43 *   &lt;complexContent>
44 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
45 *       &lt;sequence>
46 *         &lt;element name="background" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_Background" minOccurs="0"/>
47 *         &lt;element name="body" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_Body" minOccurs="0"/>
48 *       &lt;/sequence>
49 *     &lt;/restriction>
50 *   &lt;/complexContent>
51 * &lt;/complexType>
52 * </pre>
53 *
54 *
55 */
56@XmlAccessorType(XmlAccessType.FIELD)
57@XmlType(name = "", propOrder = {
58    "background",
59    "body"
60})
61@XmlRootElement(name = "document")
62public class Document
63    implements Child, ContentAccessor
64{
65
66    protected CTBackground background;
67    protected Body body;
68    @XmlTransient
69    private Object parent;
70
71    /**
72     * Gets the value of the background property.
73     *
74     * @return
75     *     possible object is
76     *     {@link CTBackground }
77     *     
78     */
79    public CTBackground getBackground() {
80        return background;
81    }
82
83    /**
84     * Sets the value of the background property.
85     *
86     * @param value
87     *     allowed object is
88     *     {@link CTBackground }
89     *     
90     */
91    public void setBackground(CTBackground value) {
92        this.background = value;
93    }
94
95    /**
96     * Gets the value of the body property.
97     *
98     * @return
99     *     possible object is
100     *     {@link Body }
101     *     
102     */
103    public Body getBody() {
104        return body;
105    }
106   
107    /**
108     * Convenience method to getBody().getContent()
109     * @since 2.7
110     */
111    public List<Object> getContent() {
112        return getBody().getContent();
113    }
114   
115
116    /**
117     * Sets the value of the body property.
118     *
119     * @param value
120     *     allowed object is
121     *     {@link Body }
122     *     
123     */
124    public void setBody(Body value) {
125        this.body = value;
126    }
127
128    /**
129     * Gets the parent object in the object tree representing the unmarshalled xml document.
130     *
131     * @return
132     *     The parent object.
133     */
134    public Object getParent() {
135        return this.parent;
136    }
137
138    public void setParent(Object parent) {
139        this.parent = parent;
140    }
141
142    /**
143     * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
144     *
145     * @param parent
146     *     The parent object in the object tree.
147     * @param unmarshaller
148     *     The unmarshaller that generated the instance.
149     */
150    public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
151        setParent(parent);
152    }
153
154}
Note: See TracBrowser for help on using the repository browser.