|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threerings.presents.tools.ImportSet
public class ImportSet
Manages a set of strings to be used as a set of imports. Provides useful functions for manipulating the set and sorts results.
Some methods in this class use a variable length String parameter 'replace'. This is a convenience for easily specifying multiple find/replace pairs. For example, to replace "Foo" with "Bar" and "123" with "ABC", a function can be called with the 4 arguments "Foo", "Bar", "123", "ABC" for the String... replace argument.
A few methods also use a "pattern" string parameter that is used to match a class name. This is a dumbed down regular expression (to avoid many \.) where "*" means .* and no other characters have special meaning. The pattern is also implicitly enclosed with ^$ so that the pattern must match the class name in its entirety. Callers will mostly use this to specify a prefix like "something*" or a suffix like "*something".
| Constructor Summary | |
|---|---|
ImportSet()
|
|
| Method Summary | |
|---|---|
void |
add(Class<?> clazz)
Adds the given class' name to the set of imports. |
void |
add(String name)
Adds the given name to the set of imports. |
void |
addAll(ImportSet other)
Adds all the imports from another import set into this one. |
void |
addMunged(Class<?> clazz,
String... replace)
Adds a class' name to the imports but first performs the given list of search/replaces as described above. |
ImportSet |
clone()
|
void |
duplicateAndMunge(String pattern,
String... replace)
Adds a new munged import for each existing import that matches a pattern. |
void |
popIn()
Re-adds the most recently popped import to the set. |
void |
pushOut(String pattern)
Temporarily remove one import matching the given pattern. |
void |
remove(Class<?> clazz)
Removes the name of a class from the imports. |
int |
removeAll(String pattern)
Remove all imports matching the given pattern. |
int |
removeArrays()
Gets rid of array imports. |
void |
removeGlobals()
Gets rid of primitive and java.lang imports. |
void |
removeSamePackage(String pkg)
Remove all classes that are in the same package. |
void |
replace(Class<?> pattern,
String replacement)
Replace the import matchings a class name. |
void |
replace(String... replace)
Replaces any import exactly each find string with the corresponding replace string. |
void |
swapInnerClassesForParents()
Replaces inner class imports (those with a '$') with an import of the parent class. |
List<String> |
toList()
Convert the set of imports to a sorted list, ready to be output to a generated file. |
String |
toString()
|
void |
translateClassArrays()
Inserts imports for the non-primitive classes contained in all array imports. |
void |
translateInnerClasses()
Replace all inner classes' separator characters ('$') with an underscore ('_') for use when generating ActionScript. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ImportSet()
| Method Detail |
|---|
public void add(Class<?> clazz)
clazz - the class to addpublic void add(String name)
name - the name to addpublic void addAll(ImportSet other)
other - the import set whose imports should be added
public void addMunged(Class<?> clazz,
String... replace)
clazz - the class whose name is munged and addedreplace - array of pairs to search/replace on the name before addingpublic ImportSet clone()
clone in class Objectpublic void removeGlobals()
public int removeArrays()
public void removeSamePackage(String pkg)
pkg - package to removepublic void swapInnerClassesForParents()
public void translateInnerClasses()
public void translateClassArrays()
public void pushOut(String pattern)
popIn. If there is no match, a null value is pushed so
that popIn can still be called.
pattern - to matchpublic void popIn()
IndexOutOfBoundsException - if there is nothing to poppublic void remove(Class<?> clazz)
clazz - the class whose name should be removedpublic void replace(String... replace)
replace - array of pairs for search/replace
public void replace(Class<?> pattern,
String replacement)
pattern - the class whose name to matchreplacement - string to use insteadpublic int removeAll(String pattern)
pattern - the dumbed down regex to match (see description above)
public void duplicateAndMunge(String pattern,
String... replace)
pattern - to qualify imports to duplicatereplace - pairs to find/replace on the new importpublic List<String> toList()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||