1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/java/JavaStructureType.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,175 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.internal.ws.processor.model.java; 1.30 + 1.31 +import com.sun.tools.internal.ws.processor.model.ModelException; 1.32 + 1.33 +import java.util.*; 1.34 + 1.35 +/** 1.36 + * 1.37 + * @author WS Development Team 1.38 + */ 1.39 +public class JavaStructureType extends JavaType { 1.40 + 1.41 + public JavaStructureType() {} 1.42 + 1.43 + public JavaStructureType(String name, boolean present, Object owner) { 1.44 + super(name, present, "null"); 1.45 + this.owner = owner; 1.46 + } 1.47 + 1.48 + public void add(JavaStructureMember m) { 1.49 + if (membersByName.containsKey(m.getName())) { 1.50 + throw new ModelException("model.uniqueness.javastructuretype", 1.51 + new Object[] {m.getName(), getRealName()}); 1.52 + } 1.53 + members.add(m); 1.54 + membersByName.put(m.getName(), m); 1.55 + } 1.56 + 1.57 + 1.58 + public JavaStructureMember getMemberByName(String name) { 1.59 + if (membersByName.size() != members.size()) { 1.60 + initializeMembersByName(); 1.61 + } 1.62 + return membersByName.get(name); 1.63 + } 1.64 + 1.65 + public Iterator getMembers() { 1.66 + return members.iterator(); 1.67 + } 1.68 + 1.69 + public int getMembersCount() { 1.70 + return members.size(); 1.71 + } 1.72 + 1.73 + /* serialization */ 1.74 + public List<JavaStructureMember> getMembersList() { 1.75 + return members; 1.76 + } 1.77 + 1.78 + /* serialization */ 1.79 + public void setMembersList(List<JavaStructureMember> l) { 1.80 + members = l; 1.81 + } 1.82 + 1.83 + private void initializeMembersByName() { 1.84 + membersByName = new HashMap<String, JavaStructureMember>(); 1.85 + if (members != null) { 1.86 + for (JavaStructureMember m : members) { 1.87 + if (m.getName() != null && 1.88 + membersByName.containsKey(m.getName())) { 1.89 + 1.90 + throw new ModelException("model.uniqueness"); 1.91 + } 1.92 + membersByName.put(m.getName(), m); 1.93 + } 1.94 + } 1.95 + } 1.96 + 1.97 + public boolean isAbstract() { 1.98 + return isAbstract; 1.99 + } 1.100 + 1.101 + public void setAbstract(boolean isAbstract) { 1.102 + this.isAbstract = isAbstract; 1.103 + } 1.104 + 1.105 + public JavaStructureType getSuperclass() { 1.106 + return superclass; 1.107 + } 1.108 + 1.109 + public void setSuperclass(JavaStructureType superclassType) { 1.110 + superclass = superclassType; 1.111 + } 1.112 + 1.113 + public void addSubclass(JavaStructureType subclassType) { 1.114 + subclasses.add(subclassType); 1.115 + subclassType.setSuperclass(this); 1.116 + } 1.117 + 1.118 + public Iterator getSubclasses() { 1.119 + if (subclasses == null || subclasses.size() == 0) { 1.120 + return null; 1.121 + } 1.122 + return subclasses.iterator(); 1.123 + } 1.124 + 1.125 + public Set getSubclassesSet() { 1.126 + return subclasses; 1.127 + } 1.128 + 1.129 + /* serialization */ 1.130 + public void setSubclassesSet(Set s) { 1.131 + subclasses = s; 1.132 + for (Iterator iter = s.iterator(); iter.hasNext();) { 1.133 + ((JavaStructureType) iter.next()).setSuperclass(this); 1.134 + } 1.135 + } 1.136 + 1.137 + public Iterator getAllSubclasses() { 1.138 + Set subs = getAllSubclassesSet(); 1.139 + if (subs.size() == 0) { 1.140 + return null; 1.141 + } 1.142 + return subs.iterator(); 1.143 + } 1.144 + 1.145 + public Set getAllSubclassesSet() { 1.146 + Set transitiveSet = new HashSet(); 1.147 + Iterator subs = subclasses.iterator(); 1.148 + while (subs.hasNext()) { 1.149 + transitiveSet.addAll( 1.150 + ((JavaStructureType)subs.next()).getAllSubclassesSet()); 1.151 + } 1.152 + transitiveSet.addAll(subclasses); 1.153 + return transitiveSet; 1.154 + } 1.155 + 1.156 + public Object getOwner() { 1.157 + 1.158 + // usually a SOAPStructureType 1.159 + return owner; 1.160 + } 1.161 + 1.162 + public void setOwner(Object owner) { 1.163 + 1.164 + // usually a SOAPStructureType 1.165 + this.owner = owner; 1.166 + } 1.167 + 1.168 + private List<JavaStructureMember> members = new ArrayList(); 1.169 + private Map<String, JavaStructureMember> membersByName = new HashMap(); 1.170 + 1.171 + // known subclasses of this type 1.172 + private Set subclasses = new HashSet(); 1.173 + private JavaStructureType superclass; 1.174 + 1.175 + // usually a SOAPStructureType 1.176 + private Object owner; 1.177 + private boolean isAbstract = false; 1.178 +}