Package crystalpalace.spec
Class Capability
- java.lang.Object
-
- crystalpalace.spec.Capability
-
public class Capability extends java.lang.ObjectA class to parse a DLL or COFF Object and extract API/linkarguments from it.Construct this object with
None(java.lang.String),Parse(byte[]),ParseDll(byte[]), orParseObject(byte[]).Use this with
LinkSpec.run(Capability, Map)andLinkSpec.runConfig(crystalpalace.spec.Capability, java.util.Map).
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringarchthe architecture of the capability (e.g., x86, x64)protected byte[]contentsThe contents of the capabilityprotected java.lang.StringkeyThe name of the $KEY for this capability in our environmentprotected java.lang.Stringlabelthe capability-specific program label (e.g., x64.o)
-
Constructor Summary
Constructors Modifier Constructor Description protectedCapability(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.StringgetArch()Get the CPU arch (e.g., x86, x64) of our capabilitybyte[]getContents()Get the contents of this capabilityjava.lang.StringgetKey()Get the $KEY used for this specific capability.java.lang.StringgetLabel()Get the preferred Crystal Palace target label for this capability (e.g., x64.dll)booleanhasCapability()Check if this Capability is associated with a DLL or COFF.booleanisDll()Is the capability a DLL?booleanisObject()Is the capability a COFF?static CapabilityNone(java.lang.String archOrLabel)Create a Capability object, usable with theLinkSpecAPI, but not associated with a DLL or Object.static CapabilityParse(byte[] capability)Create a new Capability by guessing if the capability content is a DLL or Object.static CapabilityParseDll(byte[] dll)Create a new Capability from a DLLstatic CapabilityParseObject(byte[] object)Create a new Capability from a COFF Objectjava.lang.StringtoString()Get the string representation of our capability
-
-
-
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. UseParse(byte[]),ParseDll(byte[]), orParseObject(byte[])to construct this object.- Parameters:
key- the $KEY for our capabilitycontents- the contents (raw data) of our capabilitylabel- the preferred .spec labl for our capabilityarch- 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 theLinkSpecAPI, 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:
toStringin classjava.lang.Object
-
-