KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > save > EstimatorFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.java.source.save;
20
21 import com.sun.source.tree.*;
22 import java.util.List JavaDoc;
23 import org.netbeans.api.java.source.WorkingCopy;
24
25 /**
26  * Factory used for creating instances of position provider.
27  *
28  * @author Pavel Flaska
29  */

30 final class EstimatorFactory {
31     
32     // prevent instance creation
33
private EstimatorFactory() {
34     }
35     
36     static PositionEstimator throwz(List JavaDoc<? extends ExpressionTree> oldL,
37                                     List JavaDoc<? extends ExpressionTree> newL,
38                                     WorkingCopy copy)
39     {
40         return new PositionEstimator.ThrowsEstimator(oldL, newL, copy);
41     }
42     
43     static PositionEstimator implementz(List JavaDoc<? extends Tree> oldL,
44                                         List JavaDoc<? extends Tree> newL,
45                                         WorkingCopy copy)
46     {
47         return new PositionEstimator.ImplementsEstimator(oldL, newL, copy);
48     }
49     
50     static PositionEstimator extendz(List JavaDoc<? extends Tree> oldL,
51                                      List JavaDoc<? extends Tree> newL,
52                                      WorkingCopy copy)
53     {
54         return new PositionEstimator.ExtendsEstimator(oldL, newL, copy);
55     }
56     
57     static PositionEstimator members(List JavaDoc<? extends Tree> oldL,
58                                      List JavaDoc<? extends Tree> newL,
59                                      WorkingCopy copy)
60     {
61         return new PositionEstimator.MembersEstimator(oldL, newL, copy);
62     }
63     
64     static PositionEstimator toplevel(List JavaDoc<? extends Tree> oldL,
65                                       List JavaDoc<? extends Tree> newL,
66                                       WorkingCopy copy)
67     {
68         return new PositionEstimator.TopLevelEstimator(oldL, newL, copy);
69     }
70
71     /**
72      * Provides offset positions for imports.
73      * Consider compilation unit:
74      * <pre>
75      * package yerba.mate;
76      *
77      * import java.io.File;
78      * import java.util.Collection; // utility methods
79      * import java.util.Map;
80      * // comment
81      * import java.net.URL;
82      *
83      * public class Taragui {
84      * ...
85      * }
86      * </pre>
87      *
88      * Bounds for every import statement is marked by [] pair in next
89      * sample:
90      * <pre>
91      * package yerba.mate;
92      *
93      * [import java.io.File;\n]
94      * [import java.util.Collection; // utility methods\n]
95      * [import java.util.Map;\n]
96      * [// comment
97      * import java.net.URL;\n]
98      * \n
99      * public class Taragui {
100      * ...
101      * }
102      * </pre>
103      * These bounds are returned when user ask for offset of the specified
104      * import statement.
105      */

106     static PositionEstimator imports(List JavaDoc<? extends ImportTree> oldL,
107                                      List JavaDoc<? extends ImportTree> newL,
108                                      WorkingCopy copy)
109     {
110         return new PositionEstimator.ImportsEstimator(oldL, newL, copy);
111     }
112 }
113
Popular Tags