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.
    • 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​(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 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

        Object getAttribute​(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​(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

        String getAttribute​(String attributeName,
                            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​(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

        Map<String,​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

        Object[] getAttributes​(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

        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​(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​(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​(String attributeName,
                          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​(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​(String[] attributeNames,
                           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​(Map<String,​? extends 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)