public class jrpcgen extends Object
jrpcgen
implements a Java-based rpcgen RPC protocol
compiler. jrpcgen is a Java-based tool that generates source code of Java
classes to implement an RPC protocol. The input to jrpcgen is a language
similiar to C (but more probably much more similiar to FORTRAN) known as
the RPC language (Remote Procedure Call Language).Modifier and Type | Class and Description |
---|---|
static class |
jrpcgen.GlobalIdentifierTable |
Modifier and Type | Field and Description |
---|---|
static String |
baseClassname
Name of class containing global constants.
|
static boolean |
clampProgAndVers
Clamp version and program number in client method stubs to the
version and program number specified in the x-file.
|
static String |
clientClass
Name of class containing the ONC/RPC client stubs.
|
static String |
currentFilename
Full name of the current source code file.
|
static Writer |
currentFileWriter
Current FileWriter object receiving generated source code.
|
static PrintWriter |
currentPrintWriter
Current PrintWriter object sitting on top of the
currentFileWriter object receiving generated source code. |
static boolean |
debug
Enable diagnostic messages when parsing the x-file.
|
static File |
destinationDir
Destination directory where to place the generated files.
|
static jrpcgen.GlobalIdentifierTable |
globalIdentifiers
Contains all global identifiers for type, structure and union specifiers
as well as for constants and enumeration members.
|
static boolean |
initStrings
Enable automatic initialization of String with empty Strings
instead of null reference.
|
static boolean |
makeBean
Enable generation of accessors in order to use XDR classes as beans.
|
static boolean |
makeSerializable
Enable tagging of XDR classes as being Serializable
|
static boolean |
noBackups
Disable automatic backup of old source code files, if
true . |
static boolean |
noClient
Do not generate source code for the client proxy stub if
true . |
static boolean |
noServer
Do not generate source code for the server proxy stub if
true . |
static boolean |
noXdr
Do not generate XDR datatype classes if
true . |
static String |
packageName
Specifies package name for generated source code, if not
null . |
static int |
PARAMS_MORE
A remote procedure expects more than one parameter and thus needs
an XDR wrapping class.
|
static int |
PARAMS_SINGLE
A remote procedure expects only a single parameter, which is a
complex type (class).
|
static int |
PARAMS_SINGLE_BASETYPE
A remote procedure expects only a single parameter, which is of
a base type, like integer, boolean, string, et cetera.
|
static int |
PARAMS_VOID
A remote procedure has no parameters and thus needs to use the
XDR void wrapper class as a dummy.
|
static boolean |
parseOnly
Parse x-file only but do not create source code files if set to
true . |
static Vector |
programInfos
Holds information about the remote program defined in the jrpcgen
x-file.
|
static String |
serverClass
Name of class containing the ONC/RPC server stubs.
|
static boolean |
serverTcpOnly
Create TCP-Server only
true . |
static boolean |
serverUdpOnly
Create TCP-Server only
true . |
static String |
startDate
String containing date/time when a jrpcgen run was started.
|
static boolean |
verbose
Verbosity flag.
|
static String |
VERSION
Current version of jrpcgen.
|
static boolean |
withCallInfo
Supply (additional) call information to server method stubs.
|
static File |
xFile
The x-file to parse (not: the X Files, the latter ones are something
completely different).
|
Constructor and Description |
---|
jrpcgen() |
Modifier and Type | Method and Description |
---|---|
static org.acplt.oncrpc.apps.jrpcgen.JrpcgenEnDecodingInfo |
baseEnDecodingSyllable(JrpcgenDeclaration decl)
Return the en-/decoding syllable XXX appropriate for a base data
type including arrays of base data types.
|
static String |
checkForEnumValue(String value)
Checks whether a given value references an identifier and then
returns the qualified identifier (interface where the value is
defined in) or simply the value in case of an integer literal.
|
static String |
checkForSpecials(String dataType)
Checks whether a given data type identifier refers to an enumeration
type and then returns Java's int data type instead.
|
static void |
closeJavaSourceFile()
Closes the source code file previously opened with
createJavaSourceFile . |
static String |
codingMethod(JrpcgenDeclaration decl,
boolean encode)
Return en- or decoding method appropriate for a struct or union member.
|
static String |
codingMethod(JrpcgenDeclaration decl,
boolean encode,
String oref)
Return en- or decoding method appropriate for a struct or union member.
|
static PrintWriter |
createJavaSourceFile(String classname)
Creates a new source code file for a Java class based on its class
name.
|
static PrintWriter |
createJavaSourceFile(String classname,
boolean emitImports)
Creates a new source code file for a Java class based on its class
name.
|
static JrpcgenSHA |
createSHA(String classname)
Create a new hash function object and initialize it using a class
and package name.
|
static void |
doParse()
The real parsing and code generation part.
|
static void |
dumpClasses()
Generate source code files for all structures, unions and enumerations
as well as constants.
|
static void |
dumpClient(org.acplt.oncrpc.apps.jrpcgen.JrpcgenProgramInfo programInfo)
Generate source code for the client stub proxy object.
|
static void |
dumpClientStubMethods(PrintWriter out,
org.acplt.oncrpc.apps.jrpcgen.JrpcgenVersionInfo versionInfo)
Generate source code for client-side stub methods for a particular
remote program version.
|
static void |
dumpConstantAndDependency(PrintWriter out,
JrpcgenConst c)
Dump the value of a constant and optionally first dump all constants
it depends on.
|
static void |
dumpConstants()
Generate source code file containing all constants defined in the
x-file as well as all implicitely defined constants, like program,
version and procedure numbers, etc.
|
static void |
dumpEnum(JrpcgenEnum e)
Generate a source code file containing all elements of an enumeration
defined in a x-file.
|
static void |
dumpFiles()
Create the source code files based on the parsed information from the
x-file.
|
static void |
dumpServer(org.acplt.oncrpc.apps.jrpcgen.JrpcgenProgramInfo programInfo) |
static void |
dumpServerStubMethodCall(PrintWriter out,
org.acplt.oncrpc.apps.jrpcgen.JrpcgenProcedureInfo proc) |
static void |
dumpServerStubMethods(PrintWriter out,
org.acplt.oncrpc.apps.jrpcgen.JrpcgenVersionInfo versionInfo)
Generate public abstract method signatures for all remote procedure
calls.
|
static void |
dumpStruct(JrpcgenStruct s)
Generate a source code file containing all elements of a struct
defined in a x-file.
|
static void |
dumpTypedef(JrpcgenDeclaration d)
Generate a source code file containing a wrapper class for a typedef
defined in a x-file.
|
static void |
dumpUnion(JrpcgenUnion u)
Generate a source code file containing all elements of a union
defined in a x-file.
|
static void |
main(String[] args)
The main part of jrpcgen where all things start.
|
static void |
printHelp()
Print the help message describing the available command line options.
|
static void |
reset() |
static String |
xdrBaseType(String type)
Given a name of a data type return the name of the equivalent Java
data type (if it exists), otherwise return
null . |
public static final String VERSION
public static final int PARAMS_VOID
public static final int PARAMS_SINGLE
public static final int PARAMS_SINGLE_BASETYPE
public static final int PARAMS_MORE
public static String startDate
public static jrpcgen.GlobalIdentifierTable globalIdentifiers
public static boolean noBackups
true
.public static Vector programInfos
public static boolean clampProgAndVers
public static boolean withCallInfo
public static boolean debug
public static boolean verbose
true
, then jrpcgen will report about
the steps it is taking when generating all the source code files.public static boolean parseOnly
true
.public static File xFile
public static File destinationDir
public static Writer currentFileWriter
public static PrintWriter currentPrintWriter
currentFileWriter
object receiving generated source code.public static String currentFilename
public static String packageName
null
. If null
, then no package statement
is emitted.public static String baseClassname
public static boolean noClient
true
.public static boolean noServer
true
.public static String serverClass
public static boolean noXdr
true
.public static boolean serverTcpOnly
true
.public static boolean serverUdpOnly
true
.public static String clientClass
public static boolean makeSerializable
public static boolean makeBean
public static boolean initStrings
public static void printHelp()
public static void reset()
public static PrintWriter createJavaSourceFile(String classname)
createJavaSourceFile(String, boolean)
with
the emitImport
parameter set to true
.classname
- Name of Java class to generate. Must not contain
a file extension -- especially ".java" is invalid. When the source
code file is created, ".java" is appended automatically.public static PrintWriter createJavaSourceFile(String classname, boolean emitImports)
classname
- Name of Java class to generate. Must not contain
a file extension -- especially ".java" is invalid. When the source
code file is created, ".java" is appended automatically.emitImports
- if true
, then import statements for
the remotetea ONC/RPC package and IOExceptions.public static JrpcgenSHA createSHA(String classname)
classname
- Name of class.public static void closeJavaSourceFile()
createJavaSourceFile
. This method writes a trailer
before closing the file.public static void dumpConstantAndDependency(PrintWriter out, JrpcgenConst c)
out
- The print writer where the output shall go in.c
- The constant definition to dump.public static void dumpConstants()
public static void dumpEnum(JrpcgenEnum e)
e
- Description
of XDR enumeration.public static String xdrBaseType(String type)
null
.
NOTE: "opaque" is considered like "byte" to be a base type...
FIXME: char/byte?type
- The name of an XDR base typenull
if the
given data type is not equivalent to one of Java's base data
types.public static org.acplt.oncrpc.apps.jrpcgen.JrpcgenEnDecodingInfo baseEnDecodingSyllable(JrpcgenDeclaration decl)
decl
- declaration of a member of RPC struct or union.null
, if the declaration does not specify a base data
type. Otherwise a three-element String array, with [0] containing
the type syllable for base type (including arrays), [1] containing
parameter options when encoding (like maximum sizes, etc), and [2]
containing options for decoding.public static String codingMethod(JrpcgenDeclaration decl, boolean encode)
decl
- The declaration of an XDR struct or union.encode
- Indicates whether to return the encoding or the decoding method.public static String codingMethod(JrpcgenDeclaration decl, boolean encode, String oref)
decl
- declaration for which the en-/decoding Java source code be
returned.encode
- true
if encoding method should be returned,
false
if decoding method is to be returned.oref
- name of object reference or null
if
"this" should be used instead.public static String checkForSpecials(String dataType)
dataType
- data type identifier to check.public static String checkForEnumValue(String value)
value
- Either an identifier to resolve or an integer literal.public static void dumpStruct(JrpcgenStruct s)
s
- Description
of XDR struct.public static void dumpUnion(JrpcgenUnion u)
u
- Description
of XDR union.public static void dumpTypedef(JrpcgenDeclaration d)
d
- Description
of XDR typedef.public static void dumpClasses()
public static void dumpClientStubMethods(PrintWriter out, org.acplt.oncrpc.apps.jrpcgen.JrpcgenVersionInfo versionInfo)
out
- Printer writer to send source code to.versionInfo
- Information about the remote program version for
which source code is to be generated.public static void dumpClient(org.acplt.oncrpc.apps.jrpcgen.JrpcgenProgramInfo programInfo)
programInfo
- The information on the defined RPC program.public static void dumpServerStubMethodCall(PrintWriter out, org.acplt.oncrpc.apps.jrpcgen.JrpcgenProcedureInfo proc)
out
- The print writer where the output shall go in.proc
- The information of the procedure to dump.public static void dumpServerStubMethods(PrintWriter out, org.acplt.oncrpc.apps.jrpcgen.JrpcgenVersionInfo versionInfo)
out
- The print writer where the output shall go in.versionInfo
- The cersion information on the RPC program.public static void dumpServer(org.acplt.oncrpc.apps.jrpcgen.JrpcgenProgramInfo programInfo)
programInfo
- The information on the RPC program.public static void dumpFiles()
public static void main(String[] args)
args
- A string array containing the command line arguments passed on invocation.public static void doParse() throws FileNotFoundException, Exception
FileNotFoundException
- if the specified x-file does not exist or cannot be opened for reading.Exception
- if any kind of error like a parser error occurs.Copyright © 2015. All rights reserved.