langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Dependency.java
changeset 30846 2b3f379840f0
parent 25874 83c19f00452c
equal deleted inserted replaced
30845:43ddd58a5a56 30846:2b3f379840f0
       
     1 /*
       
     2  * Copyright (c) 2009, 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.classfile;
       
    27 
       
    28 
       
    29 /**
       
    30  * A directed relationship between two {@link Dependency.Location Location}s.
       
    31  * Subtypes of {@code Dependency} may provide additional detail about the dependency.
       
    32  *
       
    33  * @see Dependency.Finder
       
    34  * @see Dependency.Filter
       
    35  * @see Dependencies
       
    36  */
       
    37 public interface Dependency {
       
    38     /**
       
    39      * A filter used to select dependencies of interest, and to discard others.
       
    40      */
       
    41     public interface Filter {
       
    42         /**
       
    43          * Return true if the dependency is of interest.
       
    44          * @param dependency the dependency to be considered
       
    45          * @return true if and only if the dependency is of interest.
       
    46          */
       
    47         boolean accepts(Dependency dependency);
       
    48     }
       
    49 
       
    50     /**
       
    51      * An interface for finding the immediate dependencies of a given class file.
       
    52      */
       
    53     public interface Finder {
       
    54         /**
       
    55          * Find the immediate dependencies of a given class file.
       
    56          * @param classfile the class file to be examined
       
    57          * @return the dependencies located in the given class file.
       
    58          */
       
    59         public Iterable<? extends Dependency> findDependencies(ClassFile classfile);
       
    60     }
       
    61 
       
    62 
       
    63     /**
       
    64      * A location somewhere within a class. Subtypes of {@code Location}
       
    65      * may be used to provide additional detail about the location.
       
    66      */
       
    67     public interface Location {
       
    68         /**
       
    69          * Get the name of the class containing the location.
       
    70          * This name will be used to locate the class file for transitive
       
    71          * dependency analysis.
       
    72          * @return the name of the class containing the location.
       
    73          */
       
    74         String getName();
       
    75 
       
    76         /**
       
    77          * Get the fully-qualified name of the class containing the location.
       
    78          * @return the fully-qualified name of the class containing the location.
       
    79          */
       
    80         String getClassName();
       
    81 
       
    82         /**
       
    83          * Get the package name of the class containing the location.
       
    84          * @return the package name of the class containing the location.
       
    85          */
       
    86         String getPackageName();
       
    87     }
       
    88 
       
    89 
       
    90     /**
       
    91      * Get the location that has the dependency.
       
    92      * @return the location that has the dependency.
       
    93      */
       
    94     Location getOrigin();
       
    95 
       
    96     /**
       
    97      * Get the location that is being depended upon.
       
    98      * @return the location that is being depended upon.
       
    99      */
       
   100     Location getTarget();
       
   101 }
       
   102