1 /*
2 * Copyright (c) 1997, 2012, 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.dtd.bindinfo;
27
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33 import javax.xml.namespace.QName;
34
35 import com.sun.tools.internal.xjc.model.CClassInfo;
36 import com.sun.xml.internal.bind.api.impl.NameConverter;
37
38 import org.w3c.dom.Element;
39 import org.xml.sax.Locator;
40
41
42 /**
43 * <element> declaration in the binding file.
44 */
45 public final class BIElement
46 {
47 /**
48 * Wraps a given <element> element in the binding file.
49 *
50 * <p>
51 * Should be created only from {@link BindInfo}.
52 */
53 BIElement( BindInfo bi, Element _e ) {
54 this.parent = bi;
55 this.e = _e;
56
57 {
58 Element c = DOMUtil.getElement(e,"content");
59 if(c!=null) {
60 if(DOMUtil.getAttribute(c,"property")!=null) {
61 // if @property is there, this is a general declaration
62 this.rest = BIContent.create(c,this);
63 } else {
64 // this must be a model-based declaration
65 for( Element p : DOMUtil.getChildElements(c) ) {
66 if(p.getLocalName().equals("rest"))
67 this.rest = BIContent.create(p,this);
68 else
105 constructors.add( new BIConstructor(c) );
106 }
107
108 String name = name();
109 QName tagName = new QName("",name);
110
111 this.clazz = new CClassInfo(parent.model,parent.getTargetPackage(),className,getLocation(),null,tagName,null,null/*TODO*/);
112 }
113
114 /**
115 * Gets the source location where this element is declared.
116 */
117 public Locator getLocation() {
118 return DOMLocator.getLocationInfo(e);
119 }
120
121
122 /** The parent {@link BindInfo} object to which this object belongs. */
123 final BindInfo parent;
124
125 /** <element> element which this object is wrapping. */
126 private final Element e;
127
128 /**
129 * The bean representation for this element.
130 */
131 public final CClassInfo clazz;
132
133 /**
134 * Content-property declarations.
135 * <p>
136 * This vector will be empty if no content-property declaration is made.
137 */
138 private final List<BIContent> contents = new ArrayList<BIContent>();
139
140 /** Conversion declarations. */
141 private final Map<String,BIConversion> conversions = new HashMap<String,BIConversion>();
142
143 /**
144 * The "rest" content-property declaration.
145 * <p>
|
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.dtd.bindinfo;
27
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33 import javax.xml.namespace.QName;
34
35 import com.sun.tools.internal.xjc.model.CClassInfo;
36 import com.sun.xml.internal.bind.api.impl.NameConverter;
37
38 import org.w3c.dom.Element;
39 import org.xml.sax.Locator;
40
41
42 /**
43 * {@code <element>} declaration in the binding file.
44 */
45 public final class BIElement
46 {
47 /**
48 * Wraps a given {@code <element>} element in the binding file.
49 *
50 * <p>
51 * Should be created only from {@link BindInfo}.
52 */
53 BIElement( BindInfo bi, Element _e ) {
54 this.parent = bi;
55 this.e = _e;
56
57 {
58 Element c = DOMUtil.getElement(e,"content");
59 if(c!=null) {
60 if(DOMUtil.getAttribute(c,"property")!=null) {
61 // if @property is there, this is a general declaration
62 this.rest = BIContent.create(c,this);
63 } else {
64 // this must be a model-based declaration
65 for( Element p : DOMUtil.getChildElements(c) ) {
66 if(p.getLocalName().equals("rest"))
67 this.rest = BIContent.create(p,this);
68 else
105 constructors.add( new BIConstructor(c) );
106 }
107
108 String name = name();
109 QName tagName = new QName("",name);
110
111 this.clazz = new CClassInfo(parent.model,parent.getTargetPackage(),className,getLocation(),null,tagName,null,null/*TODO*/);
112 }
113
114 /**
115 * Gets the source location where this element is declared.
116 */
117 public Locator getLocation() {
118 return DOMLocator.getLocationInfo(e);
119 }
120
121
122 /** The parent {@link BindInfo} object to which this object belongs. */
123 final BindInfo parent;
124
125 /** {@code <element>} element which this object is wrapping. */
126 private final Element e;
127
128 /**
129 * The bean representation for this element.
130 */
131 public final CClassInfo clazz;
132
133 /**
134 * Content-property declarations.
135 * <p>
136 * This vector will be empty if no content-property declaration is made.
137 */
138 private final List<BIContent> contents = new ArrayList<BIContent>();
139
140 /** Conversion declarations. */
141 private final Map<String,BIConversion> conversions = new HashMap<String,BIConversion>();
142
143 /**
144 * The "rest" content-property declaration.
145 * <p>
|