Top Description Inners Fields Constructors Methods
org.freedesktop.dbus.utils.generator

public Class StructTreeBuilder

extends Object
Class Inheritance
Imports
org.freedesktop.dbus.Marshalling, .Struct, org.freedesktop.dbus.annotations.Position, org.freedesktop.dbus.exceptions.DBusException, org.freedesktop.dbus.utils.Util, org.freedesktop.dbus.utils.generator.ClassBuilderInfo.ClassConstructor, .ClassBuilderInfo.ClassType, .ClassBuilderInfo.MemberOrArgument, java.lang.reflect.ParameterizedType, .Type, java.util.ArrayList, .Collection, .List, .Map

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).
Author
hypfvieh
Since
v3.0.1 - 2018-12-21

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
StructTreeBuilder.StructTree

Class to represent a tree structure.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
StructTreeBuilder(String _argumentPrefix)

pack-priv

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

Struct class name or Collection type name
buildStructClasses
(String
dbus Type string
_dbusSig
,
String
name the struct should have
_structName
,
ClassBuilderInfo
class builder with the class where the struct was first seen
_clzBldr
,
List<ClassBuilderInfo>
a list, this will contain additional struct classes created, if any. Should never be null!
_generatedClasses
)

Builds the struct(s) found in _dbusSig.

private List<StructTreeBuilder.StructTree>

Returns:

List with tree structure, maybe empty - never null
buildTree
(String
DBus type string
_dbusTypeStr
)

Builds a tree of types based on the given DBus type definition string.

private List<StructTreeBuilder.StructTree>

Returns:

List of tree elements, maybe empty, never null
buildTree
(ParameterizedType _pType)

Create tree from ParameterizedType.

private ClassBuilderInfo

Returns:

last created struct or null
createNested
(List<StructTreeBuilder.StructTree>
List of struct tree elements
_list
,
ClassBuilderInfo
root class of this struct (maybe other struct)
_root
,
List<ClassBuilderInfo>
a list, this will contain additional struct classes created, if any. Should never be null!
_classes
)

Create nested Struct class.

pack-priv static void
printTree(List<StructTreeBuilder.StructTree>
tree to print
_buildTree
,
int
indention level (usually 0)
_indent
)

Helper to print a StructTree to STDOUT (for debugging purposes).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentPrefixback to summary
private final String argumentPrefix

Constructor Detail

StructTreeBuilderback to summary
pack-priv StructTreeBuilder(String _argumentPrefix)
StructTreeBuilderback to summary
pack-priv StructTreeBuilder()

Method Detail

buildStructClassesback to summary
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 a Collection, 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 a Collection.

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:String

dbus Type string

_structName:String

name the struct should have

_clzBldr:ClassBuilderInfo

class builder with the class where the struct was first seen

_generatedClasses:List<ClassBuilderInfo>

a list, this will contain additional struct classes created, if any. Should never be null!

Returns:String

Struct class name or Collection type name

Exceptions
DBusException:
on DBus Error
buildTreeback to summary
private List<StructTreeBuilder.StructTree> buildTree(String _dbusTypeStr) throws DBusException

Builds a tree of types based on the given DBus type definition string.

Parameters
_dbusTypeStr:String

DBus type string

Returns:List<StructTreeBuilder.StructTree>

List with tree structure, maybe empty - never null

Exceptions
DBusException:
on Error
buildTreeback to summary
private List<StructTreeBuilder.StructTree> buildTree(ParameterizedType _pType) throws DBusException

Create tree from ParameterizedType.

Parameters
_pType:ParameterizedType

ParameterizedType object

Returns:List<StructTreeBuilder.StructTree>

List of tree elements, maybe empty, never null

Exceptions
DBusException:
on error
createNestedback to summary
private ClassBuilderInfo createNested(List<StructTreeBuilder.StructTree> _list, ClassBuilderInfo _root, List<ClassBuilderInfo> _classes)

Create nested Struct class.

Parameters
_list:List<StructTreeBuilder.StructTree>

List of struct tree elements

_root:ClassBuilderInfo

root class of this struct (maybe other struct)

_classes:List<ClassBuilderInfo>

a list, this will contain additional struct classes created, if any. Should never be null!

Returns:ClassBuilderInfo

last created struct or null

printTreeback to summary
pack-priv static void printTree(List<StructTreeBuilder.StructTree> _buildTree, int _indent)

Helper to print a StructTree to STDOUT (for debugging purposes).

Parameters
_buildTree:List<StructTreeBuilder.StructTree>

tree to print

_indent:int

indention level (usually 0)

org.freedesktop.dbus.utils.generator back to summary

pack-priv Class StructTreeBuilder.StructTree

extends Object
Class Inheritance
  • java.lang.Object
  • org.freedesktop.dbus.utils.generator.StructTreeBuilder.StructTree

Class to represent a tree structure.
Author
hypfvieh
Since
v3.0.1 - 2018-12-22

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final List<StructTreeBuilder.StructTree>

Constructor Summary

AccessConstructor and Description
pack-priv
StructTree(String _dataType)

Method Summary

Modifier and TypeMethod and Description
public Class<?>
public List<StructTreeBuilder.StructTree>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

dataTypeback to summary
private final Class<?> dataType
subTypeback to summary
private final List<StructTreeBuilder.StructTree> subType

Constructor Detail

StructTreeback to summary
pack-priv StructTree(String _dataType)

Method Detail

getDataTypeback to summary
public Class<?> getDataType()
getSubTypeback to summary
public List<StructTreeBuilder.StructTree> getSubType()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override