|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.generator.GeneratorCommon
public class GeneratorCommon
Common generator utilities, extend from here or call directly
| Field Summary | |
|---|---|
static int |
CONTEXT_CONFIGURATION
|
static int |
CONTEXT_CONTROL
|
static int |
CONTEXT_FRAMEWORK
|
static int |
CONTEXT_MESSAGING
|
static int |
CONTEXT_PERSISTENCE
|
static int |
CONTEXT_UI
|
static int |
DEFAULT_LINE_LENGTH
Default value at which to wrap comments and other output text. |
static java.lang.String[] |
MESSAGE_INTERFACES
|
| Constructor Summary | |
|---|---|
GeneratorCommon()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
capitalize(java.lang.String str)
Capitalizes the first letter of a string |
void |
copyfile(java.lang.String srcfile,
java.lang.String destdir)
Wrapper to access copyfile utility in the SandProject class. |
void |
deletefile(java.lang.String filespec)
Wrapper to access deletefile utility in the SandProject class. |
protected java.lang.String |
filterHTMLLine(java.lang.String line)
Called from writeHTMLContents for each line being written to provide an opportunity to change the text. |
org.sandev.sandbuild.SandDecl |
findStructDeclByShortname(java.lang.String shortname)
Find a struct decl by its short name. |
static java.util.ArrayList |
getDeclaredFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
Return an ArrayList containing all the fields for this class, including inherited fields if requested. |
static com.sun.javadoc.FieldDoc[] |
getFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
Given a ClassDoc, return all the fields for it, including any synthetic fields generated for SAND. |
static com.sun.javadoc.ClassDoc[] |
getInheritanceHierarchy(com.sun.javadoc.ClassDoc cd,
boolean includeAbstract)
Returns the inheritance hierarchy for the given ClassDoc. |
protected org.sandev.sandbuild.SandProject |
getLastAppProject()
Return the SandProject just before the triggering build project. |
protected java.lang.String |
getLastUtilDir()
Return the name of the util directory of the last project before the triggering deployment build. |
static java.lang.String |
getLongInstanceName(java.lang.String declname)
Given the fully qualified name of a struct or node declaration, return the fully qualified name of the corresponding instance message. |
static java.io.PrintStream |
getPrintStream(java.lang.String filename)
Given a filename, return a PrintStream for it. |
protected org.sandev.sandbuild.SandProject |
getSandProject(java.io.File projDir)
Return the current SandProject. |
static java.lang.String |
getShortInstanceName(java.lang.String declname)
Given either a short or fully qualified name of a struct or node declaration, return the short name of the associated instance message. |
protected java.lang.String |
getUtilPackage(org.sandev.sandbuild.SandProject proj)
Return the name of the util package for the given project. |
static java.util.ArrayList |
getVisibleFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
Return an ArrayList of the fields for the given class. |
static boolean |
hasSubStructs(org.sandev.sandbuild.SandDecl sd)
Return true if the given struct declaration has other struct declarations that extend it, false otherwise. |
static boolean |
isArray(com.sun.javadoc.FieldDoc fd)
Return true if the type of this field is an array, false otherwise. |
static boolean |
isBasic(java.lang.String typeName)
Returns true if the field type is a SAND basic type. |
static boolean |
isLongReferenceArray(com.sun.javadoc.FieldDoc fd)
Return true if this field is a reference array, false otherwise |
static boolean |
isMessageInterface(java.lang.String typeName)
Returns true if the field type is SAND message interface type such as SandStructMessage, SandVerbMessage etc. |
static boolean |
isParentAbstract(com.sun.javadoc.ClassDoc cd)
Returns true if the parent class is an abstract struct definition. |
static boolean |
isPrimitive(java.lang.String typeName)
Returns true if the field type is a primitive type. |
static boolean |
isRootStruct(com.sun.javadoc.ClassDoc cd)
Returns true if this struct definition does not extend any other struct, or extends an abstract struct. |
static boolean |
isVowel(char letter)
Returns true if the character is an English vowel. |
static void |
log(java.lang.String text)
Dump some text out to the build log. |
static java.lang.String |
nextToken(java.util.StringTokenizer toker)
Wraps StringTokenizer's nextToken method to support quoted strings. |
static java.lang.String |
pluralize(java.lang.String base)
Returns the plural form of a string. |
static java.lang.String |
rangeEscape(java.lang.String rangeSpec)
When working with a range specification, or other match expression, some of the characters can be problematic within the context of standard markup processing like XML, XHTML etc. |
protected org.sandev.sandbuild.SandDecl[] |
removePlatformDecls(org.sandev.sandbuild.SandDecl[] decls)
Remove any platform specific declarations and return the resulting array. |
void |
trackFileDelete(java.lang.String filespec)
Log the fact that we are deleting the specified file. |
void |
trackFileWrite(java.lang.String filespec)
Log the fact that we are writing the specified file |
static java.lang.String |
uncapitalize(java.lang.String str)
Converts the first character of a string to lowercase. |
static void |
writeDefaultCtor(java.io.PrintStream out,
java.lang.String classname)
Write a default ctor for the specified classname. |
static void |
writeDescription(java.io.PrintStream out,
java.lang.String prefix,
java.lang.String text)
Write the given text to the stream, beginning each line with the prefix. |
void |
writeHTMLContents(java.lang.String filespec,
java.io.PrintStream out)
Write everything between the body open line and the body close line to the given output stream. |
static void |
writeMessageImports(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
Write out the import statements for the messages we are dealing with so the generated code can use the short names. |
static void |
writeSectionName(java.io.PrintStream out,
java.lang.String sectionName)
Writes a commented source code section header. |
static void |
writeStandardCommentID(java.io.PrintStream out,
com.sun.javadoc.ClassDoc cd,
org.sandev.sandbuild.SandGenerator gen)
Write a standard comment line identifying this as autogenerated code, what the source declaration was, which generator wrote it, and when. |
protected void |
writeXHTMLFooter(java.io.PrintStream out)
Write the standard XHTML file postamble. |
protected void |
writeXHTMLFooter(java.io.PrintStream out,
boolean includeBodyTag)
Write the standard XHTML file postamble. |
protected void |
writeXHTMLHeader(java.io.PrintStream out,
java.lang.String title)
Write the standard XHTML file preamble. |
protected void |
writeXHTMLHeader(java.io.PrintStream out,
java.lang.String title,
boolean includeBodyTag,
java.lang.String bgcolor)
Write the standard XHTML file preamble. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_LINE_LENGTH
public static final java.lang.String[] MESSAGE_INTERFACES
public static final int CONTEXT_MESSAGING
public static final int CONTEXT_PERSISTENCE
public static final int CONTEXT_CONFIGURATION
public static final int CONTEXT_CONTROL
public static final int CONTEXT_UI
public static final int CONTEXT_FRAMEWORK
| Constructor Detail |
|---|
public GeneratorCommon()
| Method Detail |
|---|
public static void log(java.lang.String text)
public void trackFileWrite(java.lang.String filespec)
public void trackFileDelete(java.lang.String filespec)
public static java.io.PrintStream getPrintStream(java.lang.String filename)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
public static void writeStandardCommentID(java.io.PrintStream out,
com.sun.javadoc.ClassDoc cd,
org.sandev.sandbuild.SandGenerator gen)
public static java.lang.String nextToken(java.util.StringTokenizer toker)
public static java.lang.String capitalize(java.lang.String str)
public static java.lang.String uncapitalize(java.lang.String str)
public static java.lang.String pluralize(java.lang.String base)
I suppose it goes without saying that this method is not internationalized.
public static boolean isVowel(char letter)
public static java.lang.String rangeEscape(java.lang.String rangeSpec)
At the time of this writing, the URLEncoder, URI, and URL classes
don't really address this particularly well. They are also seem
a bit too heavy-handed for this simple conversion. We just do a
simple iterative replacement of the problematic characters.
public static void writeSectionName(java.io.PrintStream out,
java.lang.String sectionName)
public static void writeDefaultCtor(java.io.PrintStream out,
java.lang.String classname)
public static boolean isPrimitive(java.lang.String typeName)
public static boolean isBasic(java.lang.String typeName)
public static boolean isArray(com.sun.javadoc.FieldDoc fd)
public static boolean isMessageInterface(java.lang.String typeName)
public static void writeDescription(java.io.PrintStream out,
java.lang.String prefix,
java.lang.String text)
public static java.lang.String getShortInstanceName(java.lang.String declname)
public static java.lang.String getLongInstanceName(java.lang.String declname)
public static void writeMessageImports(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
public static boolean isParentAbstract(com.sun.javadoc.ClassDoc cd)
public static boolean isRootStruct(com.sun.javadoc.ClassDoc cd)
public static boolean isLongReferenceArray(com.sun.javadoc.FieldDoc fd)
public void copyfile(java.lang.String srcfile,
java.lang.String destdir)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
public void deletefile(java.lang.String filespec)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
public void writeHTMLContents(java.lang.String filespec,
java.io.PrintStream out)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
protected java.lang.String filterHTMLLine(java.lang.String line)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
protected void writeXHTMLHeader(java.io.PrintStream out,
java.lang.String title)
protected void writeXHTMLHeader(java.io.PrintStream out,
java.lang.String title,
boolean includeBodyTag,
java.lang.String bgcolor)
protected void writeXHTMLFooter(java.io.PrintStream out)
protected void writeXHTMLFooter(java.io.PrintStream out,
boolean includeBodyTag)
protected org.sandev.sandbuild.SandProject getSandProject(java.io.File projDir)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorExceptionprotected org.sandev.sandbuild.SandDecl[] removePlatformDecls(org.sandev.sandbuild.SandDecl[] decls)
protected org.sandev.sandbuild.SandProject getLastAppProject()
protected java.lang.String getUtilPackage(org.sandev.sandbuild.SandProject proj)
throws org.sandev.sandbuild.SandGeneratorException
org.sandev.sandbuild.SandGeneratorException
protected java.lang.String getLastUtilDir()
throws org.sandev.sandbuild.SandGeneratorException
The returned util directory may or may not already exist. This method does not create it.
org.sandev.sandbuild.SandGeneratorException
public static com.sun.javadoc.FieldDoc[] getFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
Each field has its own logic about when it should be added. For consistency, we are using equality tests for relevant contexts, so it is easier to read.
inherit - If true, then the inherited FieldDocs are included in the result
array. Otherwise only the fields for the specific class will be
returned. Synthetic fields are part of the message, not the struct,
and are therefore not inherited.context - One of the CONTEXT_* constants. See the SAND overview for details.
public static java.util.ArrayList getDeclaredFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
public static java.util.ArrayList getVisibleFields(com.sun.javadoc.ClassDoc cd,
boolean inherit,
int context)
public static com.sun.javadoc.ClassDoc[] getInheritanceHierarchy(com.sun.javadoc.ClassDoc cd,
boolean includeAbstract)
public org.sandev.sandbuild.SandDecl findStructDeclByShortname(java.lang.String shortname)
public static boolean hasSubStructs(org.sandev.sandbuild.SandDecl sd)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||