Skip to main content
summaryrefslogtreecommitdiffstats
blob: aa7fc1ae286128cde31f62d399a569fa8c4b9773 (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
/*******************************************************************************
 * 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;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * A validation message is created when there is information to report from
 * validating a WSDL document.
 */
public class ValidationMessageImpl implements IValidationMessage
{
  protected String message;
  protected int lineNumber;
  protected int columnNumber;
  protected String uri;
  protected int severity = SEV_ERROR;
  protected List nestedErrors;
  protected String errorKey = null;
  protected Object[] messageArguments = null;

  /**
   * Constructor.
   * 
   * @param message The validation message.
   * @param lineNumber The line where the message should be displayed.
   * @param columnNumber The column where the message should be displayed.
   * @deprecated Use contructor with URI parameter.
   */
  public ValidationMessageImpl(String message, int lineNumber, int columnNumber, int severity)
  {
    this(message, lineNumber, columnNumber, severity, null);
  }

  /**
   * Constructor.
   * Allows specifying a uri for the reference that the message refers to.
   * 
   * @param message The validation message.
   * @param lineNumber The line where the message should be displayed.
   * @param columnNumber The column where the message should be displayed.
   * @param uri The uri of the reference file for the message.
   */
  public ValidationMessageImpl(String message, int lineNumber, int columnNumber, int severity, String uri)
  {
      this(message, lineNumber, columnNumber, severity, uri, null, null);
  }
  
  /**
   * Constructor.
   * Allows specifying a uri for the reference that the message refers to.
   * 
   * @param message The validation message.
   * @param lineNumber The line where the message should be displayed.
   * @param columnNumber The column where the message should be displayed.
   * @param uri The uri of the reference file for the message.
   * @param errorKey The Xerces Error key
   * @param messageArguments The values used to "fill in the blanks" of a Xerces error Message
   */
  public ValidationMessageImpl(String message, int lineNumber, int columnNumber, int severity, String uri, String errorKey, Object[] messageArguments)
  {
    this.message = message;
    this.lineNumber = lineNumber;
    this.columnNumber = columnNumber;
    this.severity = severity;
    this.uri = uri;
    this.errorKey = errorKey;
    this.messageArguments = messageArguments;
  }

  /**
   * Returns the validation message.
   * 
   * @return The validation message.
   */
  public String getMessage()
  {
    return message;
  }

  /**
   * Returns the column number.
   * 
   * @return The column number where the message is located.
   */
  public int getColumn()
  {
    return columnNumber;
  }

  /**
   * Returns the line number.
   * 
   * @return The line number where the message is located.
   */
  public int getLine()
  {
    return lineNumber;
  }

  /**
   * returns the uri of the reference file for the validation message.
   * 
   * @return The uri of the resource that the message refers to.
   */
  public String getURI()
  {
    return uri;
  }
  /**
   * @see org.eclipse.wst.wsdl.validation.internal.IValidationMessage#getSeverity()
   */
  public int getSeverity()
  {
    return severity;
  }
  
  /**
   * Set the severity of the message.
   * 
   * @param severity The severity of the message.
   */
  public void setSeverity(int severity)
  {
    if(severity == SEV_ERROR || severity == SEV_WARNING)
    {
      this.severity = severity;
    }
  }
  
  /**
   * Add a nested validation message to this validation message.
   * 
   * @param validationMessage The validation message to add as a nested message.
   */
  public void addNestedMessage(IValidationMessage validationMessage)
  {
    if (nestedErrors == null)
    {
      nestedErrors = new ArrayList();
    }
    nestedErrors.add(validationMessage);
    int validaitonmessageSeverity = validationMessage.getSeverity();
    if(validaitonmessageSeverity == SEV_ERROR)
    {
      setSeverity(SEV_ERROR);
    }
  }

  /**
   * Get the list of nested validation messages.
   * 
   * @return The list of nested validation messages.
   */
  public List getNestedMessages()
  {
    return nestedErrors != null ? nestedErrors : Collections.EMPTY_LIST;
  }
  /**
   * @return the error key
   */
  public String getErrorKey()
  {
    return errorKey;
  }
  
  /**
   * @param errorKey the error key to set
   */
  public void setErrorKey(String errorKey)
  {
    this.errorKey = errorKey;
  }
  /**
   * @return the Xerces message arguments used to "fill in the blanks" of the messages
   */
  public Object[] getMessageArguments()
  {
    return messageArguments;
  }
}

Back to the top