KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > JavaRefactoringArguments


1 /*******************************************************************************
2  * Copyright (c) 2005, 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;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.Assert;
17
18 import org.eclipse.ltk.core.refactoring.RefactoringContribution;
19 import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
20 import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
21
22 /**
23  * Refactoring arguments which provide the ability to set arguments using
24  * key-value pairs of strings.
25  *
26  * @see RefactoringContribution
27  * @see RefactoringDescriptor
28  *
29  * @since 3.2
30  */

31 public final class JavaRefactoringArguments extends RefactoringArguments {
32
33     /** The attribute map (element type: <code>&lt;String, String&gt;</code>) */
34     private final Map JavaDoc fAttributes= new HashMap JavaDoc(2);
35
36     /** The name of the project, or <code>null</code> for the workspace */
37     private String JavaDoc fProject;
38
39     /**
40      * Creates a new java refactoring arguments.
41      *
42      * @param project
43      * the project, or <code>null</code> for the workspace
44      */

45     public JavaRefactoringArguments(final String JavaDoc project) {
46         Assert.isTrue(project == null || !"".equals(project)); //$NON-NLS-1$
47
fProject= project;
48     }
49
50     /**
51      * Returns the attribute with the specified name.
52      *
53      * @param name
54      * the name of the attribute
55      * @return the attribute value, or <code>null</code>
56      */

57     public String JavaDoc getAttribute(final String JavaDoc name) {
58         return (String JavaDoc) fAttributes.get(name);
59     }
60
61     /**
62      * Returns the name of the project.
63      *
64      * @return the name of the project, or <code>null</code> for the workspace
65      */

66     public String JavaDoc getProject() {
67         return fProject;
68     }
69
70     /**
71      * Sets the attribute with the specified name to the indicated value.
72      *
73      * @param name
74      * the name of the attribute
75      * @param value
76      * the value of the attribute
77      */

78     public void setAttribute(final String JavaDoc name, final String JavaDoc value) {
79         Assert.isNotNull(name);
80         Assert.isNotNull(value);
81         fAttributes.put(name, value);
82     }
83
84     /**
85      * Sets the name of the project.
86      *
87      * @param project
88      * the name of the project, or <code>null</code> for the
89      * workspace
90      */

91     public void setProject(final String JavaDoc project) {
92         Assert.isTrue(project == null || !"".equals(project)); //$NON-NLS-1$
93
fProject= project;
94     }
95
96     /**
97      * {@inheritDoc}
98      */

99     public String JavaDoc toString() {
100         return getClass().getName() + fAttributes.toString();
101     }
102 }
103
Popular Tags