| 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 | |
|---|
| 22 | package org.docx4j.customxml; |
|---|
| 23 | |
|---|
| 24 | import java.util.ArrayList; |
|---|
| 25 | import java.util.List; |
|---|
| 26 | import javax.xml.bind.Unmarshaller; |
|---|
| 27 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 28 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 29 | import javax.xml.bind.annotation.XmlAttribute; |
|---|
| 30 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 31 | import javax.xml.bind.annotation.XmlTransient; |
|---|
| 32 | import javax.xml.bind.annotation.XmlType; |
|---|
| 33 | import 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 | * <complexType> |
|---|
| 43 | * <complexContent> |
|---|
| 44 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
|---|
| 45 | * <sequence> |
|---|
| 46 | * <element name="schema" maxOccurs="unbounded" minOccurs="0"> |
|---|
| 47 | * <complexType> |
|---|
| 48 | * <complexContent> |
|---|
| 49 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
|---|
| 50 | * <attribute name="uri" type="{http://www.w3.org/2001/XMLSchema}string" default="" /> |
|---|
| 51 | * <attribute name="manifestLocation" type="{http://www.w3.org/2001/XMLSchema}string" /> |
|---|
| 52 | * <attribute name="schemaLocation" type="{http://www.w3.org/2001/XMLSchema}string" /> |
|---|
| 53 | * </restriction> |
|---|
| 54 | * </complexContent> |
|---|
| 55 | * </complexType> |
|---|
| 56 | * </element> |
|---|
| 57 | * </sequence> |
|---|
| 58 | * </restriction> |
|---|
| 59 | * </complexContent> |
|---|
| 60 | * </complexType> |
|---|
| 61 | * </pre> |
|---|
| 62 | * |
|---|
| 63 | * |
|---|
| 64 | */ |
|---|
| 65 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 66 | @XmlType(name = "", propOrder = { |
|---|
| 67 | "schema" |
|---|
| 68 | }) |
|---|
| 69 | @XmlRootElement(name = "schemaLibrary") |
|---|
| 70 | public class SchemaLibrary |
|---|
| 71 | implements Child |
|---|
| 72 | { |
|---|
| 73 | |
|---|
| 74 | protected List<SchemaLibrary.Schema> schema; |
|---|
| 75 | @XmlTransient |
|---|
| 76 | private Object parent; |
|---|
| 77 | |
|---|
| 78 | /** |
|---|
| 79 | * Gets the value of the schema property. |
|---|
| 80 | * |
|---|
| 81 | * <p> |
|---|
| 82 | * This accessor method returns a reference to the live list, |
|---|
| 83 | * not a snapshot. Therefore any modification you make to the |
|---|
| 84 | * returned list will be present inside the JAXB object. |
|---|
| 85 | * This is why there is not a <CODE>set</CODE> method for the schema property. |
|---|
| 86 | * |
|---|
| 87 | * <p> |
|---|
| 88 | * For example, to add a new item, do as follows: |
|---|
| 89 | * <pre> |
|---|
| 90 | * getSchema().add(newItem); |
|---|
| 91 | * </pre> |
|---|
| 92 | * |
|---|
| 93 | * |
|---|
| 94 | * <p> |
|---|
| 95 | * Objects of the following type(s) are allowed in the list |
|---|
| 96 | * {@link SchemaLibrary.Schema } |
|---|
| 97 | * |
|---|
| 98 | * |
|---|
| 99 | */ |
|---|
| 100 | public List<SchemaLibrary.Schema> getSchema() { |
|---|
| 101 | if (schema == null) { |
|---|
| 102 | schema = new ArrayList<SchemaLibrary.Schema>(); |
|---|
| 103 | } |
|---|
| 104 | return this.schema; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | /** |
|---|
| 108 | * Gets the parent object in the object tree representing the unmarshalled xml document. |
|---|
| 109 | * |
|---|
| 110 | * @return |
|---|
| 111 | * The parent object. |
|---|
| 112 | */ |
|---|
| 113 | public Object getParent() { |
|---|
| 114 | return this.parent; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | public void setParent(Object parent) { |
|---|
| 118 | this.parent = parent; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | /** |
|---|
| 122 | * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. |
|---|
| 123 | * |
|---|
| 124 | * @param parent |
|---|
| 125 | * The parent object in the object tree. |
|---|
| 126 | * @param unmarshaller |
|---|
| 127 | * The unmarshaller that generated the instance. |
|---|
| 128 | */ |
|---|
| 129 | public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { |
|---|
| 130 | setParent(parent); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | /** |
|---|
| 135 | * <p>Java class for anonymous complex type. |
|---|
| 136 | * |
|---|
| 137 | * <p>The following schema fragment specifies the expected content contained within this class. |
|---|
| 138 | * |
|---|
| 139 | * <pre> |
|---|
| 140 | * <complexType> |
|---|
| 141 | * <complexContent> |
|---|
| 142 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
|---|
| 143 | * <attribute name="uri" type="{http://www.w3.org/2001/XMLSchema}string" default="" /> |
|---|
| 144 | * <attribute name="manifestLocation" type="{http://www.w3.org/2001/XMLSchema}string" /> |
|---|
| 145 | * <attribute name="schemaLocation" type="{http://www.w3.org/2001/XMLSchema}string" /> |
|---|
| 146 | * </restriction> |
|---|
| 147 | * </complexContent> |
|---|
| 148 | * </complexType> |
|---|
| 149 | * </pre> |
|---|
| 150 | * |
|---|
| 151 | * |
|---|
| 152 | */ |
|---|
| 153 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 154 | @XmlType(name = "") |
|---|
| 155 | public static class Schema |
|---|
| 156 | implements Child |
|---|
| 157 | { |
|---|
| 158 | |
|---|
| 159 | @XmlAttribute(namespace = "http://schemas.openxmlformats.org/schemaLibrary/2006/main") |
|---|
| 160 | protected String uri; |
|---|
| 161 | @XmlAttribute(namespace = "http://schemas.openxmlformats.org/schemaLibrary/2006/main") |
|---|
| 162 | protected String manifestLocation; |
|---|
| 163 | @XmlAttribute(namespace = "http://schemas.openxmlformats.org/schemaLibrary/2006/main") |
|---|
| 164 | protected String schemaLocation; |
|---|
| 165 | @XmlTransient |
|---|
| 166 | private Object parent; |
|---|
| 167 | |
|---|
| 168 | /** |
|---|
| 169 | * Gets the value of the uri property. |
|---|
| 170 | * |
|---|
| 171 | * @return |
|---|
| 172 | * possible object is |
|---|
| 173 | * {@link String } |
|---|
| 174 | * |
|---|
| 175 | */ |
|---|
| 176 | public String getUri() { |
|---|
| 177 | if (uri == null) { |
|---|
| 178 | return ""; |
|---|
| 179 | } else { |
|---|
| 180 | return uri; |
|---|
| 181 | } |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | /** |
|---|
| 185 | * Sets the value of the uri property. |
|---|
| 186 | * |
|---|
| 187 | * @param value |
|---|
| 188 | * allowed object is |
|---|
| 189 | * {@link String } |
|---|
| 190 | * |
|---|
| 191 | */ |
|---|
| 192 | public void setUri(String value) { |
|---|
| 193 | this.uri = value; |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | /** |
|---|
| 197 | * Gets the value of the manifestLocation property. |
|---|
| 198 | * |
|---|
| 199 | * @return |
|---|
| 200 | * possible object is |
|---|
| 201 | * {@link String } |
|---|
| 202 | * |
|---|
| 203 | */ |
|---|
| 204 | public String getManifestLocation() { |
|---|
| 205 | return manifestLocation; |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | /** |
|---|
| 209 | * Sets the value of the manifestLocation property. |
|---|
| 210 | * |
|---|
| 211 | * @param value |
|---|
| 212 | * allowed object is |
|---|
| 213 | * {@link String } |
|---|
| 214 | * |
|---|
| 215 | */ |
|---|
| 216 | public void setManifestLocation(String value) { |
|---|
| 217 | this.manifestLocation = value; |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | /** |
|---|
| 221 | * Gets the value of the schemaLocation property. |
|---|
| 222 | * |
|---|
| 223 | * @return |
|---|
| 224 | * possible object is |
|---|
| 225 | * {@link String } |
|---|
| 226 | * |
|---|
| 227 | */ |
|---|
| 228 | public String getSchemaLocation() { |
|---|
| 229 | return schemaLocation; |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | /** |
|---|
| 233 | * Sets the value of the schemaLocation property. |
|---|
| 234 | * |
|---|
| 235 | * @param value |
|---|
| 236 | * allowed object is |
|---|
| 237 | * {@link String } |
|---|
| 238 | * |
|---|
| 239 | */ |
|---|
| 240 | public void setSchemaLocation(String value) { |
|---|
| 241 | this.schemaLocation = value; |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | /** |
|---|
| 245 | * Gets the parent object in the object tree representing the unmarshalled xml document. |
|---|
| 246 | * |
|---|
| 247 | * @return |
|---|
| 248 | * The parent object. |
|---|
| 249 | */ |
|---|
| 250 | public Object getParent() { |
|---|
| 251 | return this.parent; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | public void setParent(Object parent) { |
|---|
| 255 | this.parent = parent; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | /** |
|---|
| 259 | * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. |
|---|
| 260 | * |
|---|
| 261 | * @param parent |
|---|
| 262 | * The parent object in the object tree. |
|---|
| 263 | * @param unmarshaller |
|---|
| 264 | * The unmarshaller that generated the instance. |
|---|
| 265 | */ |
|---|
| 266 | public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { |
|---|
| 267 | setParent(parent); |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | } |
|---|