Class ImportStatement

java.lang.Object
processing.mode.java.preproc.ImportStatement

public class ImportStatement extends Object
Wrapper for import statements
  • Method Details

    • wholePackage

      public static ImportStatement wholePackage(String pckg)
      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

      public static ImportStatement singleClass(String cls)
      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

      public static ImportStatement parse(String importString)
      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

      public static ImportStatement parse(MatchResult match)
      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

      public String getFullSourceLine()
      Get the source line needed to execute this import.
      Returns:
      The java code required for executing this import.
    • getFullMemberName

      public String 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

      public String 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

      public String 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

      public boolean isSameAs(ImportStatement is)
      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.