Package io.protostuff.parser
Class Proto
- java.lang.Object
-
- io.protostuff.parser.AnnotationContainer
-
- io.protostuff.parser.Proto
-
- All Implemented Interfaces:
HasAnnotations
,HasOptions
,HasProto
public class Proto extends AnnotationContainer implements HasOptions
Contains the metadata of parsed protos. Basically repesents the .proto file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Proto.Loader
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.LinkedHashMap<java.lang.String,EnumGroup>
enumGroups
(package private) java.util.ArrayList<Extension>
extensions
(package private) java.util.LinkedHashMap<java.lang.String,java.lang.Object>
extraOptions
(package private) java.io.File
file
(package private) java.util.LinkedHashMap<java.lang.String,EnumGroup>
fullyQualifiedEnumGroups
(package private) java.util.LinkedHashMap<java.lang.String,Message>
fullyQualifiedMessages
(package private) java.util.LinkedHashMap<java.lang.String,Proto>
importedProtos
(package private) Proto
importer
(package private) Mutable<java.lang.String>
javaPackageName
(package private) Proto.Loader
loader
(package private) java.util.LinkedHashMap<java.lang.String,Message>
messages
(package private) Mutable<java.lang.String>
packageName
(package private) java.util.ArrayList<ConfiguredReference>
references
(package private) int
refOffset
(package private) java.util.LinkedHashMap<java.lang.String,Service>
services
private java.lang.String
sourcePath
(package private) java.util.LinkedHashMap<java.lang.String,java.lang.Object>
standardOptions
(package private) java.net.URL
url
-
Fields inherited from class io.protostuff.parser.AnnotationContainer
annotations, docs
-
-
Constructor Summary
Constructors Constructor Description Proto()
Proto(Proto.Loader loader)
Proto(java.io.File file)
Proto(java.io.File file, Proto.Loader loader)
Proto(java.io.File file, Proto.Loader loader, Proto importer)
Proto(java.net.URL url, Proto.Loader loader, Proto importer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Annotation annotation)
Adds the annoation.(package private) void
addAnnotationsTo(EnumGroup target)
(package private) void
addAnnotationsTo(EnumGroup.Value target)
(package private) void
addAnnotationsTo(Extension target)
(package private) void
addAnnotationsTo(Field<?> target, java.lang.String enclosingNamespace)
(package private) void
addAnnotationsTo(Message target)
(package private) void
addAnnotationsTo(Service target)
(package private) void
addAnnotationsTo(Service.RpcMethod target)
(package private) void
addEnumGroup(EnumGroup enumGroup)
void
addExtension(Extension extension)
(package private) void
addImportedProto(Proto proto)
(package private) void
addMessage(Message message)
(package private) void
addService(Service service)
(package private) EnumGroup
findEnumGroupReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
(package private) HasName
findFullyQualifiedObject(java.lang.String fullyQualifiedName)
Returns a Message or EnumGroup given its fully qualified name(package private) Message
findMessageReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
(package private) HasName
findReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
Given the name of a Message/EnumGroup reference and the namespace enclosing that reference (can be a full message name or package name), returns the referenced object if it exists.EnumGroup
getEnumGroup(java.lang.String name)
java.util.Map<java.lang.String,EnumGroup>
getEnumGroupMap()
java.util.Collection<EnumGroup>
getEnumGroups()
ErrorMap
getError()
java.util.Collection<Extension>
getExtensions()
<V> V
getExtraOption(java.lang.String key)
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
getExtraOptions()
java.io.File
getFile()
Proto
getImportedProto(java.io.File file)
Proto
getImportedProto(java.lang.String url)
Proto
getImportedProto(java.net.URL url)
java.util.Collection<Proto>
getImportedProtos()
java.lang.String
getJavaPackageName()
Message
getMessage(java.lang.String name)
java.util.Map<java.lang.String,Message>
getMessageMap()
java.util.Collection<Message>
getMessages()
Mutable<java.lang.String>
getMutableJavaPackageName()
Mutable<java.lang.String>
getMutablePackageName()
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
getO()
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
getOptions()
java.lang.String
getOriginalJavaPackageName()
Returns the java package name that was configured in the proto.java.lang.String
getOriginalPackageName()
Returns the package name that was configured in the proto.java.lang.String
getPackageName()
Proto
getProto()
Service
getService(java.lang.String name)
java.util.Map<java.lang.String,Service>
getServiceMap()
java.util.Collection<Service>
getServices()
java.lang.String
getSourcePath()
java.lang.Object
getStandardOption(java.lang.String name)
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
getStandardOptions()
(package private) void
importProto(java.lang.String path)
(package private) void
postParse()
void
putExtraOption(java.lang.String key, java.lang.Object value)
void
putStandardOption(java.lang.String key, java.lang.Object value)
(package private) void
setPackageName(java.lang.String packageName)
java.lang.String
toString()
-
Methods inherited from class io.protostuff.parser.AnnotationContainer
addAnnotations, addDoc, err, getA, getAnnotation, getAnnotationMap, getAnnotations, getDocs, hasAnnotation, isEmptyA
-
-
-
-
Field Detail
-
file
final java.io.File file
-
url
final java.net.URL url
-
loader
final Proto.Loader loader
-
importer
final Proto importer
-
packageName
Mutable<java.lang.String> packageName
-
javaPackageName
Mutable<java.lang.String> javaPackageName
-
importedProtos
final java.util.LinkedHashMap<java.lang.String,Proto> importedProtos
-
standardOptions
final java.util.LinkedHashMap<java.lang.String,java.lang.Object> standardOptions
-
extraOptions
final java.util.LinkedHashMap<java.lang.String,java.lang.Object> extraOptions
-
messages
final java.util.LinkedHashMap<java.lang.String,Message> messages
-
enumGroups
final java.util.LinkedHashMap<java.lang.String,EnumGroup> enumGroups
-
services
final java.util.LinkedHashMap<java.lang.String,Service> services
-
extensions
final java.util.ArrayList<Extension> extensions
-
fullyQualifiedMessages
final java.util.LinkedHashMap<java.lang.String,Message> fullyQualifiedMessages
-
fullyQualifiedEnumGroups
final java.util.LinkedHashMap<java.lang.String,EnumGroup> fullyQualifiedEnumGroups
-
references
final java.util.ArrayList<ConfiguredReference> references
-
refOffset
int refOffset
-
sourcePath
private java.lang.String sourcePath
-
-
Constructor Detail
-
Proto
public Proto()
-
Proto
public Proto(java.io.File file)
-
Proto
public Proto(Proto.Loader loader)
-
Proto
public Proto(java.io.File file, Proto.Loader loader)
-
Proto
public Proto(java.io.File file, Proto.Loader loader, Proto importer)
-
Proto
public Proto(java.net.URL url, Proto.Loader loader, Proto importer)
-
-
Method Detail
-
getError
public ErrorMap getError()
-
getFile
public java.io.File getFile()
-
getSourcePath
public java.lang.String getSourcePath()
-
getMutablePackageName
public Mutable<java.lang.String> getMutablePackageName()
-
getPackageName
public java.lang.String getPackageName()
-
getOriginalPackageName
public java.lang.String getOriginalPackageName()
Returns the package name that was configured in the proto. Note thatgetPackageName()
will have the same value as this, if the compiler options did not have entries that override it.
-
getMutableJavaPackageName
public Mutable<java.lang.String> getMutableJavaPackageName()
-
getJavaPackageName
public java.lang.String getJavaPackageName()
-
getOriginalJavaPackageName
public java.lang.String getOriginalJavaPackageName()
Returns the java package name that was configured in the proto. Note thatgetJavaPackageName()
will have the same value as this, if the compiler options did not have entries that override it.
-
setPackageName
void setPackageName(java.lang.String packageName)
-
getStandardOptions
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getStandardOptions()
-
getStandardOption
public java.lang.Object getStandardOption(java.lang.String name)
-
getExtraOptions
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getExtraOptions()
-
getO
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getO()
-
getOptions
public java.util.LinkedHashMap<java.lang.String,java.lang.Object> getOptions()
- Specified by:
getOptions
in interfaceHasOptions
-
putStandardOption
public void putStandardOption(java.lang.String key, java.lang.Object value)
- Specified by:
putStandardOption
in interfaceHasOptions
-
putExtraOption
public void putExtraOption(java.lang.String key, java.lang.Object value)
- Specified by:
putExtraOption
in interfaceHasOptions
-
getExtraOption
public <V> V getExtraOption(java.lang.String key)
-
getMessageMap
public java.util.Map<java.lang.String,Message> getMessageMap()
-
getMessages
public java.util.Collection<Message> getMessages()
-
getMessage
public Message getMessage(java.lang.String name)
-
addMessage
void addMessage(Message message)
-
getEnumGroupMap
public java.util.Map<java.lang.String,EnumGroup> getEnumGroupMap()
-
getEnumGroups
public java.util.Collection<EnumGroup> getEnumGroups()
-
getEnumGroup
public EnumGroup getEnumGroup(java.lang.String name)
-
addEnumGroup
void addEnumGroup(EnumGroup enumGroup)
-
getServiceMap
public java.util.Map<java.lang.String,Service> getServiceMap()
-
getServices
public java.util.Collection<Service> getServices()
-
getService
public Service getService(java.lang.String name)
-
addService
void addService(Service service)
-
addExtension
public void addExtension(Extension extension)
-
getExtensions
public java.util.Collection<Extension> getExtensions()
-
getImportedProtos
public java.util.Collection<Proto> getImportedProtos()
-
getImportedProto
public Proto getImportedProto(java.io.File file)
-
getImportedProto
public Proto getImportedProto(java.net.URL url)
-
getImportedProto
public Proto getImportedProto(java.lang.String url)
-
importProto
void importProto(java.lang.String path)
-
addImportedProto
void addImportedProto(Proto proto)
-
postParse
void postParse()
-
add
public void add(Annotation annotation)
Description copied from interface:HasAnnotations
Adds the annoation.- Specified by:
add
in interfaceHasAnnotations
- Overrides:
add
in classAnnotationContainer
-
addAnnotationsTo
void addAnnotationsTo(Message target)
-
addAnnotationsTo
void addAnnotationsTo(EnumGroup target)
-
addAnnotationsTo
void addAnnotationsTo(EnumGroup.Value target)
-
addAnnotationsTo
void addAnnotationsTo(Field<?> target, java.lang.String enclosingNamespace)
-
addAnnotationsTo
void addAnnotationsTo(Service target)
-
addAnnotationsTo
void addAnnotationsTo(Service.RpcMethod target)
-
addAnnotationsTo
void addAnnotationsTo(Extension target)
-
findReference
HasName findReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
Given the name of a Message/EnumGroup reference and the namespace enclosing that reference (can be a full message name or package name), returns the referenced object if it exists.- Parameters:
fullRefName
- The full name of the object as specified by the reference, including a package name if it was specifiedfullEnclosingNamespace
- The full enclosing namespace of the reference- Returns:
- A Message or EnumGroup instance, or null
-
findMessageReference
Message findMessageReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
-
findEnumGroupReference
EnumGroup findEnumGroupReference(java.lang.String fullRefName, java.lang.String enclosingNamespace)
-
findFullyQualifiedObject
HasName findFullyQualifiedObject(java.lang.String fullyQualifiedName)
Returns a Message or EnumGroup given its fully qualified name- Parameters:
fullyQualifiedName
- The fully qualified name, without an initial dot ('.')- Returns:
- The Message or EnumGroup instance if it is defined in this Proto or one of its imports.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-