pivot.wtkx
Class Compiler

java.lang.Object
  extended by pivot.wtkx.Compiler

public class Compiler
extends Object

Provides the facility by which WTKX resources can be compiled into Java classes. This enables callers to leverage compile-time checking of their WTKX files as well as a performance improvement over runtime WTKX parsing (via WTKXSerializer).

NOTE: This class contains experimental functionality and should be considered a "preview" until a future release.

Author:
tvolkert

Constructor Summary
Compiler()
          Creates a new Compiler.
 
Method Summary
 boolean compile(Class<?> referenceClass, String resourceName, Iterable<String> options)
          Compiles a WTKX resource into a Java class file.
static Class<Bindable.ObjectHierarchy> getClass(Class<?> referenceClass, String resourceName)
          Gets the compiled class created from a WTKX resource.
static String getPreferredClassName(Class<?> referenceClass, String resourceName)
          Returns the preferred class name for a compiled WTKX resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler()
Creates a new Compiler.

Method Detail

compile

public boolean compile(Class<?> referenceClass,
                       String resourceName,
                       Iterable<String> options)
                throws IOException
Compiles a WTKX resource into a Java class file.

Parameters:
referenceClass - The class relative to which the WTKX resource can be found.
resourceName - A path name that identifies the WTKX resource. The path name should be of the form defined by Class.getResource(String) and is relative to the base package. Note that this is the same form as is defined in Bindable.Load.resourceName().
options - Compiler options, or null for no options.
Returns:
true if the resource compiled without errors; false otherwise.
Throws:
IOException

getPreferredClassName

public static String getPreferredClassName(Class<?> referenceClass,
                                           String resourceName)
Returns the preferred class name for a compiled WTKX resource. The WTKX binding process will automatically attempt to discover and use compiled versions of WTKX resources (as opposed to parsing WTKX at runtime using WTKXSerializer) based on their preferred class names.

Parameters:
referenceClass - The class relative to which the WTKX resource will be considered. Use null to specify that the WTKX resource is relative to no class.
resourceName - A path name that identifies the WTKX resource. The path name should be of the form defined by Class.getResource(String) and is relative to the reference class. Note that this is the same form as is defined in Bindable.Load.resourceName().
Returns:
The preferred class name for a compiled version of the specified WTKX resource.

getClass

public static Class<Bindable.ObjectHierarchy> getClass(Class<?> referenceClass,
                                                       String resourceName)
Gets the compiled class created from a WTKX resource. This assumes that the class is named according to the preferred class name for compiled WTKX resources. If a compiled version of the resource exists but is named differently, this method will not discover it.

Parameters:
referenceClass - The class relative to which the WTKX resource will be considered. Use null to specify that the WTKX resource is relative to no class.
resourceName - A path name that identifies the WTKX resource. The path name should be of the form defined by Class.getResource(String) and is relative to the reference class. Note that this is the same form as is defined in Bindable.Load.resourceName().
Returns:
The compiled WTKX class, or null if no such class was discovered.