Class LoadedLibrary

java.lang.Object
i5.las2peer.classLoaders.libraries.LoadedLibrary
Direct Known Subclasses:
LoadedJarLibrary, LoadedNetworkLibrary

public abstract class LoadedLibrary extends Object
a loaded library represents a library in the l2p classloader context
  • Method Details

    • getLibraryIdentifier

      public LibraryIdentifier getLibraryIdentifier()
      Returns:
      the identifier (name and version) for the library to which this ClassLoader is bound
    • getResourceAsUrl

      public abstract URL getResourceAsUrl(String name) throws ResourceNotFoundException
      for class and resource loading: get the URL for the specified resource
      Parameters:
      name - A resource name
      Returns:
      a URL for the requested resource
      Throws:
      ResourceNotFoundException - the given resource does not exists in this library
    • getResourceAsString

      public String getResourceAsString(String resourceName) throws IOException, ResourceNotFoundException
      get the contents of a resource as a String
      Parameters:
      resourceName - A resource name
      Returns:
      content of the given resource as string
      Throws:
      IOException - If the resource could not be read
      ResourceNotFoundException - the given resource does not exists in this library
    • getResourceAsBinary

      public byte[] getResourceAsBinary(String resourceName) throws IOException, ResourceNotFoundException
      get the contents of a resource as a byte array
      Parameters:
      resourceName - A resource name
      Returns:
      contents of the requested resource
      Throws:
      IOException - If the resource could not be read
      ResourceNotFoundException - the given resource does not exists in this library
    • getIdentifier

      public LibraryIdentifier getIdentifier()
      returns the library identifier for the library, this object is responsible for (including name and version)
      Returns:
      indentifier of the nested library
    • classToResourceName

      public static String classToResourceName(String className)
      Helper method to get the name of a class file from the corresponding name of the class
      Parameters:
      className - name of a class
      Returns:
      a String
    • resourceToClassName

      public static String resourceToClassName(String entryName)
      Helper method to transform the name of an jar file entry into a java classname.
      Parameters:
      entryName - name of a jar file entry
      Returns:
      class name