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

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addChild​(IUnoComposite pChild)
      adds a child to the node.
      void configure​(java.lang.String pFilename)
      sets the COMPOSITE_TYPE_FILE or COMPOSITE_TYPE_FOLDER filename.
      void configure​(java.util.Hashtable<java.lang.String,​java.lang.Object> pProperties, java.lang.String pTemplate)
      set the node for a COMPOSITE_TYPE_TEXT only.
      void create​(boolean pForce)
      creates the file or folder with its non-existing parents.
      void dispose()
      Release the references held by the object.
      IUnoComposite[] getChildren()
      return all the node children if any.
      int getType()
      returns the type of the composite.
      void removeAll()
      Removes all the children nodes.
      void setChildrenSeparator​(java.lang.String pSeparator)
      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.
      java.lang.String toString()
      returns the string representation of the node is it has a textual representation.
    • Field Detail

      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
    • Method Detail

      • 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 pChild)
        adds a child to the node. No name uniqueness will be checked.
        Parameters:
        pChild - 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​(java.util.Hashtable<java.lang.String,​java.lang.Object> pProperties,
                       java.lang.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​(java.lang.String pFilename)
        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:
        pFilename - 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​(java.lang.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 pForce)
             throws java.lang.Exception
        creates the file or folder with its non-existing parents.
        Parameters:
        pForce - true let the method overwrite the existing file if needed.
        Throws:
        java.lang.Exception - If there is any problem during the file or folder creation
      • toString

        java.lang.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 java.lang.Object
        Returns:
        the string representing the node.