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.ws.processor.model;
  27 
  28 import com.sun.tools.internal.ws.processor.model.java.JavaParameter;
  29 import com.sun.tools.internal.ws.wsdl.framework.Entity;
  30 import com.sun.tools.internal.ws.wsdl.document.MessagePart;
  31 
  32 import javax.jws.WebParam.Mode;
  33 import java.util.ArrayList;
  34 import java.util.List;
  35 
  36 /**
  37  *
  38  * @author WS Development Team
  39  */
  40 public class Parameter extends ModelObject {
  41     private final String entityName;
  42 
  43     public Parameter(String name, Entity entity) {
  44         super(entity);
  45         this.name = name;
  46         if(entity instanceof com.sun.tools.internal.ws.wsdl.document.Message){
  47             this.entityName = ((com.sun.tools.internal.ws.wsdl.document.Message)entity).getName();
  48         }else if(entity instanceof MessagePart){
  49             this.entityName = ((MessagePart)entity).getName();
  50         }else{
  51             this.entityName = name;
  52         }
  53 
  54     }
  55 
  56 
  57     public String getEntityName() {
  58         return entityName;
  59     }
  60 
  61     public String getName() {
  62         return name;
  63     }
  64 
  65     public void setName(String s) {
  66         name = s;
  67     }
  68 
  69     public JavaParameter getJavaParameter() {
  70         return javaParameter;
  71     }
  72 
  73     public void setJavaParameter(JavaParameter p) {
  74         javaParameter = p;
  75     }
  76 
  77     public AbstractType getType() {
  78         return type;
  79     }
  80 
  81     public void setType(AbstractType t) {
  82         type = t;
  83     }
  84 
  85     public String getTypeName() {
  86         return typeName;
  87     }
  88 
  89     public void setTypeName(String t) {
  90         typeName = t;
  91     }
  92 
  93     public Block getBlock() {
  94         return block;
  95     }
  96 
  97     public void setBlock(Block d) {
  98         block = d;
  99     }
 100 
 101     public Parameter getLinkedParameter() {
 102         return link;
 103     }
 104 
 105     public void setLinkedParameter(Parameter p) {
 106         link = p;
 107     }
 108 
 109     public boolean isEmbedded() {
 110         return embedded;
 111     }
 112 
 113     public void setEmbedded(boolean b) {
 114         embedded = b;
 115     }
 116 
 117     public void accept(ModelVisitor visitor) throws Exception {
 118         visitor.visit(this);
 119     }
 120 
 121     private String name;
 122     private JavaParameter javaParameter;
 123     private AbstractType type;
 124     private Block block;
 125     private Parameter link;
 126     private boolean embedded;
 127     private String typeName;
 128     private String customName;
 129     private Mode mode;
 130 
 131     public int getParameterIndex() {
 132         return parameterOrderPosition;
 133     }
 134 
 135     public void setParameterIndex(int parameterOrderPosition) {
 136         this.parameterOrderPosition = parameterOrderPosition;
 137     }
 138 
 139     public boolean isReturn(){
 140         return (parameterOrderPosition == -1);
 141     }
 142 
 143     // 0 is the first parameter, -1 is the return type
 144     private int parameterOrderPosition;
 145     /**
 146      * @return Returns the customName.
 147      */
 148     public String getCustomName() {
 149         return customName;
 150     }
 151     /**
 152      * @param customName The customName to set.
 153      */
 154     public void setCustomName(String customName) {
 155         this.customName = customName;
 156     }
 157 
 158     private List<String> annotations = new ArrayList<String>();
 159 
 160     /**
 161      * @return Returns the annotations.
 162      */
 163     public List<String> getAnnotations() {
 164         return annotations;
 165     }
 166 
 167 
 168     /**
 169      * @param annotations The annotations to set.
 170      */
 171     public void setAnnotations(List<String> annotations) {
 172         this.annotations = annotations;
 173     }
 174 
 175     public void setMode(Mode mode){
 176         this.mode = mode;
 177     }
 178 
 179     public boolean isIN(){
 180         return (mode == Mode.IN);
 181     }
 182 
 183     public boolean isOUT(){
 184         return (mode == Mode.OUT);
 185     }
 186 
 187     public boolean isINOUT(){
 188         return (mode == Mode.INOUT);
 189     }
 190 
 191 
 192 
 193 }