Package processing.mode.java.preproc
Class ImportStatement
java.lang.Object
processing.mode.java.preproc.ImportStatement
Wrapper for import statements
-
Method Summary
Modifier and TypeMethodDescriptionGet the fully qualified member name which includes the package path.Get the source line needed to execute this import.Get the end of the import statement with the type to be imported.Get the package from which the import is being made.booleanCheck if the import statements refer to the same import target.booleanDetermine if this import is a wildcard import.booleanDetermine if this import statement is a static import.static ImportStatementPrase an import statement from a fully qualified name.static ImportStatementparse(MatchResult match) Parse an import statement from a regex match found via SourceUtils.*REGEX*.static ImportStatementsingleClass(String cls) Create an import statement for a single class.static ImportStatementwholePackage(String pckg) Create an import statement for a full package.
-
Method Details
-
wholePackage
Create an import statement for a full package.- Parameters:
cls- The fully qualified name of the package.- Returns:
- ImportStatement which imports all package members in a non-static context using a wildcard.
-
singleClass
Create an import statement for a single class.- Parameters:
cls- The fully qualified name of the class.- Returns:
- ImportStatement which imports the class in a non-static context.
-
parse
Prase an import statement from a fully qualified name.- Parameters:
importString- The fully qualified name from which an import statement should be built. This supports static prepended so both "java.util.List" and "static org.processing.package.Factory.build" are supported but "import java.util.List;" is not. Note that the static prepending is required if the import is static.- Returns:
- Newly parsed import statement information.
-
parse
Parse an import statement from a regex match found via SourceUtils.*REGEX*.- Parameters:
match- The regex match from which an import statement should be built. Can be from IMPORT_REGEX_NO_KEYWORD or IMPORT_REGEX or equivalent.- Returns:
- Newly parsed import statement information.
-
getFullSourceLine
Get the source line needed to execute this import.- Returns:
- The java code required for executing this import.
-
getFullMemberName
Get the fully qualified member name which includes the package path.- Returns:
- The fully qualified member name including the parent class. This is "java.util.List" in the case of "import java.util.List". Note that, in the case of static imports, it will include the member imported so "org.processing.package.Factory.build" would be returned for "import static org.processing.package.Factory.build".
-
getMemberName
Get the end of the import statement with the type to be imported.- Returns:
- This is the class name (List) in the case of "import java.util.List" or "*" in the case of a wildcard. For static imports this will be the member within the containing class (Factory.build in the case of "import static org.processing.package.Factory.build").
-
getPackageName
Get the package from which the import is being made.- Returns:
- The package "java.util" from "import java.util.List". Note that, in the case of wildcards, the wildcard will be in the member name and not the class name.
-
isStarredImport
public boolean isStarredImport()Determine if this import is a wildcard import.- Returns:
- True if the FQN (fully qualified name) ends in a wildcard and false otherwise.
-
isStaticImport
public boolean isStaticImport()Determine if this import statement is a static import.- Returns:
- True if of the form "import static {FQN}" where FQN refers to the fully qualified name and false otherwise.
-
isSameAs
Check if the import statements refer to the same import target.- Parameters:
is- The other import statement.- Returns:
- True of the two ImportStatements refer to the same import target and false otherwise.
-