langtools/src/share/classes/com/sun/tools/sjavac/options/SourceLocation.java
changeset 24067 76e7b6bbbd85
child 26098 32588700060b
equal deleted inserted replaced
24066:1dfb66929538 24067:76e7b6bbbd85
       
     1 /*
       
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package com.sun.tools.sjavac.options;
       
    27 
       
    28 import java.nio.file.Path;
       
    29 import java.util.List;
       
    30 import java.util.Map;
       
    31 import java.util.Set;
       
    32 
       
    33 import com.sun.tools.sjavac.Module;
       
    34 import com.sun.tools.sjavac.ProblemException;
       
    35 import com.sun.tools.sjavac.Source;
       
    36 
       
    37 /**
       
    38  * Represents a directory to be used for input to sjavac. (For instance a
       
    39  * sourcepath or classpath.)
       
    40  */
       
    41 public class SourceLocation {
       
    42 
       
    43     // Path to the root directory
       
    44     private Path path;
       
    45 
       
    46     // Package include / exclude patterns and file includes / excludes.
       
    47     List<String> includes, excludes, includedFiles, excludedFiles;
       
    48 
       
    49     public SourceLocation(Path path,
       
    50                           List<String> includes,
       
    51                           List<String> excludes,
       
    52                           List<String> includedFiles,
       
    53                           List<String> excludedFiles) {
       
    54         this.path = path;
       
    55         this.includes = includes;
       
    56         this.excludes = excludes;
       
    57         this.includedFiles = includedFiles;
       
    58         this.excludedFiles = excludedFiles;
       
    59     }
       
    60 
       
    61 
       
    62     /**
       
    63      * Finds all files with the given suffix that pass the include / exclude
       
    64      * filters in this source location.
       
    65      *
       
    66      * @param suffixes The set of suffixes to search for
       
    67      * @param foundFiles The map in which to store the found files
       
    68      * @param foundModules The map in which to store the found modules
       
    69      * @param currentModule The current module
       
    70      * @param permitSourcesInDefaultPackage true if sources in default package
       
    71      *                                      are to be permitted
       
    72      * @param inLinksrc true if in link source
       
    73      */
       
    74     public void findSourceFiles(Set<String> suffixes,
       
    75                                 Map<String, Source> foundFiles,
       
    76                                 Map<String, Module> foundModules,
       
    77                                 Module currentModule,
       
    78                                 boolean permitSourcesInDefaultPackage,
       
    79                                 boolean inLinksrc) {
       
    80         try {
       
    81             Source.scanRoot(path.toFile(), suffixes, excludes, includes,
       
    82                     excludedFiles, includedFiles, foundFiles, foundModules,
       
    83                     currentModule, permitSourcesInDefaultPackage, false,
       
    84                     inLinksrc);
       
    85         } catch (ProblemException e) {
       
    86             e.printStackTrace();
       
    87         }
       
    88     }
       
    89 
       
    90     /** Get the root directory of this source location */
       
    91     public Path getPath() {
       
    92         return path;
       
    93     }
       
    94 
       
    95     /** Get the package include patterns */
       
    96     public List<String> getIncludes() {
       
    97         return includes;
       
    98     }
       
    99 
       
   100     /** Get the package exclude patterns */
       
   101     public List<String> getExcludes() {
       
   102         return excludes;
       
   103     }
       
   104 
       
   105     /** Get the file include patterns */
       
   106     public List<String> getIncludedFiles() {
       
   107         return includedFiles;
       
   108     }
       
   109 
       
   110     /** Get the file exclude patterns */
       
   111     public List<String> getExcludedFiles() {
       
   112         return excludedFiles;
       
   113     }
       
   114 
       
   115 }