Cramfull Compiled Resources v2.00

be.arci.pub
Class ResourceCompiler

java.lang.Object
  |
  +--be.arci.pub.ResourceCompiler
Direct Known Subclasses:
SerializingResourceCompiler

public class ResourceCompiler
extends java.lang.Object

Utility class to compile a (set of) Resorcer subclass(es). This is a very elaborated example of a user interface to ClassCompiler, the class that actually compiles Cramfull classes.

ResourceCompiler compiles a set of resource files into one or more Cramfull subclasses. An example of also compiling serialized objects into Cramfull subclasses is given in SerializingResourceCompiler

We supply this class as a free service to all users of the Cramfull Compiled Resources library. You are allowed to modify this source code, provided you move the class out of the be.arci package hierarchy.

USAGE: java be.arci.pub.ResourceCompiler [arguments]

Any number of arguments of each type can be given. Commandline arguments are interpreted left to right, command file arguments top to bottom.

ARGUMENTS:

@Commands
Command file with 1 argument per line; comment lines start with '#'
-v or -q
Verbose mode or Quiet mode
-s or -i
Subsequent resource patterns are case Sensitive (default) or case Insensitive
-bBase
Temporary base directory to read subsequent resources from and write subsequent output to.
-cOut
Create Cramfull subclass named Out (a qualified class name)
-rOut
Replace or create Cramfull subclass named Out (a qualified class name)

Subsequent resources will be encoded in the class Out. The default Out name is "MyCramfull", in replace mode. The class-file for any previous Out argument is compiled when a new Out argument is encountered. A package directory tree for Out is created as needed.

-n
Put resources into a nested class Out$Data of Out. The nested class can be garbage collected immediately after class initialization. This option is uneffective in the evaluation version of the Cramfull Compiled Resources library.
-eEnc
Use the qualified classname Enc (an Encoder subclass) to encode subsequent resources. Default is "be.arci.cramfull.ASCIIEncoder"
Resrce
Resource filename or pattern ('*' and '?' are the wildcards). Resources will be encoded into the current Out class with a newInstance() of the current Enc class. The resource's name in Out is the suffix of it's canonical file name that corresponds to the Resrce argument, but with '/' as the separator char. Simply specify a directory to encode all files in it. Use the escapes '@@' and '--' for resource names starting with '@' or '-'.

Example:

java be.arci.pub.ResourceCompiler -n -v -bREDIST -cIconResources -bc:\artwork images/*.gif @localized.txt localized.txt: -------------- #defaults for all locales -bREDIST -rcom.mydomain.profiles.Setup -b. *.gif *.jpg *.properties #french France locale -bREDIST -rcom.mydomain.profiles.Setup_fr_FR -bFrance *.* #english locale -bREDIST -rcom.mydomain.profiles.Setup_en -bEnglish *.* This command and command file will compile the following Cramfull subclasses into the directory REDIST:
  1. IconResources
    creates files REDIST/IconResources.class and REDIST/IconResources$Data.class, with all .gif files from the c:\artwork\images directory, having resource names like "images/somefile.gif"
  2. com.mydomain.profiles.Setup
    replaces files REDIST/com/mydomain/profiles/Setup.class and REDIST/com/mydomain/profiles/Setup$Data.class, with all .gif, .jpg and .properties files of the working directory, with no path prefix in the resource name
  3. com.mydomain.profiles.Setup_fr_FR
    replaces files REDIST/com/mydomain/profiles/Setup_fr_FR.class and REDIST/com/mydomain/profiles/Setup_fr_FR$Data.class, with all files of the France directory, with no path prefix in the resource name
  4. com.mydomain.profiles.Setup_en
    replaces files REDIST/com/mydomain/profiles/Setup_en.class and REDIST/com/mydomain/profiles/Setup_en$Data.class, with all files of the English directory, with no path prefix in the resource name

Evaluation version

Since:
05/nov/2000
See Also:
ClassCompiler,
be.arci.cramfull.Cramfull
,
SerializingResourceCompiler

Field Summary
protected  ClassCompiler compiler
           
static java.lang.String DEFAULT_CRAMFULL
          Default qualified class-name for Cramfull subclass to compile (this class) or view (ResourceViewer)
protected  java.lang.String sEncoder
          Encoder to use for subsequent resources
 
Constructor Summary
protected ResourceCompiler()
          Does nothing
 
Method Summary
protected  void addResource(CompilerEntry ce)
          Adds a CompilerEntry to compile, checking for duplicates on canonical file name
protected  void closeCompiler()
          Calls ClassCompiler to encode the resources and compile the class.
protected  void compile(java.util.Vector vecArgs)
          Does everything else.
static java.util.Vector expandCommandfiles(java.lang.String[] args)
          Expands command file arguments into args.
static void main(java.lang.String[] args)
          Runs a ResourceCompiler with commandline arguments.
protected  void openCompiler(java.io.File flOutputdir, java.lang.String sOutputClass, boolean swReplace)
          Opens a new ClassCompiler, which starts writing the output class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CRAMFULL

public static final java.lang.String DEFAULT_CRAMFULL
Default qualified class-name for Cramfull subclass to compile (this class) or view (ResourceViewer)
See Also:
Cramfull,
ResourceViewer

sEncoder

protected java.lang.String sEncoder
Encoder to use for subsequent resources

compiler

protected ClassCompiler compiler
Constructor Detail

ResourceCompiler

protected ResourceCompiler()
Does nothing
Method Detail

main

public static void main(java.lang.String[] args)
Runs a ResourceCompiler with commandline arguments.

expandCommandfiles

public static java.util.Vector expandCommandfiles(java.lang.String[] args)
Expands command file arguments into args.
Returns:
a Vector of String arguments

openCompiler

protected void openCompiler(java.io.File flOutputdir,
                            java.lang.String sOutputClass,
                            boolean swReplace)
                     throws java.io.IOException
Opens a new ClassCompiler, which starts writing the output class. Subclasses could override this method to add one or more serialized Objects to the ClassCompiler.
See Also:
ClassCompiler.addSerialized(java.lang.String, java.lang.String, java.lang.Object), SerializingResourceCompiler

addResource

protected void addResource(CompilerEntry ce)
                    throws java.io.IOException
Adds a CompilerEntry to compile, checking for duplicates on canonical file name

closeCompiler

protected void closeCompiler()
                      throws java.io.IOException
Calls ClassCompiler to encode the resources and compile the class.

compile

protected void compile(java.util.Vector vecArgs)
Does everything else.

Cramfull Compiled Resources v2.00