KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > reorg > CreateTargetExecutionLog


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 package org.eclipse.jdt.internal.corext.refactoring.reorg;
12
13 import java.util.LinkedHashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 /**
17  * Objects of this class can be used as a log to trace the creation of new
18  * destinations during refactorings like move.
19  *
20  * @since 3.3
21  */

22 public final class CreateTargetExecutionLog {
23
24     private Map JavaDoc fCreations= new LinkedHashMap JavaDoc(2);
25
26     /**
27      * Returns the element which got created for the given selection.
28      *
29      * @param selection
30      * the selection
31      * @return the created element, or <code>null</code>
32      */

33     public Object JavaDoc getCreatedElement(Object JavaDoc selection) {
34         return fCreations.get(selection);
35     }
36
37     /**
38      * Returns all created elements.
39      *
40      * @return all created elements
41      */

42     public Object JavaDoc[] getCreatedElements() {
43         return fCreations.values().toArray();
44     }
45
46     /**
47      * Returns all selected elements.
48      *
49      * @return all selected elements
50      */

51     public Object JavaDoc[] getSelectedElements() {
52         return fCreations.keySet().toArray();
53     }
54
55     /**
56      * Logs that the given element got created by the refactoring.
57      *
58      * @param selection
59      * the selected object
60      * @param element
61      * the element that got created for the selection
62      */

63     public void markAsCreated(Object JavaDoc selection, Object JavaDoc element) {
64         fCreations.put(selection, element);
65     }
66 }
67
Popular Tags