A library contains all keywords defined for a schema, but also all format attributes.
@see ValidationConfigurationBuilder#addLibrary(String,Library) @see ValidationConfigurationBuilder#setDefaultLibrary(String,Library) @see ValidationConfigurationBuilder#setDefaultVersion(SchemaVersion)Library
class represents a SWC archive or a RSL. It implements the Builder
interface which allows for building the library incrementally. The following example defines a SWC archive or RSL: Library lib = new Library();You can add components to the
Library
object in the following ways: 1. String - Specify a fully-qualified name. 2. File - Specify a source file. 3. VirtualLocalFile - Specify an in-memory source object. 4. URI - Specify a namespace URI.
To add resource bundles to the Library
, you can use the addResourceBundle()
method, as the following example shows:
lib.addResourceBundle("mx.controls"));
To add archive files to the Library
, you can use the addArchiveFile()
method, as the following example shows:
lib.addArchiveFile("defaults.css", new File("path1/myStyle.css"));Before you can compile with a
Library
object, you must configure it. The following four methods are the most common methods you use to configure the Library
object: 1. setLogger() - Use this to set a Logger so that the client can be notified of events that occurred during the compilation. 2. setConfiguration() - Optional. Use this to specify compiler options. 3. setOutput() - Optional. Use this to specify an output file name. 4. setDirectory() - Optional. Use this to specify an RSL output directory.You must implement the
flex2.tools.oem.Logger
interface and use the implementation as the Logger
for the compilation. The following is an example Logger
implementation: lib.setLogger(new flex2.tools.oem.Logger() { public void log(Message message, int errorCode, String source) { System.out.println(message); } });To specify compiler options for the
Library
object, you must get a Configuration
object that is populated with default values. Then, you set compiler options programmatically using methods of the Configuration
class. The setOutput()
method lets you specify where the Library
object writes the output to. If you call the setOutput()
method, the build(boolean)
method writes directly to the specified location; for example:
lib.setOutput(new File("MyLib.swc")); lib.build(true);If you do not call the
setOutput()
method, you can use the build(OutputStream, boolean)
method. This requires that you provide a buffered output stream; for example: lib.build(new BufferedOutputStream(new FileOutputStream("MyLib.swc")), true);The
setDirectory()
method lets you output RSLs to the specified directory; for example: lib.setDirectory(new File("dir1")); lib.build(true);You can save the
Library
object compilation data for reuse. You do this using the save(OutputStream)
method. Subsequent compilations can use the load(OutputStream)
method to get the old data into the Library
object; for example: lib.save(new BufferedOutputStream(new FileOutputStream("MyLib.incr")));When a cache file (for example,
MyLib.incr
) from a previous compilation is available before the compilation, you can call the load(OutputStream)
method before you call the build()
method; for example: lib.load(new BufferedInputStream(FileInputStream("MyLib.incr"))); lib.build(true);The
build(false)
and build(OutputStream, false)
methods always rebuild the library. The first time you build the Library
object, the build(true)/build(OutputStream, true)
methods do a complete build, which is equivalent to the build(false)/build(OutputStream, false)
methods, respectively. After you call the clean()
method, the Library
object always does a full build. The clean()
method cleans up compilation data in the Library
object the output file, if the setOutput()
method was called.
You can use the Library
class to build a library from a combination of source files in the file system and in-memory, dynamically-generated source objects. You must use the addComponent(VirtualLocalFile)
, addResourceBundle(VirtualLocalFile)
, and addArchiveFile(String, VirtualLocalFile)
methods to use in-memory objects.
The Library
class can be part of a Project
.
@see flex2.tools.oem.Configuration
@see flex2.tools.oem.Project
@version 2.0.1
@author Clement Wong
The following features are supported:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|