Package org.eigenbase.resgen

## Class ResourceGenTask

- java.lang.Object
- - Task
  - - org.eigenbase.resgen.ResourceGenTask

    public class ResourceGenTask
    extends Task

A `ResourceGenTask` is an ANT task to invoke the Eigenbase Resource Generator.

Example:

>     <resgen srcdir="source" locales="en_US">
>         <include name="happy/BirthdayResource.xml"/>
>     </resgen>

generates

>     source/happy/BirthdayResource.properties
>     source/happy/BirthdayResource_en_US.properties
>     source/happy/BirthdayResource.java
>     source/happy/BirthdayResource_en_US.java

C++ Example:

>     <resgen mode="c++" srcdir="source" locales="en_US">
>         <include name="happy/BirthdayResource.xml"/>
>     </resgen>

generates

>     source/happy/BirthdayResource.resources
>     source/happy/BirthdayResource_en_US.resources
>     source/happy/BirthdayResource.h
>     source/happy/BirthdayResource.cpp

Files are not generated if there is an existing newer one.

The output path is determined by 'destdir' (or 'resdir' for .properties files) and the package-name (derived from the XML file's path relative to 'srcdir'). Since the Java runtime environment searches for resource bundles on the classpath, it is typical to set srcdir="src", destdir="src", resdir="classes".

## Element <resourceGen>

Attribute | Description | Required
--- | --- | ---
mode | Generation mode. Acceptable values are "java", "c++" or "all". The default is "java". | No
srcdir | Source directory. The paths of resource files, and hence the package names of generated Java classes, are relative to this directory. | Yes
destdir | Destination directory. Output .java files are generated relative to this directory. If not specified, has the same value as srcdir. | No
resdir | Resource directory. Output .properties files are generated relative to this directory. If not specified, has the same value as destdir. | No
locales | Comma-separated list of locales to generate files for. If not specified, uses the locale of the resource file. | No
style | Code-generation style. Values are "dynamic" or "functor". Default is "dynamic": generate several non-static methods for each resource. In the "functor" style, there is one member per resource, which has several methods. | No
force | Whether to generate files even if they do not appear to be out of date. Default is false. | No

commentstyle

Generated comment style. Values are "normal" and "scm-safe". The default is "normal": generates comments that indicate the source file's original path and states that the file should not be checked into source control systems. The "scm-safe" comment style modifies the comments to make storage of the output files in an SCM more palatable. It omits the source file's path and states that the file was generated and should not be edited manually.

No

Nested element: <`include`>.

Since:
  Oct 8, 2002
Version:
  $Id: //open/util/resgen/src/org/eigenbase/resgen/ResourceGenTask.java#7 $
Author:
  jhyde

### Nested Class Summary

Nested Classes
`static class` `ResourceGenTask.Include` `Include` implements <include> element nested within a <resgen> task (see `ResourceGenTask`).

### Field Summary

Fields
`static int` `COMMENT_STYLE_NORMAL`
`static int` `COMMENT_STYLE_SCM_SAFE`
`(package private) int` `commentStyle`
`(package private) java.io.File` `dest`
`(package private) boolean` `force`
`(package private) java.lang.String` `locales`
`(package private) int` `mode`
`(package private) java.io.File` `res`
`(package private) java.io.File` `src`
`(package private) int` `style`
`static int` `STYLE_DYNAMIC`
`static int` `STYLE_FUNCTOR`

### Constructor Summary

Constructors
`ResourceGenTask()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addInclude​(ResourceGenTask.Include resourceArgs)` Called by ANT.
`void` `execute()`
`java.io.File` `getDestdir()` Returns destdir.
`(package private) ResourceGenTask.Include[]` `getIncludes()`
`java.io.File` `getSrcdir()` Returns srcdir.
`void` `setCommentStyle​(java.lang.String commentStyle)` Sets commentstyle.
`void` `setDestdir​(java.io.File destDir)` Sets destdir.
`void` `setForce​(boolean force)` Sets force.
`void` `setLocales​(java.lang.String locales)` Sets locales.
`void` `setMode​(java.lang.String mode)` Sets mode.
`void` `setResdir​(java.io.File resDir)` Sets resdir.
`void` `setSrcdir​(java.io.File srcDir)` Sets srcdir.
`void` `setStyle​(java.lang.String style)` Sets style.
`(package private) void` `validate()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### mode

    int mode

#### src

    java.io.File src

#### dest

    java.io.File dest

#### res

    java.io.File res

#### style

    int style

#### locales

    java.lang.String locales

#### force

    boolean force

#### commentStyle

    int commentStyle

#### STYLE_DYNAMIC

    public static final int STYLE_DYNAMIC

See Also:
  Constant Field Values

#### STYLE_FUNCTOR

    public static final int STYLE_FUNCTOR

See Also:
  Constant Field Values

#### COMMENT_STYLE_NORMAL

    public static final int COMMENT_STYLE_NORMAL

See Also:
  Constant Field Values

#### COMMENT_STYLE_SCM_SAFE

    public static final int COMMENT_STYLE_SCM_SAFE

See Also:
  Constant Field Values

### Constructor Detail

#### ResourceGenTask

    public ResourceGenTask()

### Method Detail

#### execute

    public void execute()
                 throws BuildException

Throws:
  `BuildException`

#### addInclude

    public void addInclude​(ResourceGenTask.Include resourceArgs)

Called by ANT.

#### validate

    void validate()

#### getIncludes

    ResourceGenTask.Include[] getIncludes()

#### setMode

    public void setMode​(java.lang.String mode)
                 throws BuildException

Sets mode.

Throws:
  `BuildException`

#### setSrcdir

    public void setSrcdir​(java.io.File srcDir)

Sets srcdir.

#### getSrcdir

    public java.io.File getSrcdir()

Returns srcdir.

#### setDestdir

    public void setDestdir​(java.io.File destDir)

Sets destdir.

#### getDestdir

    public java.io.File getDestdir()

Returns destdir.

#### setResdir

    public void setResdir​(java.io.File resDir)

Sets resdir.

#### setStyle

    public void setStyle​(java.lang.String style)
                  throws BuildException

Sets style.

Throws:
  `BuildException`

#### setLocales

    public void setLocales​(java.lang.String locales)
                    throws BuildException

Sets locales.

Throws:
  `BuildException`

#### setForce

    public void setForce​(boolean force)

Sets force.

#### setCommentStyle

    public void setCommentStyle​(java.lang.String commentStyle)
                         throws BuildException

Sets commentstyle.

Throws:
  `BuildException`