public class CompilationUnitWriter extends Object implements SourceBuilder, Closeable
| Constructor and Description |
|---|
CompilationUnitWriter(Filer filer,
Elements elements,
SourceLevel sourceLevel,
QualifiedName classToWrite,
Collection<QualifiedName> nestedClasses,
Element originatingElement)
Returns a
CompilationUnitWriter for classToWrite. |
| Modifier and Type | Method and Description |
|---|---|
CompilationUnitWriter |
add(String fmt,
Object... args)
Appends formatted text to the source.
|
CompilationUnitWriter |
addLine(String fmt,
Object... args)
Appends a formatted line of code to the source.
|
void |
close() |
SourceLevel |
getSourceLevel() |
public CompilationUnitWriter(Filer filer, Elements elements, SourceLevel sourceLevel, QualifiedName classToWrite, Collection<QualifiedName> nestedClasses, Element originatingElement) throws FilerException
CompilationUnitWriter for classToWrite. The file preamble (package
and imports) will be generated automatically.FilerException - if a Filer guarantee is violated (see the FilerException
JavaDoc for more information); propagated because this is often seen in GUIDE projects,
so should be downgraded to a warning, whereas runtime exceptions should be flagged as an
internal error to the userpublic CompilationUnitWriter add(String fmt, Object... args)
SourceBuilderFormatting is done by String.format(java.lang.String, java.lang.Object...), except that:
Package and PackageElement instances use their fully-qualified names
(no "package " prefix).
Class, TypeElement, DeclaredType and QualifiedName
instances use their qualified names where necessary, or shorter versions if a suitable
import line can be added.
Excerpt instances have Excerpt.addTo(SourceBuilder) called.
add in interface SourceBuilderpublic CompilationUnitWriter addLine(String fmt, Object... args)
SourceBuilderFormatting is done by String.format(java.lang.String, java.lang.Object...), except that:
Package and PackageElement instances use their fully-qualified names
(no "package " prefix).
Class, TypeElement, DeclaredType and QualifiedName
instances use their qualified names where necessary, or shorter versions if a suitable
import line can be added.
Excerpt instances have Excerpt.addTo(SourceBuilder) called.
addLine in interface SourceBuilderpublic SourceLevel getSourceLevel()
getSourceLevel in interface SourceBuilderpublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2015 Google, Inc.. All rights reserved.