Example usage for com.google.gwt.user.rebind ClassSourceFileComposerFactory setJavaDocCommentForClass

List of usage examples for com.google.gwt.user.rebind ClassSourceFileComposerFactory setJavaDocCommentForClass

Introduction

In this page you can find the example usage for com.google.gwt.user.rebind ClassSourceFileComposerFactory setJavaDocCommentForClass.

Prototype

public void setJavaDocCommentForClass(String comment) 

Source Link

Document

Sets the java doc comment for this.

Usage

From source file:com.google.code.gwt.database.rebind.SqlProxyCreator.java

License:Apache License

/**
 * Returns a SourceWriter which is prepared to write the class' body.
 * /*from w ww  .  ja  v  a2  s. c  o m*/
 * @throws UnableToCompleteException
 */
private SourceWriter getSourceWriter() throws UnableToCompleteException {
    JPackage serviceIntfPkg = dataService.getPackage();
    String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
    PrintWriter printWriter = context.tryCreate(logger, packageName, getProxySimpleName());

    if (printWriter == null) {
        // Proxy already exists.
        return null;
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
            getProxySimpleName());

    for (String imp : IMPORTED_CLASSES) {
        composerFactory.addImport(imp);
    }

    JClassType superType = dataService.getImplementedInterfaces()[0];
    if (GeneratorUtils.isType(superType, DataService.class)) {
        composerFactory.setSuperclass(genUtils.getClassName(BaseDataService.class));
        isBaseType = true;
    } else {
        isBaseType = false;
        // the dataService inherits from a different interface.
        // Create another SqlProxyCreator to take care of that interface:
        SqlProxyCreator superClassCreator = new SqlProxyCreator(logger.branch(TreeLogger.DEBUG,
                "Generating proxy methods for superclass '" + superType.getQualifiedSourceName() + "'..."),
                context, superType);
        String className = superClassCreator.create();
        composerFactory.setSuperclass(genUtils.shortenName(className));
    }
    composerFactory.addImplementedInterface(genUtils.getClassName(dataService));

    composerFactory.setJavaDocCommentForClass("Generated by {@link " + genUtils.getClassName(getClass()) + "}");

    return composerFactory.createSourceWriter(context, printWriter);
}

From source file:rocket.generator.rebind.type.NewConcreteOrInterfaceType.java

License:Apache License

/**
 * Adds a java doc comment that includes a variety of statistics about the
 * class thats about to be generated.//  www.  jav  a  2  s  . com
 * 
 * @param composerFactory
 */
protected void setClassJavaDoc(final ClassSourceFileComposerFactory composerFactory) {
    Checker.notNull("parameter:composerFactory", composerFactory);

    String comments = this.getComments();
    final String date = DateFormat.getInstance().format(new Date());
    final String generatorName = this.getGeneratorContext().getGenerator().getClass().getName();
    comments = comments + "\n\nGenerated at " + date + " by " + generatorName;

    final MetaData metaData = this.getMetaData();

    final StringBufferSourceWriter writer = new StringBufferSourceWriter();
    while (true) {
        final boolean noComments = Tester.isNullOrEmpty(comments);
        final boolean noAnnotations = metaData.isEmpty();

        if (noComments && noAnnotations) {
            break;
        }

        // only has annotations...
        if (noComments && false == noAnnotations) {
            metaData.write(writer);
            break;
        }
        // only has comments...
        if (noComments && false == noAnnotations) {
            writer.println(comments);
            break;
        }

        // must have both annotations and comments...
        writer.println(comments);
        writer.println();
        metaData.write(writer);
        break;
    }

    composerFactory.setJavaDocCommentForClass(writer.getBuffer().toString());
}