1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo;
27
28 import java.io.FilterWriter;
29 import java.io.IOException;
30 import java.io.StringWriter;
31 import java.io.Writer;
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.List;
35
36 import javax.xml.bind.JAXBContext;
37 import javax.xml.bind.JAXBException;
38 import javax.xml.bind.Unmarshaller;
39 import javax.xml.bind.annotation.XmlAnyElement;
40 import javax.xml.bind.annotation.XmlElement;
41 import javax.xml.bind.annotation.XmlMixed;
42 import javax.xml.bind.annotation.XmlRootElement;
43 import javax.xml.bind.annotation.XmlType;
44 import javax.xml.transform.Transformer;
45 import javax.xml.transform.TransformerException;
46 import javax.xml.transform.dom.DOMSource;
47 import javax.xml.transform.stream.StreamResult;
48
49 import com.sun.codemodel.internal.JDocComment;
50 import com.sun.xml.internal.bind.v2.WellKnownNamespace;
51 import com.sun.tools.internal.xjc.SchemaCache;
52 import com.sun.tools.internal.xjc.model.CCustomizations;
53 import com.sun.tools.internal.xjc.model.CPluginCustomization;
54 import com.sun.tools.internal.xjc.model.Model;
55 import com.sun.tools.internal.xjc.reader.Ring;
56 import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
57 import com.sun.xml.internal.bind.annotation.XmlLocation;
58 import com.sun.xml.internal.bind.marshaller.MinimumEscapeHandler;
59 import com.sun.xml.internal.xsom.XSComponent;
60
61 import org.w3c.dom.Element;
62 import org.xml.sax.Locator;
63
64 /**
65 * Container for customization declarations.
66 *
67 * We use JAXB ourselves and parse this object from "xs:annotation".
68 *
69 * @author
70 * Kohsuke Kawaguchi (kohsuke,kawaguchi@sun.com)
71 */
72 @XmlRootElement(namespace= WellKnownNamespace.XML_SCHEMA,name="annotation")
73 @XmlType(namespace=WellKnownNamespace.XML_SCHEMA,name="foobar")
74 public final class BindInfo implements Iterable<BIDeclaration> {
75
76 private BGMBuilder builder;
77
78 @XmlLocation
79 private Locator location;
80
81 /**
336 }
337 }
338 }
339 return customizationContext;
340 } catch (JAXBException e) {
341 throw new AssertionError(e);
342 }
343 }
344
345 public static Unmarshaller getCustomizationUnmarshaller() {
346 try {
347 return getCustomizationContext().createUnmarshaller();
348 } catch (JAXBException e) {
349 throw new AssertionError(e);
350 }
351 }
352
353 /**
354 * Lazily parsed schema for the binding file.
355 */
356 public static final SchemaCache bindingFileSchema = new SchemaCache(BindInfo.class.getResource("binding.xsd"));
357 }
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo;
27
28 import java.io.FilterWriter;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import java.io.Reader;
32 import java.io.StringWriter;
33 import java.io.Writer;
34 import java.util.ArrayList;
35 import java.util.Iterator;
36 import java.util.List;
37
38 import javax.xml.bind.JAXBContext;
39 import javax.xml.bind.JAXBException;
40 import javax.xml.bind.Unmarshaller;
41 import javax.xml.bind.annotation.XmlAnyElement;
42 import javax.xml.bind.annotation.XmlElement;
43 import javax.xml.bind.annotation.XmlMixed;
44 import javax.xml.bind.annotation.XmlRootElement;
45 import javax.xml.bind.annotation.XmlType;
46 import javax.xml.transform.Transformer;
47 import javax.xml.transform.TransformerException;
48 import javax.xml.transform.dom.DOMSource;
49 import javax.xml.transform.stream.StreamResult;
50 import javax.xml.transform.stream.StreamSource;
51
52 import com.sun.codemodel.internal.JDocComment;
53 import com.sun.xml.internal.bind.v2.WellKnownNamespace;
54 import com.sun.tools.internal.xjc.SchemaCache;
55 import com.sun.tools.internal.xjc.model.CCustomizations;
56 import com.sun.tools.internal.xjc.model.CPluginCustomization;
57 import com.sun.tools.internal.xjc.model.Model;
58 import com.sun.tools.internal.xjc.reader.Ring;
59 import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
60 import com.sun.xml.internal.bind.annotation.XmlLocation;
61 import com.sun.xml.internal.bind.marshaller.MinimumEscapeHandler;
62 import com.sun.xml.internal.xsom.XSComponent;
63
64 import org.w3c.dom.Element;
65 import org.w3c.dom.ls.LSInput;
66 import org.w3c.dom.ls.LSResourceResolver;
67 import org.xml.sax.Locator;
68
69 /**
70 * Container for customization declarations.
71 *
72 * We use JAXB ourselves and parse this object from "xs:annotation".
73 *
74 * @author
75 * Kohsuke Kawaguchi (kohsuke,kawaguchi@sun.com)
76 */
77 @XmlRootElement(namespace= WellKnownNamespace.XML_SCHEMA,name="annotation")
78 @XmlType(namespace=WellKnownNamespace.XML_SCHEMA,name="foobar")
79 public final class BindInfo implements Iterable<BIDeclaration> {
80
81 private BGMBuilder builder;
82
83 @XmlLocation
84 private Locator location;
85
86 /**
341 }
342 }
343 }
344 return customizationContext;
345 } catch (JAXBException e) {
346 throw new AssertionError(e);
347 }
348 }
349
350 public static Unmarshaller getCustomizationUnmarshaller() {
351 try {
352 return getCustomizationContext().createUnmarshaller();
353 } catch (JAXBException e) {
354 throw new AssertionError(e);
355 }
356 }
357
358 /**
359 * Lazily parsed schema for the binding file.
360 */
361 public static SchemaCache bindingFileSchema =
362 new SchemaCache(
363 newStreamSource("binding.xsd"),
364 new LSResourceResolver() {
365 @Override
366 public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
367 // XSOM passes the namespace URI to the publicID parameter.
368 // we do the same here .
369 InputStream is = BindInfo.class.getResourceAsStream(systemId);
370 return new Input(is, publicId, systemId);
371 }
372 }
373 );
374
375 private static StreamSource newStreamSource(String systemId) {
376 InputStream is = BindInfo.class.getResourceAsStream(systemId);
377 StreamSource schema = new StreamSource(is);
378 schema.setSystemId(systemId);
379 return schema;
380 }
381
382 }
383
384 class Input implements LSInput {
385
386 InputStream is;
387 String publicId;
388 String systemId;
389
390 public Input(InputStream is, String publicId, String systemId) {
391 this.is = is;
392 this.publicId = publicId;
393 this.systemId = systemId;
394 }
395
396 @Override
397 public Reader getCharacterStream() {
398 return null;
399 }
400
401 @Override
402 public void setCharacterStream(Reader characterStream) {
403 }
404
405 @Override
406 public InputStream getByteStream() {
407 return is;
408 }
409
410 @Override
411 public void setByteStream(InputStream byteStream) {
412 }
413
414 @Override
415 public String getStringData() {
416 return null;
417 }
418
419 @Override
420 public void setStringData(String stringData) {
421 }
422
423 @Override
424 public String getSystemId() {
425 return systemId;
426 }
427
428 @Override
429 public void setSystemId(String systemId) {
430 }
431
432 @Override
433 public String getPublicId() {
434 return publicId;
435 }
436
437 @Override
438 public void setPublicId(String publicId) {
439 }
440
441 @Override
442 public String getBaseURI() {
443 return null;
444 }
445
446 @Override
447 public void setBaseURI(String baseURI) {
448 }
449
450 @Override
451 public String getEncoding() {
452 return null;
453 }
454
455 @Override
456 public void setEncoding(String encoding) {
457 }
458
459 @Override
460 public boolean getCertifiedText() {
461 return false;
462 }
463
464 @Override
465 public void setCertifiedText(boolean certifiedText) {
466 }
467 }
|