Interface IMarker
- All Superinterfaces:
IAdaptable
Markers themselves are handles in the same way as IResources
are handles. Instances of IMarker
do not hold the attributes
themselves but rather uniquely refer to the attribute container. As such,
their state may change underneath the handle with no warning to the holder
of the handle.
The Resources plug-in provides a general framework for defining and manipulating markers and provides several standard marker types.
Each marker has:
- a type string, specifying its type (e.g.
"org.eclipse.core.resources.taskmarker"
), - an identifier which is unique (relative to a particular resource)
Specific types of markers may carry additional information.
The resources plug-in defines five standard types:
org.eclipse.core.resources.marker
org.eclipse.core.resources.taskmarker
org.eclipse.core.resources.problemmarker
org.eclipse.core.resources.bookmark
org.eclipse.core.resources.textmarker
The plug-in also provides an extension point (
org.eclipse.core.resources.markers
) into which other
plug-ins can install marker type declaration extensions.
Marker types are declared within a multiple inheritance type system.
New markers are defined in the plugin.xml
file of the
declaring plug-in. A valid declaration contains elements as defined by
the extension point DTD:
- type - the unique name of the marker type
- super - the list of marker types of which this marker is to be considered a sub-type
- attributes - the list of standard attributes which may be present on this type of marker
- persistent - whether markers of this type should be persisted by the platform
All markers declared as persistent
are saved when the
workspace is saved, except those explicitly set as transient (the
TRANSIENT
attribute is set as true
). A plug-in
which defines a persistent marker is not directly involved in saving and
restoring the marker. Markers are not under version and configuration
management, and cannot be shared via VCM repositories.
Markers implement the IAdaptable
interface;
extensions are managed by the platform's adapter manager.
- Restriction:
- This interface is not intended to be implemented by clients.
- Restriction:
- This interface is not intended to be extended by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Bookmark marker type.static final String
Character end marker attribute.static final String
Character start marker attribute.static final String
Done marker attribute.static final String
Line number marker attribute.static final String
Location marker attribute.static final String
Base marker type.static final String
Message marker attribute.static final String
Priority marker attribute.static final int
High priority constant (value 2).static final int
Low priority constant (value 0).static final int
Normal priority constant (value 1).static final String
Problem marker type.static final String
Severity marker attribute.static final int
Error severity constant (value 2) indicating an error state.static final int
Info severity constant (value 0) indicating information only.static final int
Warning severity constant (value 1) indicating a warning.static final String
Source id attribute.static final String
Task marker type.static final String
Text marker type.static final String
Transient marker attribute.static final String
User editable marker attribute. -
Method Summary
Modifier and TypeMethodDescriptionvoid
delete()
Deletes this marker from its associated resource.boolean
Tests this marker for equality with the given object.boolean
exists()
Returns whether this marker exists in the workspace.getAttribute
(String attributeName) Returns the attribute with the given name.boolean
getAttribute
(String attributeName, boolean defaultValue) Returns the boolean-valued attribute with the given name.int
getAttribute
(String attributeName, int defaultValue) Returns the integer-valued attribute with the given name.getAttribute
(String attributeName, String defaultValue) Returns the string-valued attribute with the given name.Returns a map with all the attributes for the marker.Object[]
getAttributes
(String[] attributeNames) Returns the attributes with the given names.long
Returns the time at which this marker was created.long
getId()
Returns the id of the marker.Returns the resource with which this marker is associated.getType()
Returns the type of this marker.boolean
isSubtypeOf
(String superType) Returns whether the type of this marker is considered to be a sub-type of the given marker type.void
setAttribute
(String attributeName, boolean value) Sets the boolean-valued attribute with the given name.void
setAttribute
(String attributeName, int value) Sets the integer-valued attribute with the given name.void
setAttribute
(String attributeName, Object value) Sets the attribute with the given name.void
setAttributes
(String[] attributeNames, Object[] values) Sets the given attribute key-value pairs on this marker.void
setAttributes
(Map<String, ? extends Object> attributes) Sets the attributes for this marker to be the ones contained in the given table.Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
-
Field Details
-
MARKER
Base marker type.- See Also:
-
TASK
Task marker type.- See Also:
-
PROBLEM
Problem marker type.- See Also:
-
TEXT
Text marker type.- See Also:
-
BOOKMARK
Bookmark marker type.- See Also:
-
SEVERITY
Severity marker attribute. A number from the set of error, warning and info severities defined by the platform. -
MESSAGE
Message marker attribute. A localized string describing the nature of the marker (e.g., a name for a bookmark or task). The content and form of this attribute is not specified or interpreted by the platform. -
LOCATION
Location marker attribute. The location is a human-readable (localized) string which can be used to distinguish between markers on a resource. As such it should be concise and aimed at users. The content and form of this attribute is not specified or interpreted by the platform. -
PRIORITY
Priority marker attribute. A number from the set of high, normal and low priorities defined by the platform. -
DONE
Done marker attribute. A boolean value indicating whether the marker (e.g., a task) is considered done. -
CHAR_START
Character start marker attribute. An integer value indicating where a text marker starts. This attribute is zero-relative and inclusive. -
CHAR_END
Character end marker attribute. An integer value indicating where a text marker ends. This attribute is zero-relative and exclusive. -
LINE_NUMBER
Line number marker attribute. An integer value indicating the line number for a text marker. This attribute is 1-relative. -
TRANSIENT
Transient marker attribute. A boolean value indicating whether the marker (e. g., a task) is considered transient even if its type is declared as persistent.- Since:
- 2.1
- See Also:
-
USER_EDITABLE
User editable marker attribute. A boolean value indicating whether a user should be able to manually change the marker (e.g. a task). The default istrue
. Note that the value of this attribute is to be used by the UI as a suggestion and its value will NOT be interpreted by Core in any manner and will not be enforced by Core when performing any operations on markers.- Since:
- 2.1
- See Also:
-
SOURCE_ID
Source id attribute. A string attribute that can be used by tools that generate markers to indicate the source of the marker. Use of this attribute is optional and its format or existence is not enforced. This attribute is intended to improve serviceability by providing a value that product support personnel or automated tools can use to determine appropriate help and resolutions for markers.- Since:
- 3.3
- See Also:
-
PRIORITY_HIGH
static final int PRIORITY_HIGHHigh priority constant (value 2). -
PRIORITY_NORMAL
static final int PRIORITY_NORMALNormal priority constant (value 1). -
PRIORITY_LOW
static final int PRIORITY_LOWLow priority constant (value 0). -
SEVERITY_ERROR
static final int SEVERITY_ERRORError severity constant (value 2) indicating an error state. -
SEVERITY_WARNING
static final int SEVERITY_WARNINGWarning severity constant (value 1) indicating a warning. -
SEVERITY_INFO
static final int SEVERITY_INFOInfo severity constant (value 0) indicating information only.
-
-
Method Details
-
delete
Deletes this marker from its associated resource. This method has no effect if this marker does not exist.- Throws:
CoreException
- if this marker could not be deleted. Reasons include:- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- Resource changes are disallowed during certain types of resource change
event notification. See
- See Also:
-
equals
Tests this marker for equality with the given object. Two markers are equal if their id and resource are both equal. -
exists
boolean exists()Returns whether this marker exists in the workspace. A marker exists if its resource exists and has a marker with the marker's id.- Returns:
true
if this marker exists, otherwisefalse
-
getAttribute
Returns the attribute with the given name. The result is an instance of one of the following classes:String
,Integer
, orBoolean
. Returnsnull
if the attribute is undefined.- Parameters:
attributeName
- the name of the attribute- Returns:
- the value, or
null
if the attribute is undefined. - Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
-
getAttribute
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 attributedefaultValue
- the value to use if no value is found- Returns:
- the value or the default value if no value was found.
-
getAttribute
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 attributedefaultValue
- the value to use if no value is found- Returns:
- the value or the default value if no value was found.
-
getAttribute
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 attributedefaultValue
- the value to use if no value is found- Returns:
- the value or the default value if no value was found.
-
getAttributes
Returns a map with all the attributes for the marker. If the marker has no attributes thennull
is returned.- Returns:
- a map of attribute keys and values (key type :
String
value type :String
,Integer
, orBoolean
) ornull
. - Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
-
getAttributes
Returns the attributes with the given names. The result is an an array whose elements correspond to the elements of the given attribute name array. Each element isnull
or an instance of one of the following classes:String
,Integer
, orBoolean
.- Parameters:
attributeNames
- the names of the attributes- Returns:
- the values of the given attributes.
- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
-
getCreationTime
Returns the time at which this marker was created.- Returns:
- the difference, measured in milliseconds, between the time at which
this marker was created and midnight, January 1, 1970 UTC, or
0L
if the creation time is not known (this can occur in workspaces created using v2.0 or earlier). - Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Since:
- 2.1
-
getId
long getId()Returns the id of the marker. The id of a marker is unique relative to the resource with which the marker is associated. Marker ids are not globally unique.- Returns:
- the id of the marker
- See Also:
-
getResource
IResource getResource()Returns the resource with which this marker is associated.- Returns:
- the resource with which this marker is associated
-
getType
Returns the type of this marker. The returned marker type will not benull
.- Returns:
- the type of this marker
- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
-
isSubtypeOf
Returns whether the type of this marker is considered to be a sub-type of the given marker type.- Returns:
- boolean
true
if the marker's type is the same as (or a sub-type of) the given type. - Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
-
setAttribute
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 attributevalue
- the value- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- See Also:
-
setAttribute
Sets the attribute with the given name. The value must benull
or an instance of one of the following classes:String
,Integer
, orBoolean
. If the value isnull
, the attribute is considered to be undefined.The attribute value cannot be
String
whose UTF encoding exceeds 65535 bytes. On persistent markers this limit is enforced by an assertion.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 attributevalue
- the value, ornull
if the attribute is to be undefined- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- See Also:
-
setAttribute
Sets the boolean-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 attributevalue
- the value- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- See Also:
-
setAttributes
Sets the given attribute key-value pairs on this marker. The values must benull
or an instance of one of the following classes:String
,Integer
, orBoolean
. If a value isnull
, the new value of the attribute is considered to be undefined.The values of the attributes cannot be
String
whose UTF encoding exceeds 65535 bytes. On persistent markers this limit is enforced by an assertion.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:
attributeNames
- an array of attribute namesvalues
- an array of attribute values- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- See Also:
-
setAttributes
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
, orBoolean
. Attributes previously set on the marker but not included in the given map are considered to be removals. Setting the given map to benull
is equivalent to removing all marker attributes.The values of the attributes cannot be
String
whose UTF encoding exceeds 65535 bytes. On persistent markers this limit is enforced by an assertion.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:
attributes
- a map of attribute names to attribute values (key type :String
value type :String
,Integer
, orBoolean
) ornull
- Throws:
CoreException
- if this method fails. Reasons include:- This marker does not exist.
- Resource changes are disallowed during certain types of resource change
event notification. See
IResourceChangeEvent
for more details.
- See Also:
-