org.eclipse.wst.validation
Class ValidatorMessage
java.lang.Object
org.eclipse.wst.validation.ValidatorMessage
-
public class ValidatorMessage
- extends java.lang.Object
This class provides a way for a validator to return messages, that are easily
converted into IMarkers.
This class is completely optional for validators. A validator can choose to
directly manage IMarkers. However, some validators want to be used in
multiple contexts, for example as-you-type validation and build based
validation. For these types of validators it is not possible for them to use
only IMarkers, because often the Resource has not been saved yet.
Provisional API: This class/interface is part of an interim API that
is still under development and expected to change significantly before
reaching stability. It is being made available at this early stage to solicit
feedback from pioneering adopters on the understanding that any code that
uses this API will almost certainly be broken (repeatedly) as the API
evolves.
Method Summary
|
ValidatorMessage
|
asCopy
()
Answer a copy of yourself. |
static
ValidatorMessage
|
create
(java.lang.String message,
IResource resource)
Create a new validation message. |
java.lang.Object
|
getAttribute
(java.lang.String attributeName)
Returns the attribute with the given name. |
boolean
|
getAttribute
(java.lang.String attributeName,
boolean defaultValue)
Returns the boolean valued attribute with the given name. |
int
|
getAttribute
(java.lang.String attributeName,
int defaultValue)
Returns the integer valued attribute with the given name. |
java.lang.String
|
getAttribute
(java.lang.String attributeName,
java.lang.String defaultValue)
Returns the string valued attribute with the given name. |
java.util.Map
|
getAttributes
()
Returns a map with all the attributes for the marker. |
IResource
|
getResource
()
Returns the resource with which this marker is associated. |
java.lang.String
|
getType
()
Returns the type of this marker. |
void
|
setAttribute
(java.lang.String attributeName,
boolean value)
Sets the boolean valued attribute with the given name. |
void
|
setAttribute
(java.lang.String attributeName,
int value)
Sets the integer valued attribute with the given name. |
void
|
setAttribute
(java.lang.String attributeName,
java.lang.Object value)
Sets the attribute with the given name. |
void
|
setAttributes
(java.util.Map<java.lang.String,java.lang.Object> attributes)
Sets the attributes for this marker to be the ones contained in the given
table. |
void
|
setAttributes
(java.lang.String[] attributeNames,
java.lang.Object[] values)
Sets the given attribute key-value pairs on this marker. |
void
|
setType
(java.lang.String type)
Sets the marker type. |
Methods inherited from class java.lang.Object
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
ValidationId
public static final java.lang.String ValidationId
-
See Also:
-
Constant Field Values
create
public static
ValidatorMessage create(java.lang.String message,
IResource resource)
- Create a new validation message.
-
-
Parameters:
-
message
- The localized message that will be displayed to the user. -
resource
- The resource that the message is associated with.
asCopy
public
ValidatorMessage asCopy()
- Answer a copy of yourself.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String attributeName)
- Returns the attribute with the given name. The result is an instance of
one of the following classes:
String
, Integer
,
or Boolean
. Returns null
if the attribute is
undefined.
-
-
Parameters:
-
attributeName
- The name of the attribute.
-
Returns:
- the value, or
null
if the attribute is undefined.
getAttribute
public int getAttribute(java.lang.String attributeName,
int defaultValue)
- Returns the integer valued attribute with the given name. Returns the
given default value if the attribute is undefined or the marker does not
exist or is not an integer value.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
defaultValue
- The value to use if no integer value is found.
-
Returns:
- the value or the default value if no integer value was found.
getAttribute
public java.lang.String getAttribute(java.lang.String attributeName,
java.lang.String defaultValue)
- Returns the string valued attribute with the given name. Returns the
given default value if the attribute is undefined or the marker does not
exist or is not a string value.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
defaultValue
- The value to use if no value is found.
-
Returns:
- the value or the default value if no value was found.
getAttribute
public boolean getAttribute(java.lang.String attributeName,
boolean defaultValue)
- Returns the boolean valued attribute with the given name. Returns the
given default value if the attribute is undefined or the marker does not
exist or is not a boolean value.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
defaultValue
- The value to use if no value is found.
-
Returns:
- the value or the default value if no value was found.
getAttributes
public java.util.Map getAttributes()
- Returns a map with all the attributes for the marker. If the marker has
no attributes then
null
is returned.
-
-
Returns:
- a map of attribute keys and values (key type :
String
value type : String
,
Integer
, or Boolean
) or null
.
getResource
public IResource getResource()
- Returns the resource with which this marker is associated.
-
-
Returns:
- the resource with which this marker is associated
getType
public java.lang.String getType()
- Returns the type of this marker. The returned marker type will not be
null
.
-
-
Returns:
- the type of this marker
setType
public void setType(java.lang.String type)
- Sets the marker type.
-
-
Parameters:
-
type
- The marker id to use when creating new markers.
setAttribute
public void setAttribute(java.lang.String attributeName,
int value)
- Sets the integer valued attribute with the given name.
This method changes resources; these changes will be reported in a
subsequent resource change event, including an indication that this
marker has been modified.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
value
- The value.
setAttribute
public void setAttribute(java.lang.String attributeName,
java.lang.Object value)
- Sets the attribute with the given name. The value must be
null
or an instance of one of the following classes:
String
, Integer
, or Boolean
.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
value
- The value, or null
if the attribute is to be undefined.
setAttribute
public void setAttribute(java.lang.String attributeName,
boolean value)
- Sets the boolean valued attribute with the given name.
-
-
Parameters:
-
attributeName
- The name of the attribute. -
value
- The value.
setAttributes
public void setAttributes(java.lang.String[] attributeNames,
java.lang.Object[] values)
- Sets the given attribute key-value pairs on this marker. The values must
be
null
or an instance of one of the following classes:
String
, Integer
, or Boolean
. If a
value is null
, the new value of the attribute is considered
to be undefined.
-
-
Parameters:
-
attributeNames
- An array of attribute names. -
values
- An array of attribute values.
setAttributes
public void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
- Sets the attributes for this marker to be the ones contained in the given
table. The values must be an instance of one of the following classes:
String
, Integer
, or Boolean
.
Attributes previously set on the marker but not included in the given map
are considered to be removals. This includes the text of the message.
Setting the given map to be
null
is equivalent to removing all marker attributes.
-
-
Parameters:
-
attributes
- A map of attribute names to attribute values (key type :
String
value type : String
,
Integer
, or Boolean
) or null
.