Class FileImportControl


  • class FileImportControl
    extends AbstractImportControl
    Represents an import rules for a specific file. Only the file name is considered and only files processed by TreeWalker. The file's extension is ignored.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String name
      The name for the file.
      private java.util.regex.Pattern patternForExactMatch
      The regex pattern for exact matches - only not null if regex is true.
      private boolean regex
      If this file name represents a regular expression.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileImportControl​(PkgImportControl parent, java.lang.String name, boolean regex)
      Construct a file node.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.regex.Pattern createPatternForExactMatch​(java.lang.String expression)
      Creates a Pattern from expression.
      private static java.lang.String encloseInGroup​(java.lang.String expression)
      Enclose expression in a (non-capturing) group.
      AbstractImportControl locateFinest​(java.lang.String forPkg, java.lang.String forFileName)
      Search down the tree to locate the finest match for a supplied package.
      protected boolean matchesExactly​(java.lang.String pkg, java.lang.String fileName)
      Check for equality of this with pkg.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • name

        private final java.lang.String name
        The name for the file.
      • patternForExactMatch

        private final java.util.regex.Pattern patternForExactMatch
        The regex pattern for exact matches - only not null if regex is true.
      • regex

        private final boolean regex
        If this file name represents a regular expression.
    • Constructor Detail

      • FileImportControl

        FileImportControl​(PkgImportControl parent,
                          java.lang.String name,
                          boolean regex)
        Construct a file node.
        Parameters:
        parent - the parent node.
        name - the name of the file.
        regex - flags interpretation of name as regex pattern.
    • Method Detail

      • encloseInGroup

        private static java.lang.String encloseInGroup​(java.lang.String expression)
        Enclose expression in a (non-capturing) group.
        Parameters:
        expression - the input regular expression
        Returns:
        a grouped pattern.
      • createPatternForExactMatch

        private static java.util.regex.Pattern createPatternForExactMatch​(java.lang.String expression)
        Creates a Pattern from expression.
        Parameters:
        expression - a self-contained regular expression matching the full file name exactly.
        Returns:
        a Pattern.
      • locateFinest

        public AbstractImportControl locateFinest​(java.lang.String forPkg,
                                                  java.lang.String forFileName)
        Description copied from class: AbstractImportControl
        Search down the tree to locate the finest match for a supplied package.
        Specified by:
        locateFinest in class AbstractImportControl
        Parameters:
        forPkg - the package to search for.
        forFileName - the file name to search for.
        Returns:
        the finest match, or null if no match at all.
      • matchesExactly

        protected boolean matchesExactly​(java.lang.String pkg,
                                         java.lang.String fileName)
        Description copied from class: AbstractImportControl
        Check for equality of this with pkg.
        Specified by:
        matchesExactly in class AbstractImportControl
        Parameters:
        pkg - the package to compare with.
        fileName - the file name to compare with.
        Returns:
        if it matches.