Google Web Toolkit (Beta)
Search this site:

# Class Generator

public class Generator
extends Object
Generates source code for subclasses during deferred binding requests. Subclasses must be thread-safe.

## Methods

escape(String) | Escapes string content to be a valid string literal.
generate(TreeLogger, GeneratorContext, String) | Generate a default constructible subclass of the requested type.

## Method Detail

### escape

public static String escape(String unescaped)
Escapes string content to be a valid string literal.

#### Parameters

unescaped

#### Return Value

an escaped version of `unescaped`, suitable for being enclosed in double quotes in Java source

### generate

public abstract String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException
Generate a default constructible subclass of the requested type. The generator throws `UnableToCompleteException` if for any reason it cannot provide a substitute class

#### Parameters

logger
context
typeName

#### Return Value

the name of a subclass to substitute for the requested class, or return `null` to cause the requested type itself to be used