Interface IContextSource

  • All Known Implementing Classes:
    DirectoryContextSource

    public interface IContextSource
    A specific type of context unit.

    Implementations do not need to cache the results of any provided methods.

    • Field Detail

      • CLASS_SUFFIX

        static final java.lang.String CLASS_SUFFIX
        The file extension for class files.
        See Also:
        Constant Field Values
    • Method Detail

      • getName

        java.lang.String getName()
        Get a human-readable name to identify this context source.
        Returns:
        a human-readable name
      • getEntries

        IContextSource.Entries getEntries()
        Get a listing of all entries in this context unit.
        Returns:
        the entries in this unit
      • getClassBytes

        default byte[] getClassBytes​(java.lang.String className)
                              throws java.io.IOException
        Get the full bytes for a class's contents.
        Parameters:
        className - the class name, with no trailing /
        Returns:
        the bytes, or null if no class with that name is present
        Throws:
        java.io.IOException - if an error is encountered while reading the class data
      • getInputStream

        default java.io.InputStream getInputStream​(IContextSource.Entry resource)
                                            throws java.io.IOException
        Get an input stream for a specific resource. This will return null if a directory is requested.
        Parameters:
        resource - the resource to request
        Returns:
        an input stream
        Throws:
        java.io.IOException - if an input stream could not be opened
      • getInputStream

        java.io.InputStream getInputStream​(java.lang.String resource)
                                    throws java.io.IOException
        Get an input stream for a specific resource. This will return null if a directory is requested.
        Parameters:
        resource - the resource to request
        Returns:
        an input stream
        Throws:
        java.io.IOException - if an input stream could not be opened
      • createOutputSink

        default IContextSource.IOutputSink createOutputSink​(IResultSaver saver)
        Create a sink that can write the decompiled output from this context element.

        If this context source type does not support writing, return a null sink.

        Parameters:
        saver - the source result saver for this decompiler, for delegation
        Returns:
        the output sink, or null if unwritable