public interface IMarker extends 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.
Each marker has:
"org.eclipse.core.resources.taskmarker"
), 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
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:
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.
Modifier and Type | Field and Description |
---|---|
static String |
BOOKMARK
Bookmark marker type.
|
static String |
CHAR_END
Character end marker attribute.
|
static String |
CHAR_START
Character start marker attribute.
|
static String |
DONE
Done marker attribute.
|
static String |
LINE_NUMBER
Line number marker attribute.
|
static String |
LOCATION
Location marker attribute.
|
static String |
MARKER
Base marker type.
|
static String |
MESSAGE
Message marker attribute.
|
static String |
PRIORITY
Priority marker attribute.
|
static int |
PRIORITY_HIGH
High priority constant (value 2).
|
static int |
PRIORITY_LOW
Low priority constant (value 0).
|
static int |
PRIORITY_NORMAL
Normal priority constant (value 1).
|
static String |
PROBLEM
Problem marker type.
|
static String |
SEVERITY
Severity marker attribute.
|
static int |
SEVERITY_ERROR
Error severity constant (value 2) indicating an error state.
|
static int |
SEVERITY_INFO
Info severity constant (value 0) indicating information only.
|
static int |
SEVERITY_WARNING
Warning severity constant (value 1) indicating a warning.
|
static String |
SOURCE_ID
Source id attribute.
|
static String |
TASK
Task marker type.
|
static String |
TEXT
Text marker type.
|
static String |
TRANSIENT
Transient marker attribute.
|
static String |
USER_EDITABLE
User editable marker attribute.
|
Modifier and Type | Method and Description |
---|---|
void |
delete()
Deletes this marker from its associated resource.
|
boolean |
equals(Object object)
Tests this marker for equality with the given object.
|
boolean |
exists()
Returns whether this marker exists in the workspace.
|
Object |
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.
|
String |
getAttribute(String attributeName,
String defaultValue)
Returns the string-valued attribute with the given name.
|
Map<String,Object> |
getAttributes()
Returns a map with all the attributes for the marker.
|
Object[] |
getAttributes(String[] attributeNames)
Returns the attributes with the given names.
|
long |
getCreationTime()
Returns the time at which this marker was created.
|
long |
getId()
Returns the id of the marker.
|
IResource |
getResource()
Returns the resource with which this marker is associated.
|
String |
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(Map<String,? extends Object> attributes)
Sets the attributes for this marker to be the ones contained in the
given table.
|
void |
setAttributes(String[] attributeNames,
Object[] values)
Sets the given attribute key-value pairs on this marker.
|
getAdapter
static final String MARKER
getType()
,
Constant Field Valuesstatic final String TASK
getType()
,
Constant Field Valuesstatic final String PROBLEM
getType()
,
Constant Field Valuesstatic final String TEXT
getType()
,
Constant Field Valuesstatic final String BOOKMARK
getType()
,
Constant Field Valuesstatic final String SEVERITY
static final String MESSAGE
static final String LOCATION
static final String PRIORITY
static final String DONE
static final String CHAR_START
static final String CHAR_END
static final String LINE_NUMBER
static final String TRANSIENT
getAttribute(String, String)
,
Constant Field Valuesstatic final String USER_EDITABLE
true
. 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.getAttribute(String, String)
,
Constant Field Valuesstatic final String SOURCE_ID
getAttribute(String, String)
,
Constant Field Valuesstatic final int PRIORITY_HIGH
getAttribute(String, int)
,
Constant Field Valuesstatic final int PRIORITY_NORMAL
getAttribute(String, int)
,
Constant Field Valuesstatic final int PRIORITY_LOW
getAttribute(String, int)
,
Constant Field Valuesstatic final int SEVERITY_ERROR
getAttribute(String, int)
,
Constant Field Valuesstatic final int SEVERITY_WARNING
getAttribute(String, int)
,
Constant Field Valuesstatic final int SEVERITY_INFO
getAttribute(String, int)
,
Constant Field Valuesvoid delete() throws CoreException
CoreException
- if this marker could not be deleted. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
boolean equals(Object object)
boolean exists()
true
if this marker exists, otherwise
false
Object getAttribute(String attributeName) throws CoreException
String
, Integer
,
or Boolean
.
Returns null
if the attribute is undefined.attributeName
- the name of the attributenull
if the attribute is undefined.CoreException
- if this method fails. Reasons include:
int getAttribute(String attributeName, int defaultValue)
attributeName
- the name of the attributedefaultValue
- the value to use if no value is foundString getAttribute(String attributeName, String defaultValue)
attributeName
- the name of the attributedefaultValue
- the value to use if no value is foundboolean getAttribute(String attributeName, boolean defaultValue)
attributeName
- the name of the attributedefaultValue
- the value to use if no value is foundMap<String,Object> getAttributes() throws CoreException
null
is returned.String
value type : String
, Integer
, or
Boolean
) or null
.CoreException
- if this method fails. Reasons include:
Object[] getAttributes(String[] attributeNames) throws CoreException
null
or an instance of one
of the following classes: String
, Integer
,
or Boolean
.attributeNames
- the names of the attributesCoreException
- if this method fails. Reasons include:
long getCreationTime() throws CoreException
0L
if the creation time is not known (this can occur in workspaces created using v2.0 or earlier).CoreException
- if this method fails. Reasons include:
long getId()
IResource.findMarker(long)
IResource getResource()
String getType() throws CoreException
null
.CoreException
- if this method fails. Reasons include:
boolean isSubtypeOf(String superType) throws CoreException
true
if the marker's type
is the same as (or a sub-type of) the given type.CoreException
- if this method fails. Reasons include:
void setAttribute(String attributeName, int value) throws CoreException
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this marker has been modified.
attributeName
- the name of the attributevalue
- the valueCoreException
- if this method fails. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
void setAttribute(String attributeName, Object value) throws CoreException
null
or
an instance of one of the following classes:
String
, Integer
, or Boolean
.
If the value is null
, 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.
attributeName
- the name of the attributevalue
- the value, or null
if the attribute is to be undefinedCoreException
- if this method fails. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
void setAttribute(String attributeName, boolean value) throws CoreException
This method changes resources; these changes will be reported in a subsequent resource change event, including an indication that this marker has been modified.
attributeName
- the name of the attributevalue
- the valueCoreException
- if this method fails. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
void setAttributes(String[] attributeNames, Object[] values) throws CoreException
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.
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.
attributeNames
- an array of attribute namesvalues
- an array of attribute valuesCoreException
- if this method fails. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
void setAttributes(Map<String,? extends Object> attributes) throws CoreException
String
, Integer
, or Boolean
.
Attributes previously set on the marker but not included in the given map
are considered to be removals. Setting the given map to be null
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.
attributes
- a map of attribute names to attribute values
(key type : String
value type : String
,
Integer
, or Boolean
) or null
CoreException
- if this method fails. Reasons include:
IResourceChangeEvent
for more details.IResourceRuleFactory.markerRule(IResource)
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.