Interface IUnoComposite
Their goal is to provide a simple tree structure to generate UNO-IDL files. A Uno composite could be of several types:
COMPOSITE_TYPE_NOTSET: the type isn't set (very bad)COMPOSITE_TYPE_FILE: the node is representing a fileCOMPOSITE_TYPE_FOLDER: the node is representing a directoryCOMPOSITE_TYPE_TEXT: The node is representing a piece of text
The logical use of a UNO composite will respect the following steps:
- setting up the composite type
- configuring the composite depending on its type
- adding children to the composite
- creating the composite file, folder or text
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intconfigures the composite as a file.static final intconfigures the composite as a folder.static final intstatic final intconfigures the composite as a UNO-IDL object with a textual representation. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IUnoComposite child) adds a child to the node.voidsets theCOMPOSITE_TYPE_FILEorCOMPOSITE_TYPE_FOLDERfilename.voidset the node for a COMPOSITE_TYPE_TEXT only.voidcreate(boolean force) creates the file or folder with its non-existing parents.voiddispose()Release the references held by the object.return all the node children if any.intgetType()returns the type of the composite.voidRemoves all the children nodes.voidsetChildrenSeparator(String pSeparator) defines the string which has to be inserted between two children.voidsetIndented(boolean pToIndent) sets whether the output string of the text composite will be indented or not.voidsetType(int pType) sets the type of the composite.toString()returns the string representation of the node is it has a textual representation.
-
Field Details
-
COMPOSITE_TYPE_NOTSET
static final int COMPOSITE_TYPE_NOTSET- See Also:
-
COMPOSITE_TYPE_FILE
static final int COMPOSITE_TYPE_FILEconfigures the composite as a file. The filename has to be filed in order to create the composite.- See Also:
-
COMPOSITE_TYPE_FOLDER
static final int COMPOSITE_TYPE_FOLDERconfigures the composite as a folder. The property filename has to be filed in order to create the composite.- See Also:
-
COMPOSITE_TYPE_TEXT
static final int COMPOSITE_TYPE_TEXTconfigures the composite as a UNO-IDL object with a textual representation. Thus the properties and template have to be filled in order to create the composite.- See Also:
-
-
Method Details
-
dispose
void dispose()Release the references held by the object. -
getChildren
IUnoComposite[] getChildren()return all the node children if any.- Returns:
- an array of zero or more IUnoComposite nodes
-
addChild
adds a child to the node. No name uniqueness will be checked.- Parameters:
child- the child to add
-
removeAll
void removeAll()Removes all the children nodes. -
setType
void setType(int pType) sets the type of the composite. The value has to be chosen among theCOMPOSITE_TYPE_*types.This method can be called only once to avoid strange reconfigurations of the node. Moreover, it should be called first to setup the node before to set the properties or template. Any other operation done with the type unset will be simply ignored.
Please note that a
COMPOSITE_TYPE_TEXTnode can only containCOMPOSITE_TYPE_TEXTchildren. Otherwise they won't be taken into account for the nodetoString()execution.- Parameters:
pType- the COMPOSITE_TYPE_XXX type of the node
-
getType
int getType()returns the type of the composite. The value is one of theCOMPOSITE_TYPE_*types.- Returns:
- the type of the composite
-
configure
set the node for a COMPOSITE_TYPE_TEXT only. The template uses some properties defined inthe properties parameter.The template is a string where
\nis the end of line, and the properties are written using the form${prop_name}. The property name has to correspond to one of the properties given in attribute, otherwises the empty string will be used instead. The special property${children}will be replaced by the childrentoString()resultExample of template:
module ${name} { ${children} };Example of properties associated:
- name = mymodule
- Parameters:
pProperties- properties table. The name is associated to the value.pTemplate- the string template used in thetoString()method.
-
configure
sets theCOMPOSITE_TYPE_FILEorCOMPOSITE_TYPE_FOLDERfilename.There is no need to have a very deep folder and file tree, because only one will be sufficient to create all the parents.
- Parameters:
filename- the composite filename.
-
setIndented
void setIndented(boolean pToIndent) sets whether the output string of the text composite will be indented or not. The method has no effect if the type is different fromCOMPOSITE_TYPE_TEXT- Parameters:
pToIndent-truewill add indentation.
-
setChildrenSeparator
defines the string which has to be inserted between two children. If no separator is specified, the children will simply be concatenated.- Parameters:
pSeparator- the separator to add between the children
-
create
creates the file or folder with its non-existing parents.- Parameters:
force-truelet the method overwrite the existing file if needed.- Throws:
Exception- If there is any problem during the file or folder creation
-
toString
String toString()returns the string representation of the node is it has a textual representation. The string will be a reference for the files and folders.
-