|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.generator.GeneratorCommon
org.sandev.generator.AggregateGeneratorBase
org.sandev.generator.ProtocolBufferGenerator
public class ProtocolBufferGenerator
Write a protocol buffer declaration file for our defined messages. Protocol Buffers are Google's data interchange format. For more information see their announcement.
Basically what this does is go through all the struct declarations and write the corresponding prototype declarations for the derived messages to appname.proto in the apps util directory. Also included in the file is the receivable messages in the given node declaration, if specified in the generator call. The generated .proto file will have all the messages and whatever the app can receive if functioning as a web service. To use the .proto file you will need to
By default all fields are declared as optional (or
repeated for arrays). By default IDs are assigned in
the order that the fields are declared starting from 1. The
default field type mappings are:
| SAND type | .proto type |
| int | int32 |
| long | int64 |
| double | double |
| Date | Date (defined base type) |
| String | string |
@sand.protobuf 3 sint32 requiredEnum declarations are not currently generated. We are currently using plain int values instead so that if you add a new enum value, both the sender and receiver can continue to communicate without having to regenerate the serialization. At the time of this writing there are also some limitations to Protocol Buffers declarations that are worth noting:
| Field Summary |
|---|
| Fields inherited from class org.sandev.generator.AggregateGeneratorBase |
|---|
extra |
| Fields inherited from class org.sandev.generator.GeneratorCommon |
|---|
CONTEXT_CONFIGURATION, CONTEXT_CONTROL, CONTEXT_FRAMEWORK, CONTEXT_MESSAGING, CONTEXT_PERSISTENCE, CONTEXT_UI, DEFAULT_LINE_LENGTH, MESSAGE_INTERFACES |
| Constructor Summary | |
|---|---|
ProtocolBufferGenerator()
|
|
| Method Summary | |
|---|---|
protected java.lang.String |
getFileSpec(java.io.File baseDir)
Return lastApp/src/TLD/domain/appname/util/PBMsgs.proto for the triggering build. |
protected java.lang.String |
getProtoType(java.lang.String typename)
Return the protobuf type for the given SAND type. |
protected boolean |
hasContainedInterfaces(com.sun.javadoc.FieldDoc[] fields,
org.sandev.sandbuild.SandDecl[] decls,
com.sun.javadoc.ClassDoc cd)
Return true if the given fields include interfaces. |
protected void |
writeBaseTypes(java.io.PrintStream out)
Write the message declarations for the basic types we require. |
protected void |
writeFile(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
Write the proto declarations source file. |
protected void |
writeMessageDecl(java.io.PrintStream out,
java.lang.String className,
com.sun.javadoc.ClassDoc cd,
com.sun.javadoc.FieldDoc[] fields)
Write a struct message declaration |
protected void |
writeMessageDecls(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
Write the declarations for each of the defined structs. |
protected void |
writeReceiverDecls(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
|
| Methods inherited from class org.sandev.generator.AggregateGeneratorBase |
|---|
addSandAttrValToDecls, cleanup, cleanupSecondaryFiles, generate, getExtra, setExtra, writeSecondaryFiles |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.sandev.sandbuild.SandGenerator |
|---|
cleanup, generate |
| Constructor Detail |
|---|
public ProtocolBufferGenerator()
| Method Detail |
|---|
protected java.lang.String getFileSpec(java.io.File baseDir)
throws org.sandev.sandbuild.SandGeneratorException
getFileSpec in class AggregateGeneratorBaseorg.sandev.sandbuild.SandGeneratorException
protected void writeFile(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
writeFile in class AggregateGeneratorBase
protected void writeMessageDecls(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
protected void writeBaseTypes(java.io.PrintStream out)
protected boolean hasContainedInterfaces(com.sun.javadoc.FieldDoc[] fields,
org.sandev.sandbuild.SandDecl[] decls,
com.sun.javadoc.ClassDoc cd)
protected void writeMessageDecl(java.io.PrintStream out,
java.lang.String className,
com.sun.javadoc.ClassDoc cd,
com.sun.javadoc.FieldDoc[] fields)
protected java.lang.String getProtoType(java.lang.String typename)
protected void writeReceiverDecls(java.io.PrintStream out,
org.sandev.sandbuild.SandDecl[] decls)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||