source: trunk/docx4j/src/main/java/org/docx4j/xmlPackage/Part.java @ 511

Revision 511, 6.5 KB checked in by jharrop, 4 years ago (diff)

Add ability to create a WordML Package from a Word 2007 xmlPackage.
Moved xmlPackage content model

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
21package org.docx4j.xmlPackage;
22
23import javax.xml.bind.annotation.XmlAccessType;
24import javax.xml.bind.annotation.XmlAccessorType;
25import javax.xml.bind.annotation.XmlAttribute;
26import javax.xml.bind.annotation.XmlSchemaType;
27import javax.xml.bind.annotation.XmlType;
28
29
30/**
31 *
32 *                              Defines a part of a package using open package
33 *                              conventions. A part with contentType containing xml
34 *                              requires xmlData. All other contentType values use
35 *                              binaryData.
36 *                     
37 *
38 * <p>Java class for CT_Part complex type.
39 *
40 * <p>The following schema fragment specifies the expected content contained within this class.
41 *
42 * <pre>
43 * &lt;complexType name="CT_Part">
44 *   &lt;complexContent>
45 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
46 *       &lt;choice>
47 *         &lt;element name="xmlData" type="{http://schemas.microsoft.com/office/2006/xmlPackage}CT_XmlData"/>
48 *         &lt;element name="binaryData" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
49 *       &lt;/choice>
50 *       &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
51 *       &lt;attribute name="contentType">
52 *         &lt;simpleType>
53 *           &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
54 *             &lt;pattern value="text/xml"/>
55 *             &lt;pattern value="application/xml"/>
56 *             &lt;pattern value="application/.+\+xml"/>
57 *             &lt;pattern value=".+"/>
58 *           &lt;/restriction>
59 *         &lt;/simpleType>
60 *       &lt;/attribute>
61 *       &lt;attribute name="compression" default="deflateSuperFast">
62 *         &lt;simpleType>
63 *           &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
64 *             &lt;enumeration value="store"/>
65 *             &lt;enumeration value="deflateSuperFast"/>
66 *             &lt;enumeration value="deflateFast"/>
67 *             &lt;enumeration value="deflateNormal"/>
68 *             &lt;enumeration value="deflateMaximum"/>
69 *           &lt;/restriction>
70 *         &lt;/simpleType>
71 *       &lt;/attribute>
72 *       &lt;attribute name="padding" type="{http://www.w3.org/2001/XMLSchema}unsignedInt" default="0" />
73 *     &lt;/restriction>
74 *   &lt;/complexContent>
75 * &lt;/complexType>
76 * </pre>
77 *
78 *
79 */
80@XmlAccessorType(XmlAccessType.FIELD)
81@XmlType(name = "CT_Part", propOrder = {
82    "xmlData",
83    "binaryData"
84})
85public class Part {
86
87    protected XmlData xmlData;
88    protected byte[] binaryData;
89    @XmlAttribute(namespace = "http://schemas.microsoft.com/office/2006/xmlPackage", required = true)
90    protected String name;
91    @XmlAttribute(namespace = "http://schemas.microsoft.com/office/2006/xmlPackage")
92    protected String contentType;
93    @XmlAttribute(namespace = "http://schemas.microsoft.com/office/2006/xmlPackage")
94    protected String compression;
95    @XmlAttribute(namespace = "http://schemas.microsoft.com/office/2006/xmlPackage")
96    @XmlSchemaType(name = "unsignedInt")
97    protected Long padding;
98
99    /**
100     * Gets the value of the xmlData property.
101     *
102     * @return
103     *     possible object is
104     *     {@link XmlData }
105     *     
106     */
107    public XmlData getXmlData() {
108        return xmlData;
109    }
110
111    /**
112     * Sets the value of the xmlData property.
113     *
114     * @param value
115     *     allowed object is
116     *     {@link XmlData }
117     *     
118     */
119    public void setXmlData(XmlData value) {
120        this.xmlData = value;
121    }
122
123    /**
124     * Gets the value of the binaryData property.
125     *
126     * @return
127     *     possible object is
128     *     byte[]
129     */
130    public byte[] getBinaryData() {
131        return binaryData;
132    }
133
134    /**
135     * Sets the value of the binaryData property.
136     *
137     * @param value
138     *     allowed object is
139     *     byte[]
140     */
141    public void setBinaryData(byte[] value) {
142        this.binaryData = ((byte[]) value);
143    }
144
145    /**
146     * Gets the value of the name property.
147     *
148     * @return
149     *     possible object is
150     *     {@link String }
151     *     
152     */
153    public String getName() {
154        return name;
155    }
156
157    /**
158     * Sets the value of the name property.
159     *
160     * @param value
161     *     allowed object is
162     *     {@link String }
163     *     
164     */
165    public void setName(String value) {
166        this.name = value;
167    }
168
169    /**
170     * Gets the value of the contentType property.
171     *
172     * @return
173     *     possible object is
174     *     {@link String }
175     *     
176     */
177    public String getContentType() {
178        return contentType;
179    }
180
181    /**
182     * Sets the value of the contentType property.
183     *
184     * @param value
185     *     allowed object is
186     *     {@link String }
187     *     
188     */
189    public void setContentType(String value) {
190        this.contentType = value;
191    }
192
193    /**
194     * Gets the value of the compression property.
195     *
196     * @return
197     *     possible object is
198     *     {@link String }
199     *     
200     */
201    public String getCompression() {
202        if (compression == null) {
203            return "deflateSuperFast";
204        } else {
205            return compression;
206        }
207    }
208
209    /**
210     * Sets the value of the compression property.
211     *
212     * @param value
213     *     allowed object is
214     *     {@link String }
215     *     
216     */
217    public void setCompression(String value) {
218        this.compression = value;
219    }
220
221    /**
222     * Gets the value of the padding property.
223     *
224     * @return
225     *     possible object is
226     *     {@link Long }
227     *     
228     */
229    public long getPadding() {
230        if (padding == null) {
231            return  0L;
232        } else {
233            return padding;
234        }
235    }
236
237    /**
238     * Sets the value of the padding property.
239     *
240     * @param value
241     *     allowed object is
242     *     {@link Long }
243     *     
244     */
245    public void setPadding(Long value) {
246        this.padding = value;
247    }
248
249}
Note: See TracBrowser for help on using the repository browser.