Interface IUnoComposite


public interface IUnoComposite
is an interface to handle Uno composites.

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 file
  • COMPOSITE_TYPE_FOLDER: the node is representing a directory
  • COMPOSITE_TYPE_TEXT: The node is representing a piece of text

The logical use of a UNO composite will respect the following steps:

  1. setting up the composite type
  2. configuring the composite depending on its type
  3. adding children to the composite
  4. creating the composite file, folder or text

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    configures the composite as a file.
    static final int
    configures the composite as a folder.
    static final int
     
    static final int
    configures the composite as a UNO-IDL object with a textual representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    adds a child to the node.
    void
    configure(String filename)
    sets the COMPOSITE_TYPE_FILE or COMPOSITE_TYPE_FOLDER filename.
    void
    configure(Hashtable<String,Object> pProperties, String pTemplate)
    set the node for a COMPOSITE_TYPE_TEXT only.
    void
    create(boolean force)
    creates the file or folder with its non-existing parents.
    void
    Release the references held by the object.
    return all the node children if any.
    int
    returns the type of the composite.
    void
    Removes all the children nodes.
    void
    defines the string which has to be inserted between two children.
    void
    setIndented(boolean pToIndent)
    sets whether the output string of the text composite will be indented or not.
    void
    setType(int pType)
    sets the type of the composite.
    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_FILE
      configures 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_FOLDER
      configures 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_TEXT
      configures 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

      void addChild(IUnoComposite child)
      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 the COMPOSITE_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_TEXT node can only contain COMPOSITE_TYPE_TEXT children. Otherwise they won't be taken into account for the node toString() 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 the COMPOSITE_TYPE_* types.
      Returns:
      the type of the composite
    • configure

      void configure(Hashtable<String,Object> pProperties, String pTemplate)
      set the node for a COMPOSITE_TYPE_TEXT only. The template uses some properties defined inthe properties parameter.

      The template is a string where \n is 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 children toString() result

      Example 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 the toString() method.
    • configure

      void configure(String filename)
      sets the COMPOSITE_TYPE_FILE or COMPOSITE_TYPE_FOLDER filename.

      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 from COMPOSITE_TYPE_TEXT
      Parameters:
      pToIndent - true will add indentation.
    • setChildrenSeparator

      void setChildrenSeparator(String pSeparator)
      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

      void create(boolean force) throws Exception
      creates the file or folder with its non-existing parents.
      Parameters:
      force - true let 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.
      Overrides:
      toString in class Object
      Returns:
      the string representing the node.