KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > undo > MarkerDescription


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.internal.ide.undo;
13
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.resources.IMarker;
17 import org.eclipse.core.resources.IResource;
18 import org.eclipse.core.runtime.CoreException;
19
20 /**
21  * MarkerDescription is a lightweight description of a marker that can be used
22  * to describe a marker to be created or updated.
23  *
24  * This class is not intended to be instantiated or used by clients.
25  *
26  * @since 3.3
27  *
28  */

29 public class MarkerDescription {
30     String JavaDoc type;
31
32     Map JavaDoc attributes;
33
34     IResource resource;
35
36     /**
37      *
38      * Create a marker description from the specified marker.
39      *
40      * @param marker
41      * the marker to be described
42      * @throws CoreException
43      */

44     public MarkerDescription(IMarker marker) throws CoreException {
45         this.type = marker.getType();
46         this.attributes = marker.getAttributes();
47         this.resource = marker.getResource();
48
49     }
50
51     /**
52      * Create a marker description from the specified marker type, attributes,
53      * and resource.
54      *
55      * @param type
56      * the type of marker to be created.
57      * @param attributes
58      * the attributes to be assigned to the marker
59      * @param resource
60      * the resource on which the marker should be created
61      */

62     public MarkerDescription(String JavaDoc type, Map JavaDoc attributes, IResource resource) {
63         this.type = type;
64         this.attributes = attributes;
65         this.resource = resource;
66     }
67
68     /**
69      * Create a marker from the marker description.
70      *
71      * @return the created marker
72      * @throws CoreException
73      */

74     public IMarker createMarker() throws CoreException {
75         IMarker marker = resource.createMarker(type);
76         marker.setAttributes(attributes);
77         return marker;
78     }
79
80     /**
81      * Update an existing marker using the attributes in the marker description.
82      *
83      * @param marker
84      * the marker to be updated
85      * @throws CoreException
86      */

87     public void updateMarker(IMarker marker) throws CoreException {
88         marker.setAttributes(attributes);
89     }
90
91     /**
92      * Return the resource associated with this marker.
93      *
94      * @return the resource associated with this marker
95      */

96     public IResource getResource() {
97         return resource;
98     }
99
100     /**
101      * Return the marker type associated with this marker.
102      *
103      * @return the string marker type of this marker
104      */

105     public String JavaDoc getType() {
106         return type;
107     }
108 }
Popular Tags