|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.npsnet.xrti.utilities.ProxyCompiler
The XRTI proxy compiler. May be invoked as a command line application or
by using the static compileProxies method (from within an Ant
task, for instance).
| Nested Class Summary | |
private class |
ProxyCompiler.ArrayTypeInformation
An internal class for information concerning array types. |
| Field Summary | |
private static java.lang.String |
ALTERNATIVE
The alternative element. |
private static java.lang.String |
ARRAY_DATA
The array data type element. |
private java.util.HashMap |
arrayTypeInformationMap
Maps array type names to ArrayTypeInformation objects. |
private static java.lang.String |
ATTRIBUTE
The attribute element. |
private static java.lang.String |
CARDINALITY
The cardinality attribute. |
private static java.lang.String |
DATA_TYPE
The data type attribute. |
private static java.lang.String |
DISCRIMINANT
The discriminant attribute. |
private static java.lang.String |
ENCODING
The encoding attribute. |
private static java.lang.String |
ENUMERATED_DATA
The enumerated data type element. |
private static java.lang.String |
ENUMERATOR
The enumerator element. |
private java.io.File |
federationDescriptionDocument
The federation description document. |
private static java.lang.String |
FIELD
The field element. |
private static java.lang.String |
FIXED_RECORD_DATA
The fixed record data type element. |
private static java.lang.String |
HELP
The help command line argument. |
private static java.lang.String |
HLA_FIXED_ARRAY
The HLA fixed array encoding. |
private static java.lang.String |
HLA_FIXED_RECORD
The HLA fixed record encoding. |
private static java.lang.String |
HLA_VARIABLE_ARRAY
The HLA variable array encoding. |
private static java.lang.String |
HLA_VARIANT_RECORD
The HLA variant record encoding. |
private static java.lang.String |
INTERACTION_CLASS
The interaction class element. |
private static java.lang.String |
INTERACTION_LISTENER_NAME
The interaction listener name command line argument. |
private java.util.HashMap |
interactionClassElementMap
Maps interaction classes names to their defining elements. |
private java.lang.String |
interactionListenerName
The interaction listener name. |
private static java.lang.String |
INTERACTIONS
The interactions element. |
private static java.lang.String |
NAME
The name attribute. |
private static java.lang.String |
NEITHER
The neither type of sharing. |
private static java.lang.String |
OBJECT_CLASS
The object class element. |
private java.util.HashMap |
objectClassElementMap
Maps object class names to their defining elements. |
private static java.lang.String |
OBJECTS
The objects element. |
private java.util.HashSet |
opaqueTypes
The set of opaque types: types that must be stored as byte arrays because their encodings are non-standard. |
private static java.lang.String |
PACKAGE_PREFIX
The package prefix command line argument. |
private java.lang.String |
packagePrefix
The package prefix. |
private static java.lang.String |
PARAMETER
The parameter element. |
private static java.lang.String |
PARENTS
The parents attribute. |
private static java.lang.String |
PROXY_AMBASSADOR_NAME
The proxy ambassador name command line argument. |
private java.lang.String |
proxyAmbassadorName
The proxy ambassador name. |
private static java.lang.String |
PUBLISH
The publish type of sharing. |
private static java.lang.String |
PUBLISH_SUBSCRIBE
The publish-and-subscribe type of sharing. |
private static java.lang.String |
REPRESENTATION
The representation attribute. |
private static java.lang.String |
SEMANTICS
The semantics attribute. |
private static java.lang.String |
SHARING
The sharing attribute. |
private static java.lang.String |
SIMPLE_DATA
The simple data type element. |
private java.util.HashMap |
simpleTypeRepresentationMap
Maps simple type names to their representations. |
private static java.lang.String |
SUBSCRIBE
The subscribe type of sharing. |
private static java.lang.String |
TARGET_DIRECTORY
The target directory command line argument. |
private java.io.File |
targetDirectory
The target directory. |
private static java.lang.String |
VALUES
The values attribute. |
private static java.lang.String |
VARIANT_RECORD_DATA
The variant record data type element. |
| Constructor Summary | |
ProxyCompiler()
|
|
| Method Summary | |
private java.lang.String |
capitalize(java.lang.String string)
Capitalizes the first letter of the specified string. |
private java.util.Vector |
collateAttributes(org.w3c.dom.Element objectClassElement,
java.util.HashMap attributeInterfaceSetMap)
Collates and returns the list of attributes for the object class described by the specified element, combining attributes inherited from any parents other than the immediate parent and those specific to the class. |
private java.util.Vector |
collateAttributes2(org.w3c.dom.Element objectClassElement,
java.util.HashMap attributeInterfaceSetMap)
Collates and returns the list of attributes for the object class described by the specified element, combining attributes inherited from the immediate parent, those from any other parents, and those specific to the class. |
private java.util.Vector |
collateParameters(org.w3c.dom.Element interactionClassElement)
Collates and returns the list of parameters for the interaction class described by the specified element, combining parameters inherited from the immediate parent, those from any other parents, and those specific to the class. |
void |
compileProxies()
Generates Java source code for a set of proxy classes corresponding to the object and interaction classes described in the federation description document. |
private java.lang.String |
convertToIdentifier(java.lang.String anyName)
Converts the specified free-form name to a reasonable Java identifier by removing whitespace and illegal characters and so on. |
private java.lang.String |
convertToJavaClassName(java.lang.String anyName)
Converts the specified free-form name to a reasonable Java class name by removing whitespace and illegal characters, modifying capitalization, and so on. |
private java.lang.String |
formatCommentBody(int indentLevel,
java.lang.String commentBody)
Formats the body of a comment, adding asterisks at the beginning of each line. |
private void |
generateDataTypes(org.w3c.dom.Document fddDocument)
Generates data type classes. |
private void |
generateEnumeratedDataType(org.w3c.dom.Element typeElement)
Generates an enumerated data type class. |
private void |
generateFixedRecordDataType(org.w3c.dom.Element typeElement)
Generates a fixed record data type class. |
private java.lang.String |
generateIndentString(int indentLevel)
Generates an indentation string for the specified level of indentation. |
private void |
generateInteractionListener(org.w3c.dom.Document fddDocument)
Generates the interaction listener source file. |
private void |
generateObjectInstanceInterface(org.w3c.dom.Element classElement,
java.lang.String superInterfaceName)
Generates an object instance interface source file. |
private void |
generateObjectInstanceInterfaces(org.w3c.dom.Document fddDocument)
Generates the object instance interface source files. |
private void |
generateObjectInstanceListener(org.w3c.dom.Element classElement)
Generates an object instance listener source file. |
private void |
generateObjectInstanceListeners(org.w3c.dom.Document fddDocument)
Generates the object instance listener source files. |
private void |
generateObjectInstanceProxies(org.w3c.dom.Document fddDocument)
Generates the object instance proxy source files. |
private void |
generateObjectInstanceProxy(org.w3c.dom.Element classElement,
java.lang.String superClassName)
Generates an object instance proxy source file. |
private void |
generateProxyAmbassador(org.w3c.dom.Document fddDocument)
Generates the proxy ambassador source file. |
private void |
generateVariantRecordDataType(org.w3c.dom.Element typeElement)
Generates a variant record data type class. |
java.io.File |
getFederationDescriptionDocument()
Returns the location of the federation description document. |
java.lang.String |
getInteractionListenerName()
Returns the (unprefixed) name of the interaction listener interface. |
private java.lang.String |
getPackageName(java.lang.String className)
Returns the name of the package specified by the given fully qualified class name. |
java.lang.String |
getPackagePrefix()
Returns the package prefix. |
java.lang.String |
getProxyAmbassadorName()
Returns the (unprefixed) name of the proxy ambassador class. |
java.io.File |
getTargetDirectory()
Returns the target directory in which to place generated source files. |
private java.lang.String |
javaTypeForBasicRepresentation(java.lang.String basicRepresentationName)
Returns the Java type name corresponding to the specified basic representation name. |
private java.lang.String |
javaTypeForDataType(java.lang.String dataTypeName)
Returns the Java type name corresponding to the specified data type name. |
static void |
main(java.lang.String[] args)
The application entry point. |
private void |
printClassComment(java.io.PrintStream ps,
java.lang.String body)
Prints a Javadoc-style class comment. |
private void |
printDeserializationBlock(java.io.PrintStream ps,
int indentLevel,
char iteratorVariable,
java.lang.String dataTypeName,
java.lang.String variableName,
java.lang.String streamName)
Prints a code block that will deserialize the specified variable from the given stream. |
private boolean |
printDiscoverObjectInstanceBlock(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement,
boolean first)
Prints the discover object instance block for the specified object class element and its sub-elements. |
private void |
printInitToDefaultBlock(java.io.PrintStream ps,
java.lang.String dataTypeName,
java.lang.String variableName)
Prints a code block that will initialize the specified variable to a default state. |
private void |
printInteractionHandleDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
Prints the set of interaction handle declarations for the specified interaction class element and its sub-elements. |
private void |
printInteractionHandleInitializations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
Prints the set of interaction handle initializations for the specified interaction class element and its sub-elements. |
private void |
printObjectClassHandleDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
Prints the set of object class handle declarations for the specified object class element and its sub-elements. |
private void |
printObjectClassHandleInitializations(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
Prints the set of object class handle initializations for the specified object class element and its sub-elements. |
private void |
printObjectClassPublicationSubscriptions(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
Prints the set of object class publications and subscriptions for the specified object class element and its sub-elements. |
private void |
printObjectInstanceProxyConstructors(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
Prints the set of object instance proxy constructors for the specified object class element and its sub-elements. |
private boolean |
printReceiveInteractionBlock(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement,
boolean first)
Prints the receive interaction block for the specified interaction class element and its sub-elements. |
private void |
printReceiveInteractionDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
Prints the set of receive-interaction declarations for the specified interaction class element and its sub-elements. |
private void |
printSendInteractionMethods(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
Prints the set of send-interaction methods for the specified interaction class element and its sub-elements. |
private void |
printSerializationBlock(java.io.PrintStream ps,
int indentLevel,
char iteratorVariable,
java.lang.String dataTypeName,
java.lang.String variableName,
java.lang.String streamName)
Prints a code block that will serialize the specified variable to the given stream. |
private void |
printVariableComment(java.io.PrintStream ps,
java.lang.String body)
Prints a Javadoc-style variable comment. |
void |
setFederationDescriptionDocument(java.io.File pFederationDescriptionDocument)
Sets the location of the federation description document. |
void |
setInteractionListenerName(java.lang.String pInteractionListenerName)
Sets the (unprefixed) name of the interaction listener interface. |
void |
setPackagePrefix(java.lang.String pPackagePrefix)
Sets the package prefix. |
void |
setProxyAmbassadorName(java.lang.String pProxyAmbassadorName)
Sets the (unprefixed) name of the proxy ambassador class. |
void |
setTargetDirectory(java.io.File pTargetDirectory)
Sets the target directory in which to place generated source files. |
private java.lang.String |
spacer(java.lang.String string)
Generates a string of the same length as the parameter, consisting only of space characters. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final java.lang.String TARGET_DIRECTORY
private static final java.lang.String PACKAGE_PREFIX
private static final java.lang.String PROXY_AMBASSADOR_NAME
private static final java.lang.String INTERACTION_LISTENER_NAME
private static final java.lang.String HELP
private static final java.lang.String SIMPLE_DATA
private static final java.lang.String ARRAY_DATA
private static final java.lang.String ENUMERATED_DATA
private static final java.lang.String ENUMERATOR
private static final java.lang.String FIXED_RECORD_DATA
private static final java.lang.String VARIANT_RECORD_DATA
private static final java.lang.String FIELD
private static final java.lang.String ALTERNATIVE
private static final java.lang.String OBJECTS
private static final java.lang.String OBJECT_CLASS
private static final java.lang.String ATTRIBUTE
private static final java.lang.String INTERACTIONS
private static final java.lang.String INTERACTION_CLASS
private static final java.lang.String PARAMETER
private static final java.lang.String NAME
private static final java.lang.String SEMANTICS
private static final java.lang.String REPRESENTATION
private static final java.lang.String VALUES
private static final java.lang.String DATA_TYPE
private static final java.lang.String CARDINALITY
private static final java.lang.String ENCODING
private static final java.lang.String DISCRIMINANT
private static final java.lang.String PARENTS
private static final java.lang.String SHARING
private static final java.lang.String HLA_FIXED_ARRAY
private static final java.lang.String HLA_VARIABLE_ARRAY
private static final java.lang.String HLA_FIXED_RECORD
private static final java.lang.String HLA_VARIANT_RECORD
private static final java.lang.String PUBLISH
private static final java.lang.String SUBSCRIBE
private static final java.lang.String PUBLISH_SUBSCRIBE
private static final java.lang.String NEITHER
private java.io.File federationDescriptionDocument
private java.io.File targetDirectory
private java.lang.String packagePrefix
private java.lang.String proxyAmbassadorName
private java.lang.String interactionListenerName
private java.util.HashMap simpleTypeRepresentationMap
private java.util.HashSet opaqueTypes
private java.util.HashMap arrayTypeInformationMap
ArrayTypeInformation objects.
private java.util.HashMap interactionClassElementMap
private java.util.HashMap objectClassElementMap
| Constructor Detail |
public ProxyCompiler()
| Method Detail |
public static void main(java.lang.String[] args)
args - the command line argumentspublic void setFederationDescriptionDocument(java.io.File pFederationDescriptionDocument)
pFederationDescriptionDocument - the location of the federation description
documentpublic java.io.File getFederationDescriptionDocument()
public void setTargetDirectory(java.io.File pTargetDirectory)
pTargetDirectory - the target directory in which to place generated source filespublic java.io.File getTargetDirectory()
public void setPackagePrefix(java.lang.String pPackagePrefix)
pPackagePrefix - the package prefixpublic java.lang.String getPackagePrefix()
public void setProxyAmbassadorName(java.lang.String pProxyAmbassadorName)
pProxyAmbassadorName - the (unprefixed) name of the proxy ambassador classpublic java.lang.String getProxyAmbassadorName()
public void setInteractionListenerName(java.lang.String pInteractionListenerName)
pInteractionListenerName - the (unprefixed) name of the interaction listener
interfacepublic java.lang.String getInteractionListenerName()
public void compileProxies()
throws CouldNotOpenFDD,
ErrorReadingFDD,
TypeConflictException
CouldNotOpenFDD - if the federation description document could not be opened
ErrorReadingFDD - if the federation description document is invalid
TypeConflictException - if a type conflict is encounteredprivate java.lang.String capitalize(java.lang.String string)
string - the string to capitalize
private java.lang.String spacer(java.lang.String string)
string - the string whose length is to be copied
private java.lang.String convertToJavaClassName(java.lang.String anyName)
anyName - the free-form name to convert
private java.lang.String convertToIdentifier(java.lang.String anyName)
anyName - the free-form name to convert
private java.lang.String getPackageName(java.lang.String className)
className - the fully qualified class name
null for the base packageprivate java.lang.String generateIndentString(int indentLevel)
indentLevel - the level of indentation desired
private java.lang.String formatCommentBody(int indentLevel,
java.lang.String commentBody)
indentLevel - the level of indentation requiredcommentBody - the comment body to format
private void printClassComment(java.io.PrintStream ps,
java.lang.String body)
ps - the print stream to write the comment tobody - the body of the comment
private void printVariableComment(java.io.PrintStream ps,
java.lang.String body)
ps - the print stream to write the comment tobody - the body of the commentprivate java.lang.String javaTypeForBasicRepresentation(java.lang.String basicRepresentationName)
basicRepresentationName - the basic representation name
private java.lang.String javaTypeForDataType(java.lang.String dataTypeName)
dataTypeName - the data type name
private void printSerializationBlock(java.io.PrintStream ps,
int indentLevel,
char iteratorVariable,
java.lang.String dataTypeName,
java.lang.String variableName,
java.lang.String streamName)
ps - the print stream to write the code block toindentLevel - the level of indentation to useiteratorVariable - the name of the iterator variable to use ('i', 'j', 'k'...)dataTypeName - the name of the variable's data typevariableName - the name of the variablestreamName - the name of the stream
private void printDeserializationBlock(java.io.PrintStream ps,
int indentLevel,
char iteratorVariable,
java.lang.String dataTypeName,
java.lang.String variableName,
java.lang.String streamName)
ps - the print stream to write the code block toindentLevel - the level of indentation to useiteratorVariable - the name of the iterator variable to use ('i', 'j', 'k'...)dataTypeName - the name of the variable's data typevariableName - the name of the variablestreamName - the name of the stream
private void printInitToDefaultBlock(java.io.PrintStream ps,
java.lang.String dataTypeName,
java.lang.String variableName)
ps - the print stream to write the code block todataTypeName - the name of the variable's data typevariableName - the name of the variableprivate void generateDataTypes(org.w3c.dom.Document fddDocument)
fddDocument - the parsed federation description documentprivate void generateEnumeratedDataType(org.w3c.dom.Element typeElement)
typeElement - the element containing the type descriptionprivate void generateFixedRecordDataType(org.w3c.dom.Element typeElement)
typeElement - the element containing the type descriptionprivate void generateVariantRecordDataType(org.w3c.dom.Element typeElement)
typeElement - the element containing the type description
private void generateProxyAmbassador(org.w3c.dom.Document fddDocument)
throws TypeConflictException
fddDocument - the parsed federation description document
TypeConflictException - if a type conflict is encountered
private java.util.Vector collateParameters(org.w3c.dom.Element interactionClassElement)
throws TypeConflictException
interactionClassElement - the element describing the interaction class
TypeConflictException - if a type conflict is detected
private void printInteractionHandleDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
throws TypeConflictException
ps - the stream to print tointeractionClassElement - the interaction class element to process
TypeConflictException - if a type conflict is detected
private void printObjectClassHandleDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
ps - the stream to print toobjectClassElement - the object class element to process
private void printInteractionHandleInitializations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
throws TypeConflictException
ps - the stream to print tointeractionClassElement - the interaction class element to process
TypeConflictException - if a type conflict is detected
private void printObjectClassHandleInitializations(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
throws TypeConflictException
ps - the stream to print toobjectClassElement - the object class element to process
TypeConflictException - if a type conflict is detected
private void printObjectClassPublicationSubscriptions(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
throws TypeConflictException
ps - the stream to print toobjectClassElement - the object class element to process
TypeConflictException - if a type conflict is detected
private void printObjectInstanceProxyConstructors(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement)
ps - the stream to print toobjectClassElement - the object class element to process
private void printSendInteractionMethods(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
throws TypeConflictException
ps - the stream to print tointeractionClassElement - the interaction class element to process
TypeConflictException - if a type conflict is detected
private boolean printReceiveInteractionBlock(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement,
boolean first)
throws TypeConflictException
ps - the stream to print tointeractionClassElement - the interaction class element to processfirst - whether or not this is the first block being printed
first: true if the first
block has not been printed, false if it has been
TypeConflictException - if a type conflict is detected
private boolean printDiscoverObjectInstanceBlock(java.io.PrintStream ps,
org.w3c.dom.Element objectClassElement,
boolean first)
ps - the stream to print toobjectClassElement - the object class element to processfirst - whether or not this is the first block being printed
first: true if the first
block has not been printed, false if it has been
private void generateInteractionListener(org.w3c.dom.Document fddDocument)
throws TypeConflictException
fddDocument - the parsed federation description document
TypeConflictException - if a type conflict is detected
private void printReceiveInteractionDeclarations(java.io.PrintStream ps,
org.w3c.dom.Element interactionClassElement)
throws TypeConflictException
ps - the stream to print tointeractionClassElement - the interaction class element to process
TypeConflictException - if a type conflict is detected
private void generateObjectInstanceProxies(org.w3c.dom.Document fddDocument)
throws TypeConflictException
fddDocument - the parsed federation description document
TypeConflictException - if a type conflict is detectedprivate void generateObjectInstanceInterfaces(org.w3c.dom.Document fddDocument)
fddDocument - the parsed federation description documentprivate void generateObjectInstanceListeners(org.w3c.dom.Document fddDocument)
fddDocument - the parsed federation description document
private void generateObjectInstanceProxy(org.w3c.dom.Element classElement,
java.lang.String superClassName)
throws TypeConflictException
classElement - the object instance class element containing the relevant
informationsuperClassName - the name of the proxy superclass
TypeConflictException - if a type conflict is detected
private java.util.Vector collateAttributes(org.w3c.dom.Element objectClassElement,
java.util.HashMap attributeInterfaceSetMap)
throws TypeConflictException
objectClassElement - the element describing the object classattributeInterfaceSetMap - maps attribute names to sets of interfaces that
contain the attribute
TypeConflictException - if a type conflict is detected
private java.util.Vector collateAttributes2(org.w3c.dom.Element objectClassElement,
java.util.HashMap attributeInterfaceSetMap)
throws TypeConflictException
objectClassElement - the element describing the object classattributeInterfaceSetMap - maps attribute names to sets of interfaces
containing the attribute
TypeConflictException - if a type conflict is detected
private void generateObjectInstanceInterface(org.w3c.dom.Element classElement,
java.lang.String superInterfaceName)
classElement - the object instance class element containing the relevant
informationsuperInterfaceName - the name of the superinterfaceprivate void generateObjectInstanceListener(org.w3c.dom.Element classElement)
classElement - the object instance class element containing the relevant
information
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||