Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util
Class JavaGeneratorTool

    java.lang.Object
      org.apache.tomcat.util.JavaGeneratorTool

public class JavaGeneratorTool
extends java.lang.Object

General-purpose utilities to help generation of syntetic java classes

Constructor Summary
`JavaGeneratorTool()`

Method Summary
`static java.lang.String` | `fixDigits(java.lang.String s)` Make sure package components or class name doesn't start with a digit
`static java.lang.String` | `getVersionedName(java.lang.String baseName, int version)`
`static boolean` | `isKeyword(java.lang.String s)`
`static java.lang.String` | `manglePackage(java.lang.String s)` Mangle Package names to avoid reserver words
`static int` | `readVersion(java.lang.String classDir, java.lang.String baseClassName)` Generated java files may be versioned, to avoid full reloading when the source changes.
`static void` | `writeVersion(java.lang.String classDir, java.lang.String baseClassName, int version)` After we compile a page, we save the version in a file with known name, so we can restore the state when we restart.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JavaGeneratorTool

    public JavaGeneratorTool()

Method Detail

### manglePackage

    public static final java.lang.String manglePackage(java.lang.String s)

  Mangle Package names to avoid reserver words

### isKeyword

    public static boolean isKeyword(java.lang.String s)

### fixDigits

    public static java.lang.String fixDigits(java.lang.String s)

  Make sure package components or class name doesn't start with a digit

### readVersion

    public static int readVersion(java.lang.String classDir,
                                  java.lang.String baseClassName)

  Generated java files may be versioned, to avoid full reloading when the source changes. Before generating a file, we check if it is already generated, and for that we need the latest version of the file. One way to do it ( the original jasper ) is to modify the class file and use a class name without version number, then use a class loader trick to load the file and extract the version from the class name. This method implements a different strategy - the classes are generate with version number, and we use a map file to find the latest version of a class. ( we could list ) That can be improved by using a single version file per directory, or by listing the directory. The class file is generated to use _version extension.

  Returns:
    int version number of the latest class file, or -1 if the mapFile or the coresponding class file is not found

### writeVersion

    public static void writeVersion(java.lang.String classDir,
                                    java.lang.String baseClassName,
                                    int version)

  After we compile a page, we save the version in a file with known name, so we can restore the state when we restart. Note that this should move to a general-purpose persist repository ( on my plans for next version of tomcat )

### getVersionedName

    public static java.lang.String getVersionedName(java.lang.String baseName,
                                                    int version)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Apache Software Foundation. All Rights Reserved.