Skip to main content
summaryrefslogtreecommitdiffstats
blob: cf18c2e0d365d156ac9097e45f2ea8e53f2398f6 (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
/*******************************************************************************
 * Copyright (c) 2001, 2004 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 Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.wsdl.validation.internal.wsdl11;

import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.apache.xerces.xs.XSModel;
import org.eclipse.wst.wsdl.validation.internal.Constants;
import org.eclipse.wst.wsdl.validation.internal.IValidationInfo;
import org.eclipse.wst.wsdl.validation.internal.ValidationInfoImpl;
import org.eclipse.wst.wsdl.validation.internal.resolver.URIResolver;

/**
 * An implemenation of WSDL11ValidationInfo.
 */
public class WSDL11ValidationInfoImpl implements IWSDL11ValidationInfo
{
  private IValidationInfo valinfo = null;
  private Hashtable elementlocations = null;
  private List schemas = new Vector();
  
  public WSDL11ValidationInfoImpl(IValidationInfo valinfo)
  {
    this.valinfo = valinfo;
  }
  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#getFileURI()
   */
  public String getFileURI()
  {
    return valinfo.getFileURI();
  }

  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addSchema(org.apache.xerces.xs.XSModel)
   */
  public void addSchema(XSModel xsModel)
  {
    if (xsModel != null)
    {
      schemas.add(xsModel);
    }

  }

  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#getSchemas()
   */
  public XSModel[] getSchemas()
  {
    return (XSModel[])schemas.toArray(new XSModel[schemas.size()]);
  }

  /* (non-Javadoc)
   * @see org.eclipse.wsdl.validate.wsdl11.WSDL11ValidationInfo#cleardSchemas()
   */
  public void clearSchemas()
  {
    schemas.clear();
  }
  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#setElementLocations(java.util.Hashtable)
   */
  public void setElementLocations(Hashtable elementLocations)
  {
    this.elementlocations = elementLocations;
  }

  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addError(java.lang.String, java.lang.Object)
   */
  public void addError(String message, Object element)
  {
    addError(message, element, null, null);
  }
  
  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addError(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object[])
   */
  public void addError(String message, Object element, String errorKey, Object[] messageArguments)
  {
    LocationHolder location;
    if (elementlocations.containsKey(element))
    {
      location = (LocationHolder)elementlocations.get(element);
      addError(message, location.getLine(), location.getColumn(), location.getURI(), errorKey, messageArguments);
    }
    // if we give it an element that hasn't been defined we'll set the location
    // at (0,0) so the error shows up but no line marker in the editor
    else
    {
      addError(message, 0, 1, getFileURI());
    }
  }

  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addWarning(java.lang.String, java.lang.Object)
   */
  public void addWarning(String message, Object element)
  {
    LocationHolder location;
    if (elementlocations.containsKey(element))
    {
      location = (LocationHolder)elementlocations.get(element);
      addWarning(message, location.getLine(), location.getColumn(), location.getURI());
    }
    // if we give it an element that hasn't been defined we'll set the location
    // at (0,0) so the error shows up but no line marker in the editor
    else
    {
      addWarning(message, 0, 1, getFileURI());
    }

  }

  /**
   * @see org.eclipse.wsdl.validate.wsdl11.WSDL11ValidationInfo#addNamespaceWithNoValidator(java.lang.String)
   */
//  public void addNamespaceWithNoValidator(String namespace)
//  {
//    valinfo.addNamespaceWithNoValidator(namespace);
//
//  }

  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addError(java.lang.String, int, int)
   */
  public void addError(String message, int line, int column, String uri)
  {
    addError(message, line, column, uri, null, null);
  }

  public void addError(String message, int line, int column, String uri, String errorKey, Object[] messageArguments)
  { 
    try
    { ((ValidationInfoImpl)valinfo).addError(message, line, column, uri, errorKey, messageArguments);
    }
    catch (ClassCastException e)
    {
      valinfo.addError(message, line, column, uri);
    }
  }
  
  /**
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#addWarning(java.lang.String, int, int)
   */
  public void addWarning(String message, int line, int column, String uri)
  {
    valinfo.addWarning(message, line, column, uri);
  }

  /* (non-Javadoc)
   * @see org.eclipse.wsdl.validate.wsdl11.WSDL11ValidationInfo#getURIResolver()
   */
  public URIResolver getURIResolver() 
  {
	return valinfo.getURIResolver();
  }
  
  /* (non-Javadoc)
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#getSchemaCache()
   */
  public XMLGrammarPool getSchemaCache() 
  {
	XMLGrammarPool grammarPool = (XMLGrammarPool)valinfo.getAttribute(Constants.XMLSCHEMA_CACHE_ATTRIBUTE);
	return grammarPool;
  }
  
  /* (non-Javadoc)
   * @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11ValidationInfo#getXMLCache()
   */
  public XMLGrammarPool getXMLCache() 
  {
	XMLGrammarPool grammarPool = (XMLGrammarPool)valinfo.getAttribute(Constants.XML_CACHE_ATTRIBUTE);
	return grammarPool;
  }
  
}

Back to the top