src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Message.java

Tue, 08 Apr 2014 11:26:40 +0100

author
mkos
date
Tue, 08 Apr 2014 11:26:40 +0100
changeset 534
6de45b31d047
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8033113: wsimport fails on WSDL:header parameter name customization
Reviewed-by: chegar

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.tools.internal.ws.processor.model;
ohair@286 27
ohair@286 28 import com.sun.tools.internal.ws.wsdl.framework.Entity;
ohair@286 29 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
ohair@286 30 import com.sun.tools.internal.ws.wscompile.AbortException;
ohair@286 31 import com.sun.tools.internal.ws.resources.ModelMessages;
ohair@286 32
ohair@286 33 import javax.xml.namespace.QName;
ohair@286 34 import java.util.*;
ohair@286 35
ohair@286 36 /**
ohair@286 37 *
ohair@286 38 * @author WS Development Team
ohair@286 39 */
ohair@286 40 public abstract class Message extends ModelObject {
ohair@286 41 protected Message(com.sun.tools.internal.ws.wsdl.document.Message entity, ErrorReceiver receiver) {
ohair@286 42 super(entity);
ohair@286 43 setErrorReceiver(receiver);
ohair@286 44 }
ohair@286 45
ohair@286 46 public void addBodyBlock(Block b) {
ohair@286 47 if (_bodyBlocks.containsKey(b.getName())) {
ohair@286 48 errorReceiver.error(getEntity().getLocator(), ModelMessages.MODEL_PART_NOT_UNIQUE(((com.sun.tools.internal.ws.wsdl.document.Message)getEntity()).getName(), b.getName()));
ohair@286 49 throw new AbortException();
ohair@286 50 }
ohair@286 51 _bodyBlocks.put(b.getName(), b);
ohair@286 52 b.setLocation(Block.BODY);
ohair@286 53 }
ohair@286 54
ohair@286 55 public Iterator<Block> getBodyBlocks() {
ohair@286 56 return _bodyBlocks.values().iterator();
ohair@286 57 }
ohair@286 58
ohair@286 59 public int getBodyBlockCount() {
ohair@286 60 return _bodyBlocks.size();
ohair@286 61 }
ohair@286 62
ohair@286 63 /* serialization */
ohair@286 64 public Map<QName, Block> getBodyBlocksMap() {
ohair@286 65 return _bodyBlocks;
ohair@286 66 }
ohair@286 67
ohair@286 68 /* serialization */
ohair@286 69 public void setBodyBlocksMap(Map<QName, Block> m) {
ohair@286 70 _bodyBlocks = m;
ohair@286 71 }
ohair@286 72
ohair@286 73 public boolean isBodyEmpty() {
ohair@286 74 return getBodyBlocks().hasNext();
ohair@286 75 }
ohair@286 76
ohair@286 77 public boolean isBodyEncoded() {
ohair@286 78 boolean isEncoded = false;
ohair@286 79 for (Iterator iter = getBodyBlocks(); iter.hasNext();) {
ohair@286 80 Block bodyBlock = (Block) iter.next();
ohair@286 81 if (bodyBlock.getType().isSOAPType()) {
ohair@286 82 isEncoded = true;
ohair@286 83 }
ohair@286 84 }
ohair@286 85 return isEncoded;
ohair@286 86 }
ohair@286 87
ohair@286 88 public void addHeaderBlock(Block b) {
ohair@286 89 if (_headerBlocks.containsKey(b.getName())) {
ohair@286 90 errorReceiver.error(getEntity().getLocator(), ModelMessages.MODEL_PART_NOT_UNIQUE(((com.sun.tools.internal.ws.wsdl.document.Message)getEntity()).getName(), b.getName()));
ohair@286 91 throw new AbortException();
ohair@286 92 }
ohair@286 93 _headerBlocks.put(b.getName(), b);
ohair@286 94 b.setLocation(Block.HEADER);
ohair@286 95 }
ohair@286 96
ohair@286 97 public Iterator<Block> getHeaderBlocks() {
ohair@286 98 return _headerBlocks.values().iterator();
ohair@286 99 }
ohair@286 100
ohair@286 101 public Collection<Block> getHeaderBlockCollection() {
ohair@286 102 return _headerBlocks.values();
ohair@286 103 }
ohair@286 104
ohair@286 105 public int getHeaderBlockCount() {
ohair@286 106 return _headerBlocks.size();
ohair@286 107 }
ohair@286 108
ohair@286 109 /* serialization */
ohair@286 110 public Map<QName, Block> getHeaderBlocksMap() {
ohair@286 111 return _headerBlocks;
ohair@286 112 }
ohair@286 113
ohair@286 114 /* serialization */
ohair@286 115 public void setHeaderBlocksMap(Map<QName, Block> m) {
ohair@286 116 _headerBlocks = m;
ohair@286 117 }
ohair@286 118
ohair@286 119 /** attachment block */
ohair@286 120 public void addAttachmentBlock(Block b) {
ohair@286 121 if (_attachmentBlocks.containsKey(b.getName())) {
ohair@286 122 errorReceiver.error(getEntity().getLocator(), ModelMessages.MODEL_PART_NOT_UNIQUE(((com.sun.tools.internal.ws.wsdl.document.Message)getEntity()).getName(), b.getName()));
ohair@286 123 throw new AbortException();
ohair@286 124 }
ohair@286 125 _attachmentBlocks.put(b.getName(), b);
ohair@286 126 b.setLocation(Block.ATTACHMENT);
ohair@286 127 }
ohair@286 128
ohair@286 129 public void addUnboundBlock(Block b) {
ohair@286 130 if (_unboundBlocks.containsKey(b.getName())) {
ohair@286 131 return;
ohair@286 132 }
ohair@286 133 _unboundBlocks.put(b.getName(), b);
ohair@286 134 b.setLocation(Block.UNBOUND);
ohair@286 135 }
ohair@286 136
ohair@286 137 public Iterator<Block> getUnboundBlocks() {
ohair@286 138 return _unboundBlocks.values().iterator();
ohair@286 139 }
ohair@286 140
ohair@286 141 /* serialization */
ohair@286 142 public Map<QName, Block> getUnboundBlocksMap() {
ohair@286 143 return _unboundBlocks;
ohair@286 144 }
ohair@286 145
ohair@286 146 public int getUnboundBlocksCount() {
ohair@286 147 return _unboundBlocks.size();
ohair@286 148 }
ohair@286 149
ohair@286 150 /* serialization */
ohair@286 151 public void setUnboundBlocksMap(Map<QName, Block> m) {
ohair@286 152 _unboundBlocks = m;
ohair@286 153 }
ohair@286 154
ohair@286 155
ohair@286 156 public Iterator<Block> getAttachmentBlocks() {
ohair@286 157 return _attachmentBlocks.values().iterator();
ohair@286 158 }
ohair@286 159
ohair@286 160 public int getAttachmentBlockCount () {
ohair@286 161 return _attachmentBlocks.size();
ohair@286 162 }
ohair@286 163
ohair@286 164 /* serialization */
ohair@286 165 public Map<QName, Block> getAttachmentBlocksMap() {
ohair@286 166 return _attachmentBlocks;
ohair@286 167 }
ohair@286 168
ohair@286 169 /* serialization */
ohair@286 170 public void setAttachmentBlocksMap(Map<QName, Block> m) {
ohair@286 171 _attachmentBlocks = m;
ohair@286 172 }
ohair@286 173
ohair@286 174 public void addParameter(Parameter p) {
ohair@286 175 if (_parametersByName.containsKey(p.getName())) {
ohair@286 176 errorReceiver.error(getEntity().getLocator(), ModelMessages.MODEL_PARAMETER_NOTUNIQUE(p.getName(), p.getName()));
ohair@286 177 throw new AbortException();
ohair@286 178 }
ohair@286 179 _parameters.add(p);
mkos@534 180 String name = p.getCustomName() != null ? p.getCustomName() : p.getName();
mkos@534 181 _parametersByName.put(name, p);
ohair@286 182 }
ohair@286 183
ohair@286 184 public Parameter getParameterByName(String name) {
ohair@286 185 if (_parametersByName.size() != _parameters.size()) {
ohair@286 186 initializeParametersByName();
ohair@286 187 }
ohair@286 188 return _parametersByName.get(name);
ohair@286 189 }
ohair@286 190
ohair@286 191 public Iterator<Parameter> getParameters() {
ohair@286 192 return _parameters.iterator();
ohair@286 193 }
ohair@286 194
ohair@286 195 /* serialization */
ohair@286 196 public List<Parameter> getParametersList() {
ohair@286 197 return _parameters;
ohair@286 198 }
ohair@286 199
ohair@286 200 /* serialization */
ohair@286 201 public void setParametersList(List<Parameter> l) {
ohair@286 202 _parameters = l;
ohair@286 203 }
ohair@286 204
ohair@286 205 private void initializeParametersByName() {
ohair@286 206 _parametersByName = new HashMap();
ohair@286 207 if (_parameters != null) {
ohair@286 208 for (Iterator iter = _parameters.iterator(); iter.hasNext();) {
ohair@286 209 Parameter param = (Parameter) iter.next();
ohair@286 210 if (param.getName() != null &&
ohair@286 211 _parametersByName.containsKey(param.getName())) {
ohair@286 212 errorReceiver.error(getEntity().getLocator(), ModelMessages.MODEL_PARAMETER_NOTUNIQUE(param.getName(), param.getName()));
ohair@286 213 throw new AbortException();
ohair@286 214 }
ohair@286 215 _parametersByName.put(param.getName(), param);
ohair@286 216 }
ohair@286 217 }
ohair@286 218 }
ohair@286 219
ohair@286 220 public Set<Block> getAllBlocks(){
ohair@286 221 Set<Block> blocks = new HashSet<Block>();
ohair@286 222 blocks.addAll(_bodyBlocks.values());
ohair@286 223 blocks.addAll(_headerBlocks.values());
ohair@286 224 blocks.addAll(_attachmentBlocks.values());
ohair@286 225 return blocks;
ohair@286 226 }
ohair@286 227
ohair@286 228 private Map<QName, Block> _attachmentBlocks = new HashMap<QName, Block>();
ohair@286 229 private Map<QName, Block> _bodyBlocks = new HashMap<QName, Block>();
ohair@286 230 private Map<QName, Block> _headerBlocks = new HashMap<QName, Block>();
ohair@286 231 private Map<QName, Block> _unboundBlocks = new HashMap<QName, Block>();
ohair@286 232 private List<Parameter> _parameters = new ArrayList<Parameter>();
ohair@286 233 private Map<String, Parameter> _parametersByName = new HashMap<String, Parameter>();
ohair@286 234 }

mercurial