Class StructTreeBuilder
java.lang.Object
org.freedesktop.dbus.utils.generator.StructTreeBuilder
Helper to create a DBus struct class.
As Structs are regular classes (POJOs) in Java,
this helper also takes care about recursion (Struct in Struct/Map/List).
- Since:
- v3.0.1 - 2018-12-21
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classClass to represent a tree structure. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildStructClasses(String _dbusSig, String _structName, ClassBuilderInfo _clzBldr, List<ClassBuilderInfo> _generatedClasses) Builds the struct(s) found in _dbusSig.private List<StructTreeBuilder.StructTree> buildTree(ParameterizedType _pType) Create tree fromParameterizedType.private List<StructTreeBuilder.StructTree> Builds a tree of types based on the given DBus type definition string.private ClassBuilderInfocreateNested(List<StructTreeBuilder.StructTree> _list, ClassBuilderInfo _root, List<ClassBuilderInfo> _classes) Create nested Struct class.(package private) static voidprintTree(List<StructTreeBuilder.StructTree> _buildTree, int _indent) Helper to print a StructTree to STDOUT (for debugging purposes).
-
Constructor Details
-
StructTreeBuilder
public StructTreeBuilder()
-
-
Method Details
-
buildStructClasses
public String buildStructClasses(String _dbusSig, String _structName, ClassBuilderInfo _clzBldr, List<ClassBuilderInfo> _generatedClasses) throws DBusException Builds the struct(s) found in _dbusSig. If the struct is wrapped in aCollection, it will be unwrapped.
The resulting String will return the parent class name. This can be the Structs classname or e.g. List/Set class if the struct was wrapped in aCollection.
Structs which are inside of another struct will get the appendix 'Struct' for each iteration. This may lead to classes with names like FooStructStructStruct (FooStruct->(InnerStruct->InnerInnerStruct)).- Parameters:
_dbusSig- dbus Type string_structName- name the struct should have_clzBldr- class builder with the class where the struct was first seen_generatedClasses- a list, this will contain additional struct classes created, if any. Should never be null!- Returns:
- Struct class name or Collection type name
- Throws:
DBusException- on DBus Error
-
createNested
private ClassBuilderInfo createNested(List<StructTreeBuilder.StructTree> _list, ClassBuilderInfo _root, List<ClassBuilderInfo> _classes) Create nested Struct class.- Parameters:
_list- List of struct tree elements_root- root class of this struct (maybe other struct)_classes- a list, this will contain additional struct classes created, if any. Should never be null!- Returns:
- last created struct or null
-
printTree
Helper to print a StructTree to STDOUT (for debugging purposes).- Parameters:
_buildTree- tree to print_indent- indention level (usually 0)
-
buildTree
Builds a tree of types based on the given DBus type definition string.- Parameters:
_dbusTypeStr- DBus type string- Returns:
- List with tree structure, maybe empty - never null
- Throws:
DBusException- on Error
-
buildTree
Create tree fromParameterizedType.- Parameters:
_pType-ParameterizedTypeobject- Returns:
- List of tree elements, maybe empty, never null
- Throws:
DBusException- on error
-