Class InterfaceCodeGenerator
java.lang.Object
org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator
Replacement for the old CreateInterface tool.
This utility class will read introspection data from a given DBus interface
and tries to generate proper Java interfaces.
- Since:
- v3.0.1 - 2018-12-20
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final DocumentBuilderFactoryprivate final Stringprivate final org.slf4j.Loggerprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionInterfaceCodeGenerator(String _introspectionData, String _objectPath, String _busName) -
Method Summary
Modifier and TypeMethodDescriptionanalyze(boolean _ignoreDtd) Analyze the DBus interface given in constructor by parsing the introspection data.private StringbuildStructClass(String _dbusTypeStr, String _structName, ClassBuilderInfo _packageName, List<ClassBuilderInfo> _structClasses) Creates a class for a DBus Struct-Object.convertToElementList(NodeList _nodeList) Converts a NodeList to List<Element>.private StringcreateTuple(List<ClassBuilderInfo.MemberOrArgument> _outputArgs, String _className, ClassBuilderInfo _parentClzBldr, List<ClassBuilderInfo> _additionalClasses, List<String> _dbusOutputArgTypes) Creates a Tuple extending class to encapsulate a multi-value return (which is not supported by Java natively).extractAll(Element _ife) Extract all methods/signals etc.private List<ClassBuilderInfo> extractMethods(Element _methodElement, ClassBuilderInfo _clzBldr) Extract <method> elements properties.private List<ClassBuilderInfo> extractProperties(Element _propertyElement, ClassBuilderInfo _clzBldr) Extract <property> elements properties.private List<ClassBuilderInfo> extractSignals(Element _signalElement, ClassBuilderInfo _clzBldr) Extract <signal> element properties.static voidprivate static voidprivate static voidversion()(package private) static voidwriteToFile(String _outputDir, Map<File, String> _filesToGenerate) Creates all files in the given map with the given content in the given directory.
-
Field Details
-
docFac
-
logger
private final org.slf4j.Logger logger -
nodeName
-
busName
-
introspectionData
-
-
Constructor Details
-
InterfaceCodeGenerator
-
-
Method Details
-
analyze
Analyze the DBus interface given in constructor by parsing the introspection data.- Parameters:
_ignoreDtd- true to disable dtd-validation, false otherwise- Returns:
- List of Filenames and contents for the files
- Throws:
Exception- on DBUS or IO errors
-
convertToElementList
Converts a NodeList to List<Element>. Will skip all NodeList entries not compatible with Element type.- Parameters:
_nodeList- NodeList to convert- Returns:
- List of Element, maybe empty
-
extractAll
Extract all methods/signals etc. from the given interface element.- Parameters:
_ife- interface element- Returns:
- Map of files and their contents
- Throws:
IOException- when reading xml failsDBusException- when DBus fails
-
extractSignals
private List<ClassBuilderInfo> extractSignals(Element _signalElement, ClassBuilderInfo _clzBldr) throws IOException, DBusException Extract <signal> element properties.- Parameters:
_signalElement- signal xml element_clzBldr-ClassBuilderInfoobject- Returns:
- List of
ClassBuilderInfowhich have been created (maybe empty, never null) - Throws:
IOException- on IO ErrorDBusException- on DBus Error
-
extractMethods
private List<ClassBuilderInfo> extractMethods(Element _methodElement, ClassBuilderInfo _clzBldr) throws IOException, DBusException Extract <method> elements properties.- Parameters:
_methodElement- method XML element_clzBldr-ClassBuilderInfoobject- Returns:
- List of
ClassBuilderInfowhich have been created (maybe empty, never null) - Throws:
IOException- on IO ErrorDBusException- on DBus Error
-
extractProperties
private List<ClassBuilderInfo> extractProperties(Element _propertyElement, ClassBuilderInfo _clzBldr) throws DBusException Extract <property> elements properties.- Parameters:
_propertyElement- method XML element_clzBldr-ClassBuilderInfoobject- Returns:
- List of
ClassBuilderInfowhich have been created (maybe empty, never null) - Throws:
DBusException- on DBus Error
-
createTuple
private String createTuple(List<ClassBuilderInfo.MemberOrArgument> _outputArgs, String _className, ClassBuilderInfo _parentClzBldr, List<ClassBuilderInfo> _additionalClasses, List<String> _dbusOutputArgTypes) Creates a Tuple extending class to encapsulate a multi-value return (which is not supported by Java natively).- Parameters:
_outputArgs- Map with return arguments (key) and their types (value)_className- name the tuple class should get_parentClzBldr- parent class where the tuple was required in_additionalClasses- list where the new created tuple class will be added to_dbusOutputArgTypes- Dbus argument names and data types- Returns:
- FQCN of the newly created tuple based class
-
buildStructClass
private String buildStructClass(String _dbusTypeStr, String _structName, ClassBuilderInfo _packageName, List<ClassBuilderInfo> _structClasses) throws DBusException Creates a class for a DBus Struct-Object.- Parameters:
_dbusTypeStr- Dbus Type definition string_structName- name of the struct to create_packageName- package name for the struct class_structClasses- list ofClassCastException, other struct classes which may be created during struct creation will be added here- Returns:
- FQCN of the created struct class
- Throws:
DBusException- on Error
-
writeToFile
Creates all files in the given map with the given content in the given directory.- Parameters:
_outputDir- directory to put output files to_filesToGenerate- map of files and contents which should be created
-
main
-
version
private static void version() -
printHelp
private static void printHelp()
-