Interface CodeSource

All Superinterfaces:
AutoCloseable, CodeContainer, CodeLoader, CodeMutable, CodeNode, CodeNodeWithFileWriting, CodeProvider, CodeWithContext

public interface CodeSource extends CodeProvider, CodeContainer, CodeNodeWithFileWriting, CodeMutable
A CodeSource represents a physical location where CodePackages and CodeFiles are retrieved from.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Method Details

    • getRootPackage

      CodePackage getRootPackage()
      Returns:
      the root package of this source. Will typically be lazy initialized and traversal (especially CodePathElements.getDeclared()) can be expensive. Results will however be cached to speed up subsequent calls.
    • getDependencies

      CodeSourceDependencies<?> getDependencies()
      Returns:
      the CodeSourceDependencies containing CodeSources that are the parents of this source. These can be considered of the dependencies of this source (like in Maven, Gradle, Yarn, etc.)
    • getParent

      CodeSource getParent()
      Specified by:
      getParent in interface CodeNode
      Returns:
      the first parent from getDependencies() or null if the parents are empty. In the latter case this is the root source (in Java from system classloader with the JDK code).
    • getId

      String getId()
      Returns:
      the unique ID of this source. May be the string representation of the byte or source code location.
    • getByteCodeLocation

      File getByteCodeLocation()
      Returns:
      the File to the physical byte-code or null if not available. Can point to a directory, archive (JAR, WAR, EAR, etc.), or whatever format may be used for the according language. Therefore it is recommended to manually operate on this information.
    • getSourceCodeLocation

      File getSourceCodeLocation()
      Returns:
      the File to the physical source-code or null if not available. Can point to a directory, archive (ZIP, sources.jar, etc.), or whatever format may be used for the according language. Therefore it is not recommended to manually operate on this information.
    • getDescriptor

      CodeSourceDescriptor getDescriptor()
      Returns:
      the CodeSourceDescriptor of this source.
    • getReflectiveObject

      CodeSource getReflectiveObject()
      Returns:
      see CodeMutableItem.getReflectiveObject().
    • getType

      CodeType getType(String qualifiedName)
      ATTENTION:
      When calling getType methods on CodeSource you will only be able to retrieve CodeTypes from exactly this source. This should only be used in very specific situations (e.g. if you only want to retrieve code from main or test locations of a maven project). In most cases you want to use CodeLoader.getType(String) instead.
      Specified by:
      getType in interface CodeLoader
      Parameters:
      qualifiedName - the qualified name of the requested CodeType.
      Returns:
      the requested CodeType or null if not found.
    • getType

      CodeGenericType getType(Class<?> clazz)
      ATTENTION:
      When calling getType methods on CodeSource you will only be able to retrieve CodeTypes from exactly this source. This should only be used in very specific situations (e.g. if you only want to retrieve code from main or test locations of a maven project). In most cases you want to use CodeLoader.getType(Class) instead. This method makes only sense for Java. For other CodeLanguages please ignore this method.
      Specified by:
      getType in interface CodeLoader
      Parameters:
      clazz - the Class to get as CodeGenericType.
      Returns:
      the existing or otherwise newly created CodeGenericType. Typically a CodeType but may also be a array type in case an array was given.
    • getType

      CodeType getType(CodeName qualifiedName)
      ATTENTION:
      When calling getType methods on CodeSource you will only be able to retrieve CodeTypes from exactly this source. This should only be used in very specific situations (e.g. if you only want to retrieve code from main or test locations of a maven project). In most cases you want to use CodeLoader.getType(CodeName) instead.
      Specified by:
      getType in interface CodeLoader
      Parameters:
      qualifiedName - the CodeName of the requested CodeType.
      Returns:
      the requested CodeType or null if not found.