Class Utilities


  • public class Utilities
    extends java.lang.Object
    • Field Detail

      • CONTRACT_WITH_SLASHES

        private static final java.lang.String CONTRACT_WITH_SLASHES
      • SCOPE_WITH_SLASHES

        private static final java.lang.String SCOPE_WITH_SLASHES
      • QUALIFIER_WITH_SLASHES

        private static final java.lang.String QUALIFIER_WITH_SLASHES
      • METHOD_GENERATOR_WITH_SLASHES

        private static final java.lang.String METHOD_GENERATOR_WITH_SLASHES
        See Also:
        Constant Field Values
      • GENERATOR_NAME_FIELD_WITH_SLASHES

        private static final java.lang.String GENERATOR_NAME_FIELD_WITH_SLASHES
        See Also:
        Constant Field Values
      • ISA_CONTRACT

        private final java.util.Map<java.lang.String,​java.lang.Boolean> ISA_CONTRACT
      • ISA_SCOPE

        private final java.util.Map<java.lang.String,​java.lang.Boolean> ISA_SCOPE
      • ISA_QUALIFIER

        private final java.util.Map<java.lang.String,​java.lang.Boolean> ISA_QUALIFIER
      • FOUND_SUPERCLASS

        private final java.util.Map<java.lang.String,​java.lang.String> FOUND_SUPERCLASS
      • FOUND_INTERFACES

        private final java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> FOUND_INTERFACES
      • METADATA

        private final java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> METADATA
      • verbose

        private final boolean verbose
      • searchPath

        private final java.util.List<java.io.File> searchPath
      • openedJarFiles

        private final java.util.Map<java.io.File,​java.util.jar.JarFile> openedJarFiles
      • CONFIGURED_CONTRACT

        private static final java.lang.String CONFIGURED_CONTRACT
        See Also:
        Constant Field Values
      • GENERATOR_IMPL_NAME

        private static final java.lang.String GENERATOR_IMPL_NAME
        See Also:
        Constant Field Values
      • GENERATOR_SCOPE_NAME

        private static final java.lang.String GENERATOR_SCOPE_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • Utilities

        Utilities​(boolean verbose,
                  java.util.List<java.io.File> searchPath)
      • Utilities

        Utilities​(boolean verbose,
                  java.lang.String searchPath)
    • Method Detail

      • getFilesFromSearchPath

        private static java.util.List<java.io.File> getFilesFromSearchPath​(java.lang.String searchPath)
      • findClass

        private java.io.InputStream findClass​(java.util.List<java.io.File> searchHeres,
                                              java.lang.String dotDelimitedName,
                                              boolean searchClassPath,
                                              java.lang.String calledFrom)
                                       throws java.io.IOException
        Will look for a file on a last-ditch sort of effort using the searchHere thing (jar or directory) and then also in the classpath
        Parameters:
        searchHere -
        dotDelimitedName -
        searchClassPath - true if the classpath should be searched as well
        Returns:
        an IOStream if the file could be located
        Throws:
        java.io.IOException
      • nullCaches

        private void nullCaches​(java.lang.String dotDelimitedName)
      • isClassAContract

        private boolean isClassAContract​(java.util.List<java.io.File> searchHeres,
                                         java.lang.String dotDelimitedName)
        Returns true if the given class is a contract
        Parameters:
        searchHere - The file or jar to look in
        dotDelimitedName - The fully qualified class name to look for
        Returns:
        true if this can determine that this is a contract
      • getSuperclass

        private java.lang.String getSuperclass​(java.util.List<java.io.File> searchHeres,
                                               java.lang.String dotDelimitedName)
        Returns true if the given class is a contract
        Parameters:
        searchHere - The file or jar to look in
        dotDelimitedName - The fully qualified class name to look for
        Returns:
        The dot-delimited superclass name or null if this is terminal (is an interface or extends java.lang.Object)
      • isClassAScope

        public boolean isClassAScope​(java.util.List<java.io.File> searchHeres,
                                     java.lang.String dotDelimitedName)
        Returns true if it can be determined that this class is a scope
        Parameters:
        searchHere -
        dotDelimitedName -
        Returns:
        true if this class is a scope
      • isClassAQualifier

        public boolean isClassAQualifier​(java.util.List<java.io.File> searchHeres,
                                         java.lang.String dotDelimitedName)
        Returns true if it can be determined that this class is a qualifier
        Parameters:
        searchHere -
        dotDelimitedName -
        Returns:
        true if this class is a qualifier
      • isClassAGenerator

        public GenerateMethodAnnotationData isClassAGenerator​(java.util.List<java.io.File> searchHeres,
                                                              java.lang.String dotDelimitedName)
        Returns true if it can be determined that this class is a generator
        Parameters:
        searchHere -
        dotDelimitedName -
        Returns:
        true if this class is a qualifier
      • getAssociatedSuperclassContracts

        private void getAssociatedSuperclassContracts​(java.util.List<java.io.File> searchHeres,
                                                      java.lang.String dotDelimitedName,
                                                      java.util.Set<java.lang.String> addToMe)
      • getAssociatedContracts

        public java.util.Set<java.lang.String> getAssociatedContracts​(java.util.List<java.io.File> searchHeres,
                                                                      java.lang.String dotDelimitedName)
        Gets the contracts associated with the name passed in
        Parameters:
        searchHere -
        dotDelimitedName -
        Returns:
        The set of contracts associated with this dotDelimited name (ordered iterator)
      • addSubInterface

        private void addSubInterface​(java.util.List<java.io.File> searchHeres,
                                     java.lang.String dotDelimitedInterface,
                                     java.util.LinkedHashSet<java.lang.String> retVal)
      • getMetadataKey

        public java.lang.String getMetadataKey​(java.lang.String scopeOrQualifier,
                                               java.lang.String methodName)
      • getListActualType

        static java.lang.String getListActualType​(java.lang.String signature)
      • getFirstParameterType

        static java.lang.String getFirstParameterType​(java.lang.String desc)
      • createDescriptorIfService

        public java.util.List<DescriptorImpl> createDescriptorIfService​(java.io.InputStream is,
                                                                        java.util.List<java.io.File> searchHeres)
                                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • findAllServicesFromDirectory

        public java.util.List<DescriptorImpl> findAllServicesFromDirectory​(java.io.File directory,
                                                                           java.util.List<java.io.File> parent)
                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()