Interface IMarker

  • All Superinterfaces:
    IAdaptable

    public interface IMarker
    extends IAdaptable
    Markers are a general mechanism for associating notes and meta-data with resources.

    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

      Fields 
      Modifier and Type Field Description
      static java.lang.String BOOKMARK
      Bookmark marker type.
      static java.lang.String CHAR_END
      Character end marker attribute.
      static java.lang.String CHAR_START
      Character start marker attribute.
      static java.lang.String DONE
      Done marker attribute.
      static java.lang.String LINE_NUMBER
      Line number marker attribute.
      static java.lang.String LOCATION
      Location marker attribute.
      static java.lang.String MARKER
      Base marker type.
      static java.lang.String MESSAGE
      Message marker attribute.
      static java.lang.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 java.lang.String PROBLEM
      Problem marker type.
      static java.lang.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 java.lang.String SOURCE_ID
      Source id attribute.
      static java.lang.String TASK
      Task marker type.
      static java.lang.String TEXT
      Text marker type.
      static java.lang.String TRANSIENT
      Transient marker attribute.
      static java.lang.String USER_EDITABLE
      User editable marker attribute.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void delete()
      Deletes this marker from its associated resource.
      boolean equals​(java.lang.Object object)
      Tests this marker for equality with the given object.
      boolean exists()
      Returns whether this marker exists in the workspace.
      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<java.lang.String,​java.lang.Object> getAttributes()
      Returns a map with all the attributes for the marker.
      java.lang.Object[] getAttributes​(java.lang.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.
      java.lang.String getType()
      Returns the type of this marker.
      boolean isSubtypeOf​(java.lang.String superType)
      Returns whether the type of this marker is considered to be a sub-type of the given marker type.
      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.lang.String[] attributeNames, java.lang.Object[] values)
      Sets the given attribute key-value pairs on this marker.
      void setAttributes​(java.util.Map<java.lang.String,​? extends java.lang.Object> attributes)
      Sets the attributes for this marker to be the ones contained in the given table.
    • Method Detail

      • delete

        void delete()
             throws CoreException
        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.
        See Also:
        IResourceRuleFactory.markerRule(IResource)
      • equals

        boolean equals​(java.lang.Object object)
        Tests this marker for equality with the given object. Two markers are equal if their id and resource are both equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the other object
        Returns:
        an indication of whether the objects are 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, otherwise false
      • getAttribute

        java.lang.Object getAttribute​(java.lang.String attributeName)
                               throws CoreException
        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.
        Throws:
        CoreException - if this method fails. Reasons include:
        • This marker does not exist.
      • getAttribute

        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 value is found
        Returns:
        the value or the default value if no value was found.
      • getAttribute

        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

        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

        java.util.Map<java.lang.String,​java.lang.Object> getAttributes()
                                                                      throws CoreException
        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.
        Throws:
        CoreException - if this method fails. Reasons include:
        • This marker does not exist.
      • getAttributes

        java.lang.Object[] getAttributes​(java.lang.String[] attributeNames)
                                  throws CoreException
        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 is null or an instance of one of the following classes: String, Integer, or Boolean.
        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

        long getCreationTime()
                      throws CoreException
        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:
        IResource.findMarker(long)
      • getResource

        IResource getResource()
        Returns the resource with which this marker is associated.
        Returns:
        the resource with which this marker is associated
      • getType

        java.lang.String getType()
                          throws CoreException
        Returns the type of this marker. The returned marker type will not be null.
        Returns:
        the type of this marker
        Throws:
        CoreException - if this method fails. Reasons include:
        • This marker does not exist.
      • isSubtypeOf

        boolean isSubtypeOf​(java.lang.String superType)
                     throws CoreException
        Returns whether the type of this marker is considered to be a sub-type of the given marker type.
        Returns:
        boolean trueif 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

        void setAttribute​(java.lang.String attributeName,
                          int value)
                   throws CoreException
        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
        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:
        IResourceRuleFactory.markerRule(IResource)
      • setAttribute

        void setAttribute​(java.lang.String attributeName,
                          java.lang.Object value)
                   throws CoreException
        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. 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.

        Parameters:
        attributeName - the name of the attribute
        value - the value, or null 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:
        IResourceRuleFactory.markerRule(IResource)
      • setAttribute

        void setAttribute​(java.lang.String attributeName,
                          boolean value)
                   throws CoreException
        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 attribute
        value - 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:
        IResourceRuleFactory.markerRule(IResource)
      • setAttributes

        void setAttributes​(java.lang.String[] attributeNames,
                           java.lang.Object[] values)
                    throws CoreException
        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.

        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 names
        values - 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:
        IResourceRuleFactory.markerRule(IResource)
      • setAttributes

        void setAttributes​(java.util.Map<java.lang.String,​? extends java.lang.Object> attributes)
                    throws CoreException
        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. 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.

        Parameters:
        attributes - a map of attribute names to attribute values (key type : String value type : String, Integer, or Boolean) or null
        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:
        IResourceRuleFactory.markerRule(IResource)