KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > core > refactoring > RefactoringSessionDescriptor


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.ltk.core.refactoring;
12
13 import org.eclipse.core.runtime.Assert;
14
15 /**
16  * Descriptor object of a refactoring session.
17  * <p>
18  * Refactoring session descriptors encapsulate a series of refactoring
19  * descriptors. They are used to represent chunks of the global workspace
20  * refactoring history or refactoring scripts created by the user.
21  * </p>
22  * <p>
23  * Refactoring session descriptors contain the following information:
24  * <ul>
25  * <li> an optional comment string, which provides a full human-readable
26  * description of the refactoring session. Comments are automatically generated
27  * by refactorings and provide more refactoring-specific information, such as
28  * which elements have participated in which refactorings. </li>
29  * <li> a list of refactoring descriptors describing the refactorings executed
30  * during a refactoring session. The refactoring list is sorted in ascending
31  * order by the execution time of the refactorings. </li>
32  * <li> a version tag describing version information of the refactoring session
33  * descriptor format. The version tag is used to provide a means of schema
34  * evolution on the refactoring framework level. Clients which would like to
35  * version their refactoring descriptors are required to implement this in their
36  * specific subclasses of {@link RefactoringDescriptor}. </li>
37  * </ul>
38  * </p>
39  * <p>
40  * Refactoring session descriptors are potentially heavy weight objects which
41  * should not be held on to. Use refactoring descriptor proxies
42  * {@link RefactoringDescriptorProxy} to present refactoring descriptors in the
43  * user interface or otherwise manipulate refactoring histories. More details
44  * about a particular refactoring session can be revealed in the comment, which
45  * contains more text with refactoring-specific information.
46  * </p>
47  * <p>
48  * All time stamps are measured as the milliseconds since January 1, 1970,
49  * 00:00:00 GMT.
50  * </p>
51  * <p>
52  * Note: this class is not indented to be subclassed outside the refactoring
53  * framework.
54  * </p>
55  *
56  * @see RefactoringDescriptor
57  *
58  * @since 3.2
59  */

60 public class RefactoringSessionDescriptor {
61
62     /** The version constant for v1.0 (value: 1.0) */
63     public static final String JavaDoc VERSION_1_0= "1.0"; //$NON-NLS-1$
64

65     /** The comment , or <code>null</code> for no comment */
66     private final String JavaDoc fComment;
67
68     /** The refactoring descriptors */
69     private final RefactoringDescriptor[] fDescriptors;
70
71     /** The non-empty version string */
72     private final String JavaDoc fVersion;
73
74     /**
75      * Creates a new refactoring session descriptor.
76      *
77      * @param descriptors
78      * the refactoring descriptors in executed order, or the empty
79      * array
80      * @param version
81      * the non-empty version tag, one of the <code>VERSION_xxx</code>
82      * constants
83      * @param comment
84      * the comment of the refactoring session, or <code>null</code>
85      * for no comment
86      */

87     public RefactoringSessionDescriptor(final RefactoringDescriptor[] descriptors, final String JavaDoc version, final String JavaDoc comment) {
88         Assert.isNotNull(descriptors);
89         Assert.isTrue(version != null && !"".equals(version)); //$NON-NLS-1$
90
fDescriptors= new RefactoringDescriptor[descriptors.length];
91         System.arraycopy(descriptors, 0, fDescriptors, 0, descriptors.length);
92         fVersion= version;
93         fComment= comment;
94     }
95
96     /**
97      * Returns the comment.
98      *
99      * @return the comment, or the empty string
100      */

101     public final String JavaDoc getComment() {
102         return (fComment != null) ? fComment : ""; //$NON-NLS-1$
103
}
104
105     /**
106      * Returns the refactoring descriptors.
107      *
108      * @return the array of refactoring descriptors in executed order, or the
109      * empty array
110      */

111     public final RefactoringDescriptor[] getRefactorings() {
112         final RefactoringDescriptor[] result= new RefactoringDescriptor[fDescriptors.length];
113         System.arraycopy(fDescriptors, 0, result, 0, result.length);
114         return result;
115     }
116
117     /**
118      * Returns the version tag.
119      *
120      * @return the version tag
121      */

122     public final String JavaDoc getVersion() {
123         return fVersion;
124     }
125 }
126
Popular Tags