Skip to main content
summaryrefslogtreecommitdiffstats
blob: f479a0f536afb46c3475933cbabf51125a0a1839 (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
/*******************************************************************************
 * Copyright (c) 2006 Oracle Corporation.
 * 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:
 *    Cameron Bateman/Oracle - initial API and implementation
 *    
 ********************************************************************************/

package org.eclipse.jst.jsf.ui.internal.validation;

import java.util.Locale;

import org.eclipse.core.resources.IResource;
import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
import org.eclipse.wst.validation.internal.core.Message;

/**
 * EL customized localizable validation message
 * @author cbateman
 *
 */
class MyLocalizedMessage extends Message
{
	private final String _message;
	private final int	 _errorCode;

	/**
	 * @param severity
	 * @param messageText
	 * @param targetObject
	 * @param errorCode 
	 */
	public MyLocalizedMessage(int severity, String messageText, IResource targetObject, int errorCode) {
		this(severity, messageText, (Object) targetObject, errorCode);
	}

	/**
	 * @param severity
	 * @param messageText
	 * @param targetObject
	 * @param errorCode 
	 */
	private MyLocalizedMessage(int severity, String messageText, Object targetObject, int errorCode) {
		super(JSFCorePlugin.getDefault().getBundle().getSymbolicName(), severity, 
                messageText);
		_message = messageText;
		setTargetObject(targetObject);
		_errorCode = errorCode;
	}

	/**
	 * @return the localized message
	 */
	public String getLocalizedMessage() {
		return _message;
	}

	/**
	 * @see org.eclipse.wst.validation.internal.core.Message#getText()
	 */
	public String getText() {
		return getLocalizedMessage();
	}

	/**
	 * @see org.eclipse.wst.validation.internal.core.Message#getText(java.lang.ClassLoader)
	 */
	public String getText(ClassLoader cl) {
		return getLocalizedMessage();
	}

	/**
	 * @see org.eclipse.wst.validation.internal.core.Message#getText(java.util.Locale)
	 */
	public String getText(Locale l) {
		return getLocalizedMessage();
	}

	public String getText(Locale l, ClassLoader cl) {
		return getLocalizedMessage();
	}

	/**
	 * @return the error code related to this message
	 */
	public int getErrorCode() {
		return _errorCode;
	}


	/**
	 * @param offset
	 * @return true if this message applies to document offset
	 */
	public boolean appliesTo(int offset)
	{
		return (offset >= getOffset() && offset < getOffset()+getLength());
	}
}

Back to the top