Skip to main content
summaryrefslogtreecommitdiffstats
blob: ff14b85d999c9f03e4d7cf49686f9bcd06a5db88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*******************************************************************************
 * Copyright (c) 2002-2005 IBM Corporation and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   IBM - Initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.wsi.internal.core.analyzer.config.impl;

import java.io.PrintWriter;
import java.io.StringWriter;

import javax.xml.namespace.QName;

import org.eclipse.wst.wsi.internal.core.WSIConstants;
import org.eclipse.wst.wsi.internal.core.analyzer.config.WSDLElement;
import org.eclipse.wst.wsi.internal.core.util.EntryType;

/**
 * The implementation for WSDL definitions. 
 * 
 * @version 1.0.1
 * @author Peter Brittenham  (peterbr@us.ibm.com)
 */
public class WSDLElementImpl implements WSDLElement
{
  protected String type;
  protected String namespace;
  protected String name;
  protected String parentElementName;

  /**
   * @see #setType
   */
  public String getType()
  {
    return this.type;
  }

  /**
   * @see #getType
   */
  public void setType(String type)
  {
    this.type = type;
  }

  /**
   * @see #setNamespace
   */
  public String getNamespace()
  {
    return this.namespace;
  }

  /**
   * @see #getNamespace
   */
  public void setNamespace(String namespace)
  {
    this.namespace = namespace;
  }

  /**
   * @see #setName
   */
  public String getName()
  {
    return this.name;
  }

  /**
   * @see #getName
   */
  public void setName(String name)
  {
    this.name = name;
  }

  public QName getQName()
  {
    return new QName(this.namespace, this.name);
  }

  /**
   * Get WSDL parent element name.
   * @see #setParentElementName
  
   */
  public String getParentElementName()
  {
    return this.parentElementName;
  }

  /**
   * Set WSDL parent element name.
   * @see #getParentElementName
   */
  public void setParentElementName(String parentElementName)
  {
    this.parentElementName = parentElementName;
  }

  /**
   * @see org.eclipse.wst.wsi.test.analyzer.config.WSDLElement#getParentElementQName()
   */
  public QName getParentElementQName()
  {
    return new QName(this.namespace, this.parentElementName);
  }

  /**
   * Is port element.
   */
  public boolean isPort()
  {
    return type.equals(EntryType.TYPE_DESCRIPTION_PORT);
  }

  /**
   * Is binding element.
   */
  public boolean isBinding()
  {
    return type.equals(EntryType.TYPE_DESCRIPTION_BINDING);
  }

  /**
   * Is portType element.
   */
  public boolean isPortType()
  {
    return type.equals(EntryType.TYPE_DESCRIPTION_PORTTYPE);
  }

  /**
   * Is operation element.
   */
  public boolean isOperation()
  {
    return type.equals(EntryType.TYPE_DESCRIPTION_OPERATION);
  }

  /**
   * Is message element.
   */
  public boolean isMessage()
  {
    return type.equals(EntryType.TYPE_DESCRIPTION_MESSAGE);
  }

  /**
   * Get string representation of this object.
   */
  public String toString()
  {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    pw.println("    WSDL Element: ");
    pw.println("      type ................... " + this.type);
    pw.println("      namespace .............. " + this.namespace);
    pw.println("      name ................... " + this.name);

    if (this.parentElementName != null)
      pw.println("      parentElementName ...... " + this.parentElementName);

    return sw.toString();
  }

  /**
   * Get representation of this object as an XML string.
   */
  public String toXMLString(String namespaceName)
  {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    String nsName = namespaceName;
    if ((!nsName.equals("") && (!nsName.endsWith(":"))))
      nsName += ":";

    // Config options
    pw.print("        <" + nsName + ELEM_NAME + " ");
    pw.print(WSIConstants.ATTR_TYPE + "=\"" + getType() + "\" ");
    pw.print(WSIConstants.ATTR_NAMESPACE + "=\"" + getNamespace() + "\" ");
    if (this.parentElementName != null)
      pw.print(
        WSIConstants.ATTR_PARENT_ELEMENT_NAME
          + "=\""
          + getParentElementName()
          + "\"");
    pw.print(">");
    pw.print(getName());
    pw.println("</" + nsName + ELEM_NAME + ">");

    return sw.toString();
  }
}

Back to the top