Class Capability

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String arch
      the architecture of the capability (e.g., x86, x64)
      protected byte[] contents
      The contents of the capability
      protected java.lang.String key
      The name of the $KEY for this capability in our environment
      protected java.lang.String label
      the capability-specific program label (e.g., x64.o)
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Capability​(java.lang.String key, byte[] contents, java.lang.String label, java.lang.String arch)
      Internal constructor to create a Capability.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getArch()
      Get the CPU arch (e.g., x86, x64) of our capability
      byte[] getContents()
      Get the contents of this capability
      java.lang.String getKey()
      Get the $KEY used for this specific capability.
      java.lang.String getLabel()
      Get the preferred Crystal Palace target label for this capability (e.g., x64.dll)
      boolean hasCapability()
      Check if this Capability is associated with a DLL or COFF.
      boolean isDll()
      Is the capability a DLL?
      boolean isObject()
      Is the capability a COFF?
      static Capability None​(java.lang.String archOrLabel)
      Create a Capability object, usable with the LinkSpec API, but not associated with a DLL or Object.
      static Capability Parse​(byte[] capability)
      Create a new Capability by guessing if the capability content is a DLL or Object.
      static Capability ParseDll​(byte[] dll)
      Create a new Capability from a DLL
      static Capability ParseObject​(byte[] object)
      Create a new Capability from a COFF Object
      java.lang.String toString()
      Get the string representation of our capability
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • key

        protected java.lang.String key
        The name of the $KEY for this capability in our environment
      • contents

        protected byte[] contents
        The contents of the capability
      • label

        protected java.lang.String label
        the capability-specific program label (e.g., x64.o)
      • arch

        protected java.lang.String arch
        the architecture of the capability (e.g., x86, x64)
    • Constructor Detail

      • Capability

        protected Capability​(java.lang.String key,
                             byte[] contents,
                             java.lang.String label,
                             java.lang.String arch)
        Internal constructor to create a Capability. Use Parse(byte[]), ParseDll(byte[]), or ParseObject(byte[]) to construct this object.
        Parameters:
        key - the $KEY for our capability
        contents - the contents (raw data) of our capability
        label - the preferred .spec labl for our capability
        arch - the CPU arch (e.g., x86, x64) of our capability
    • Method Detail

      • getKey

        public java.lang.String getKey()
        Get the $KEY used for this specific capability.
        Returns:
        $OBJECT if the capability is COFF, $DLL if the capability is a DLL.
      • getContents

        public byte[] getContents()
        Get the contents of this capability
        Returns:
        the capability contents saved into this object
      • getLabel

        public java.lang.String getLabel()
        Get the preferred Crystal Palace target label for this capability (e.g., x64.dll)
        Returns:
        the target label string for this capability
      • getArch

        public java.lang.String getArch()
        Get the CPU arch (e.g., x86, x64) of our capability
        Returns:
        the String x86 or x64.
      • hasCapability

        public boolean hasCapability()
        Check if this Capability is associated with a DLL or COFF.
        Returns:
        false if this object was created with None(java.lang.String)
      • isObject

        public boolean isObject()
        Is the capability a COFF?
        Returns:
        true if the capability is a COFF.
      • isDll

        public boolean isDll()
        Is the capability a DLL?
        Returns:
        true if the capability is a DLL.
      • None

        public static Capability None​(java.lang.String archOrLabel)
        Create a Capability object, usable with the LinkSpec API, but not associated with a DLL or Object.
        Parameters:
        archOrLabel - the architecture target of our program (e.g., x86, x64) OR the full label name (e.g., foo.x64)
        Returns:
        a Capability object.
      • ParseObject

        public static Capability ParseObject​(byte[] object)
        Create a new Capability from a COFF Object
        Parameters:
        object - the contents of the COFF file.
        Returns:
        a Capability object.
      • ParseDll

        public static Capability ParseDll​(byte[] dll)
        Create a new Capability from a DLL
        Parameters:
        dll - the contents of the DLL file.
        Returns:
        a Capability object.
      • Parse

        public static Capability Parse​(byte[] capability)
        Create a new Capability by guessing if the capability content is a DLL or Object.
        Parameters:
        capability - a Win32 DLL or COFF. If it's a DLL, ParseDll(byte[]) is called. If it's a COFF, ParseObject(byte[]) is called.
        Returns:
        a Capability object.
        Throws:
        java.lang.RuntimeException - if the capability is not a COFF or DLL
      • toString

        public java.lang.String toString()
        Get the string representation of our capability
        Overrides:
        toString in class java.lang.Object