Class AbstractConfigurationElement

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String ATT_CONFIG_SRC  
      protected static java.lang.String ATT_DELETED  
      protected static java.lang.String ATT_POSITION  
      protected static java.lang.String ATT_PROTOTYPE  
      static java.lang.String ATT_USE_DEFAULT
      Defines the "use-default" attribute.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void addFileSource​(java.lang.String filePath, java.lang.String appPath, long lastLoaded)
      Adds a reference to a file from a config-source.
      void applyCustomization​(CustomizationInfo c)
      Applies the corresponding customizations.
      void applyCustomizations()
      Loops through all the CustomizationInfo in the Customizations class and apply the corresponding customizations.
      void cleanUpDeletedElements()
      This method when called will delete all the child elements that are marked as deleted.
      java.lang.Object clone()  
      void delete​(java.lang.Object key)  
      AbstractConfigurationElement deltas()
      Returns the deltas between the original() and this objects.
      AbstractConfigurationElement deltas​(AbstractConfigurationElement other)
      Returns a partial instance of this object that contains the attributes and elements required to make this object equals to the other paramter.
      protected boolean equalAtts​(AbstractConfigurationElement other)
      Returns true if the list of active attributes of the given AbstractConfigurationElement is equal to this list of active attributes of this AbstractConfigurationElement.
      protected boolean equalElements​(AbstractConfigurationElement other)
      Returns true if the list of all child elements of the given AbstractConfigurationElement is equal to this list of all child-elements of this AbstractConfigurationElement.
      protected boolean equalNodeValues​(AbstractConfigurationElement other)
      Returns true if the node value of both configuration elements is the same.
      boolean equals​(java.lang.Object object)  
      boolean equalsIncludingDeletedElements​(java.lang.Object object)  
      protected void exportAttributesToXML​(org.w3c.dom.Element element, ConfigurationSource source)
      Appends the list of attributes of this ConfigurationElement into the given node.
      protected void exportElementsToXML​(org.w3c.dom.Element element, ConfigurationSource source)
      Appends the list of child-elements of this ConfigurationElement into the given node.
      protected void exportNodeValueToXML​(org.w3c.dom.Element element, ConfigurationSource source)
      Appends the node value associated with the given source key into the given node.
      ConfigurationValue getAttribute​(java.lang.String name)
      Returns the value associated with the given attribute.
      HashList getAttributes()
      Returns the list of all attributes available to this ConfigurationElement.
      protected boolean getBoolAttribute​(java.lang.String name)
      Helper method, returns the value of the given attribute as boolean (true/false).
      protected java.lang.Object getChildKey​(org.w3c.dom.Node node)
      Returns the key that uniquely identifies the child element associated with the given Node.
      java.lang.String getConfigSrc()
      Returns the value of the config-src attribute.
      protected java.lang.String getDTDFileName()
      Returns the name of a DTD file that will be added as SystemID to the XML resulting from serializing the contents of this ConfigurationElement into a file; null by default.
      ConfigurationElement getElement​(java.lang.Object key)
      Returns the ConfigurationElement instance associated with the given nodeName.
      protected ConfigurationElement getElement​(java.lang.Object key, boolean includeDeleted)  
      HashList getElements()
      Returns the list of all child-elements available to this ConfigurationElement.
      FileLoader getFileLoader()
      Returns the file loader instance used by this ConfigurationElement to load files from the file system.
      protected int getIntAttribute​(java.lang.String name)
      Helper method, returns the value of the given attribute as integer.
      protected int getIntAttribute​(java.lang.String name, int defaultValue)
      Helper method, returns the value of the given attribute as integer.
      java.lang.Object getKey()
      Default implementation for getKey().
      protected abstract java.lang.String getKeyAttribute()
      This method must return the attribute that uniquely identifies this element among its siblings; if no single attribute can be used, return null and override the getKey and setKey methods.
      int getLineNumber()
      Returns the line number (if known) of the element in the XML file.
      protected AbstractConfigurationElement.FilteredList getList​(java.lang.String nodeName)
      Returns an ImplicitList with all the elements associated with the given nodeName.
      java.lang.Object getNextKey()
      Returns an object that can be used as key for a list of child-elements that doesn't have a key by itself.
      java.lang.String getNodeName()
      Returns the node-name for this element.
      java.lang.String getNodeValue()
      Returns the node value for this element.
      protected java.lang.String getNodeValue​(ConfigurationSource source)
      Returns the node value for this element in the given sourceKey.
      protected AbstractConfigurationElement getOrCreateElement​(java.lang.String nodeName, java.lang.Object key)
      Returns the current child instance; if null but the child is registered, it creates a new instance for it.
      AbstractConfigurationElement getParent()
      Gets the parent for this configuration element.
      int getPosition()
      Returns the expected position of this element.
      protected AbstractConfigurationElement getPrototype()
      Returns the current prototype of this instance.
      protected java.lang.Class getRegisteredClass​(java.lang.String nodeName)
      Returns the Class associated with the given nodeName.
      java.lang.String getSelfInitPath()
      Returns the path to the file where this configuration element was originally loaded from.
      protected ConfigurationSource getSource​(java.lang.String key)
      Gets the ElementSource for the given key.
      java.lang.String getStrAttribute​(java.lang.String name)
      Helper method, returns the value of the given attribute as a string.
      boolean getUseDefault()
      Returns the use-default value.
      protected ParserParameters getXMLParserParameters​(java.lang.String fileName)
      Returns an instance of ParserParameters used by the XML parser.
      protected SerializerParameters getXMLSerializerParameters()
      Returns an instance of SerializerParameters used by the XML serializer in the toXML(org.w3c.dom.Document) By default it returns null.
      int hashCode()  
      protected int hashCodeAtts()
      Returns the hashcode for attributes.
      protected int hashCodeElements()
      Returns the hashcode for attributes.
      protected int hashCodeNodeValues()
      Returns the hashcode for attributes.
      protected boolean hasRegisteredClass​(java.lang.String nodeName)
      Returns true is there is a child registered for the given nodeName.
      protected void initAttributesFromXML​(org.w3c.dom.Node root, java.lang.String sourceKey, CustomizationInfo c)
      Initializes the list of attributes from given Node
      protected void initDefaultAttributes()
      This method can be overridden to set default values for attributes.
      protected void initElementFromXML​(org.w3c.dom.Node child, java.lang.String sourceKey, CustomizationInfo c)
      Initializes a single child-element from the given Node
      protected void initElementsFromXML​(org.w3c.dom.Node root, java.lang.String sourceKey, CustomizationInfo c)
      Initializes the list of child-elements from given Node
      protected void initFromFile​(java.lang.String filePath, CustomizationInfo c)
      Initializes this configuration element by loading the contents of the given filePath using the corresponding CustomizationInfo.
      void initFromResource​(java.lang.String resourceName)
      Initializes this configuration element by loading the contents a resource that exists in the class path.
      void initFromXML​(org.w3c.dom.Node root)
      Initialize the attributes and child elements from the values in the given Node
      protected void initFromXML​(org.w3c.dom.Node root, java.lang.String sourceKey, CustomizationInfo c)
      Initialize the attributes and child elements from the values in the given Node
      protected void initNodeValueFromXML​(org.w3c.dom.Node root, java.lang.String sourceKey, CustomizationInfo c)
      Initializes the list of child-elements from given Node
      protected void initPrototype​(java.lang.String protoName)
      Inits the prototype object of this element.
      boolean isActive()  
      boolean isCustomized()  
      boolean isDeleted()
      Returns true is this element has been mark as deleted.
      boolean isDirty()
      Returns true is this element or one of its children has been modified programatically after being loaded.
      protected boolean isInSource​(java.lang.String sourceKey)
      Returns true if the element already contains an ElementSource for the given key.
      protected boolean isKeyAttribute​(java.lang.String name)
      Returns true is the name is that of the key attribute.
      void load​(java.lang.String fileName)
      Loads the file with the given name and initializes this ConfigurationElement with its content.
      protected void mergeChanges​(java.lang.String srcKey)
      Removes deltas and applies them to the given source.
      protected AbstractConfigurationElement newChildInstance​(java.lang.String nodeName, java.lang.Class childClass)
      Creates a new instance of a child element for the given class.
      protected ConfigurationSource newSource​(java.lang.String srcKey, CustomizationInfo c)
      Create a new ElementSource and adds to the list of sources of this element.
      AbstractConfigurationElement original()
      Returns a new instance of this object, populated only with the out of the box values of Microstrategy Web, that is, only default values or those that came from the load method.
      ConfigurationElement populate​(ConfigurationElement other)
      This method takes another configuration element and populates this element with the other's attributes and child-elements.
      protected void printAttributes​(java.lang.StringBuffer outString)
      Appends the list of attributes of this ConfigurationElement into the given StringBuffer.
      protected void printElements​(java.lang.StringBuffer outString)
      Appends the list of child-elements of this ConfigurationElement into the given StringBuffer.
      protected void printNodeValue​(java.lang.StringBuffer outString)
      Appends the node value into the given StringBuffer.
      protected void refreshLists()  
      protected void registerClass​(java.lang.String nodeName, java.lang.Class c)
      Registers a child class for the child with the given nodeName.
      protected void registerElement​(java.lang.String nodeName, java.lang.Class c)
      Register a child of this ConfigurationElement.
      protected void registerElement​(java.lang.String nodeName, java.lang.Class c, boolean canBeNull)
      Register a child of this ConfigurationElement.
      protected void registerElementList​(java.lang.String nodeName, java.lang.Class c)
      Register a list of this ConfigurationElement.
      void reload()
      Loops through all the ElementSource of this ConfigurationElement and reloads the content of those whose underlying configuration file has changed.
      protected void reloadPrototype()
      Loops through all the ElementSource of this ConfigurationElement and reloads the content of those whose underlying configuration file has changed.
      protected void removeAttribute​(java.lang.String name)
      Completely remove the value for the given attribute.
      protected void removeDefaults​(CustomizationInfo c)
      This method is called when the use-default attribute is set false, so all previous values of attributes and children must be cleared.
      void replaceList​(AbstractConfigurationElement.FilteredList list)  
      void restore​(java.lang.Object key)  
      void save()
      Saves this ConfigurationElement back into the files where it was loaded from.
      void save​(CustomizationInfo c)
      Saves deltas for this ConfigurationElement into the given CustomizationInfo.
      void saveChangesAs​(java.lang.String fileName)
      Saves all in-memory changes to the given file.
      void saveConfig​(java.lang.String filePath)
      Deprecated.
      To save in a different location, set a custom FileLoader and use the save() method.
      void saveFlatXML​(java.lang.String fileName)
      Saves the current element structure, in XML format, into the given file.
      protected void saveNode​(org.w3c.dom.Node node, java.lang.String fileLocation)
      Saves an XML node into a file in the given location.
      protected void saveSource​(ConfigurationSource source)
      Saves only the contents associated with the given source.
      protected void setAttribute​(java.lang.String name, java.lang.Object value)
      Sets the value for the given attribute.
      protected void setBoolAttribute​(java.lang.String name, boolean value)
      Helper method, sets the value of the given attribute from a boolean.
      protected void setChildOriginals()  
      void setConfigSrc​(java.lang.String path)
      Sets the config-src attribute.
      void setCustomized​(boolean value)
      set if this element is a customized element or not.
      protected void setElement​(java.lang.Object key, ConfigurationElement child)
      Allows users to add or replace an element.
      void setFileLoader​(FileLoader fl)
      Sets the FileLoader instance to be used to load files.
      protected void setIntAttribute​(java.lang.String name, int value)
      Helper method, sets the value of the given attribute from an integer.
      protected void setKey​(org.w3c.dom.Element element)
      Default implementation for setKey().
      void setLineNumber​(int lineNumber)
      Sets the line number of the element in the XML file.
      protected void setNodeName​(java.lang.String name)
      Sets the name of the node associated with this configuration element.
      protected void setNodeValue​(java.lang.String value)
      Returns the node value for this element.
      void setPosition​(int position)
      Sets the expected position of this element.
      protected void setPrototype​(AbstractConfigurationElement prototype)
      Sets the prototype object for this instance.
      protected void setSelfInitPath​(java.lang.String value)  
      protected void setStrAttribute​(java.lang.String name, java.lang.String value)
      Helper method, sets the value of the given attribute as a string.
      void setUseDefault​(boolean useDefault)
      The definition of a ConfigurationElement can come come from different sources, for example, the definition can come from an external file (by specifying a getConfigSrc() value), or it can be modified through a Customization.
      void setUseValidation​(boolean value)
      Defines whether the XML content should validated using a DTD.
      protected boolean throwConfigParseException()
      Control whether to throw configuration parse exception DE20651: Do not throw exception for viz configurations to avoid error / empty on Main pages.
      java.lang.String toString()
      Generates the String representation of this ConfigurationElement.
      org.w3c.dom.Element toXML()
      Generates the DOM representation of this ConfigurationElement.
      protected org.w3c.dom.Element toXML​(java.lang.String sourceKey)
      Generates the DOM representation of this ConfigurationElement for the list of attributes and elements defined in the given ElementSource.
      org.w3c.dom.Element toXML​(org.w3c.dom.Document doc)
      Generates the DOM representation of this ConfigurationElement.
      protected org.w3c.dom.Element toXML​(org.w3c.dom.Document doc, java.lang.String sourceKey)
      Generates the DOM representation of this ConfigurationElement for the list of attributes and elements defined in the given ElementSource.
      protected boolean useNodeValue()
      Controls whether this element will use the node value as a property.
      boolean useValidation()
      Returns whether the XML content should be validated using a DTD.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractConfigurationElement

        protected AbstractConfigurationElement()
        Default constructor. Calls initDefaultAttributes()
    • Method Detail

      • setNodeName

        protected void setNodeName​(java.lang.String name)
        Sets the name of the node associated with this configuration element.
      • getParent

        public AbstractConfigurationElement getParent()
        Gets the parent for this configuration element. Returns null if it's a root or if it's still not associated to any element.
      • registerElement

        protected void registerElement​(java.lang.String nodeName,
                                       java.lang.Class c,
                                       boolean canBeNull)
        Register a child of this ConfigurationElement. When a node with the given name is found in the configuration file, an instance of c is created and initialized with the corresponding configuration. It's assumed that only one child with this name is available in the configuration file; if more than one is found, the corresponding nodes are merged into a single ConfigurationElement.

        The canBeNull parameter controls whether the child instance is created by default or not. When false, the getElement(java.lang.Object) will always return a non-null instance even if the child is not in the XML; if true the child instance is only created if the object is found in the XML, in this case null checks are necessary in your code after calling getElement to make sure the return object is not null.


        Only elements registered with this and with the registerElementList(java.lang.String, java.lang.Class) methods are valid child nodes in the configuration file. If a child has not been registered, WARNING messages will be logged.

        This method should only be called in the constructor, otherwise the clone method will fail. It can only be called if the useNodeValue() method returns false as they are mutually exclusive: by design an element can only use children if its not using the node value.

        Currently it is required that all registered child elements extend AbstractConfigurationElement. If the given class c doesn't, this method will throw an IllegalArgumentException.
        See Also:
        getElement(java.lang.Object)
      • registerClass

        protected void registerClass​(java.lang.String nodeName,
                                     java.lang.Class c)
        Registers a child class for the child with the given nodeName. Used to keep track of those children than can have null values.
      • hasRegisteredClass

        protected boolean hasRegisteredClass​(java.lang.String nodeName)
        Returns true is there is a child registered for the given nodeName.
      • getRegisteredClass

        protected java.lang.Class getRegisteredClass​(java.lang.String nodeName)
        Returns the Class associated with the given nodeName.
      • registerElementList

        protected void registerElementList​(java.lang.String nodeName,
                                           java.lang.Class c)
        Register a list of this ConfigurationElement. When a node with the given name is found in the configuration file, an instance of c is created and initialized with the corresponding configuration. If more than one subnodes are found with this name, one instance for each is created and all of them are added as child of this ConfigurationElement. The list can then be accessed through the getList(java.lang.String) method.

        Only elements registered with this and with the registerElement(java.lang.String, java.lang.Class) methods are valid child nodes in the configuration file.

        This method should only be called in the constructor, otherwise the clone method will fail. It can only be called if the useNodeValue() method returns false as they are mutually exclusive: by design an element can only use children if its not using the node value.

        Currently it is required that all registered child elements extend AbstractConfigurationElement. If the given class c doesn't, this method will throw an IllegalArgumentException.
      • useNodeValue

        protected boolean useNodeValue()
        Controls whether this element will use the node value as a property. For example, nodes defined as:
        
          <a att="1">This is the node value</a>
         
        can expose a property which will return the node's value (This is the node vale). When this is the case, though, the element can't have any sub elements. They're mutually exclusive.
        Returns:
        false by default. Override this method if you want to associate the node value with some property.
      • getConfigSrc

        public java.lang.String getConfigSrc()
        Returns the value of the config-src attribute. This attribute indicates a file path where the definition of this attribute will be loaded from or saved into.
      • setConfigSrc

        public void setConfigSrc​(java.lang.String path)
        Sets the config-src attribute. If setting it to a non-null value, the definiton of this configuration element will be saved into this location.
      • setUseDefault

        public void setUseDefault​(boolean useDefault)
        The definition of a ConfigurationElement can come come from different sources, for example, the definition can come from an external file (by specifying a getConfigSrc() value), or it can be modified through a Customization. When the useDefault is set to false, values that come from previous sources are ignored and only the definition from the current source is used; this includes all attributes and child elements of this element. This is especially useful in customizations to replace the out of the box values of a node with a new definition.
        Parameters:
        useDefault - true/false value
      • getUseDefault

        public boolean getUseDefault()
        Returns the use-default value.
        Returns:
        the true/false value of the useDefault flag of this Configuration Element
        See Also:
        setUseDefault(boolean)
      • getPosition

        public int getPosition()
        Returns the expected position of this element. If the position should be automatically infered from the position found in the XML, it returns -1. This value is stored in the "position" attribute of the node. Notice that the actual position of this element might differ from this value, as the position attribute is not guaranteed to be unique or correct.
      • setPosition

        public void setPosition​(int position)
        Sets the expected position of this element. The value is stored in the "position" attribute of the node. If when calling this method, this instance is a member of an ImplicitList, the element will automatically reposition itself in this list. Setting -1 as position indicates to automatically position this element based on its position in the XML.
      • getKey

        public java.lang.Object getKey()
        Default implementation for getKey(). It assumes a single attribute can be used to uniquely identify this element among its siblings; the attribute to use is specified by the getKeyAttribute() method.
        Specified by:
        getKey in interface ConfigurationElement
        Returns:
        If getKeyAttribute() is empty returns null, otherwise it returns the value of the given attribute.
      • setKey

        protected void setKey​(org.w3c.dom.Element element)
        Default implementation for setKey(). It assumes a single attribute can be used to uniquely identify this element among its siblings and adds this attribute to the given element; the attribute to use is specified by the getKeyAttribute() method.
      • getKeyAttribute

        protected abstract java.lang.String getKeyAttribute()
        This method must return the attribute that uniquely identifies this element among its siblings; if no single attribute can be used, return null and override the getKey and setKey methods.
      • getElement

        public ConfigurationElement getElement​(java.lang.Object key)
        Returns the ConfigurationElement instance associated with the given nodeName. If the ConfigurationElement was not present in the xml configuration, this method might return an empty instance of the corresponding ConfigurationElement or null depending on the canBeNull parameter passed to the registerElement(java.lang.String, java.lang.Class) method. If a list is associated with the given nodeName, this method returns a list containing all the ConfigurationElement instances for that nodeName. If no ConfigurationElement is associated with the given nodeName, the method returns null.
        Specified by:
        getElement in interface ConfigurationElement
      • getElement

        protected ConfigurationElement getElement​(java.lang.Object key,
                                                  boolean includeDeleted)
      • newChildInstance

        protected AbstractConfigurationElement newChildInstance​(java.lang.String nodeName,
                                                                java.lang.Class childClass)
        Creates a new instance of a child element for the given class.
      • setElement

        protected void setElement​(java.lang.Object key,
                                  ConfigurationElement child)
        Allows users to add or replace an element. If an element with the given key already exists it gets replaced, otherwise it's simply added.
      • delete

        public void delete​(java.lang.Object key)
      • restore

        public void restore​(java.lang.Object key)
      • isActive

        public boolean isActive()
      • refreshLists

        protected void refreshLists()
      • getList

        protected AbstractConfigurationElement.FilteredList getList​(java.lang.String nodeName)
        Returns an ImplicitList with all the elements associated with the given nodeName. If no child was present in the xml configuration with this name, it will return an empty list. If the nodeName has not been registered for a list, it throws an IllegalArgumentException.

      • isKeyAttribute

        protected boolean isKeyAttribute​(java.lang.String name)
        Returns true is the name is that of the key attribute.
      • getNodeValue

        public java.lang.String getNodeValue()
        Returns the node value for this element. The node value represents the inner content of the xml tag. If multiple ElementSources are defined for this element, it returns the value of the one with greater priority.
      • getNodeValue

        protected java.lang.String getNodeValue​(ConfigurationSource source)
        Returns the node value for this element in the given sourceKey. The node value represents the inner content of the xml tag.
        If sourceKey is null, it returns the current value.
      • setNodeValue

        protected void setNodeValue​(java.lang.String value)
        Returns the node value for this element. The node value represents the inner context of the xml tag. If multiple ElementSources are defined for this element, it returns the value of the one with greater priority.
      • getAttribute

        public final ConfigurationValue getAttribute​(java.lang.String name)
        Returns the value associated with the given attribute. If the attribute was not present in the xml configuration the method returns null.
        Specified by:
        getAttribute in interface ConfigurationElement
      • setAttribute

        protected void setAttribute​(java.lang.String name,
                                    java.lang.Object value)
        Sets the value for the given attribute.
      • removeAttribute

        protected void removeAttribute​(java.lang.String name)
        Completely remove the value for the given attribute.
      • getStrAttribute

        public java.lang.String getStrAttribute​(java.lang.String name)
        Helper method, returns the value of the given attribute as a string.
        Specified by:
        getStrAttribute in interface ConfigurationElement
      • setStrAttribute

        protected void setStrAttribute​(java.lang.String name,
                                       java.lang.String value)
        Helper method, sets the value of the given attribute as a string.
      • getIntAttribute

        protected int getIntAttribute​(java.lang.String name)
        Helper method, returns the value of the given attribute as integer. If the attribute has no value, it returns Integer.MIN_VALUE. If the attribute has a non-numeric value, it throws an IllegalArgumentException.
      • getIntAttribute

        protected int getIntAttribute​(java.lang.String name,
                                      int defaultValue)
        Helper method, returns the value of the given attribute as integer. If the attribute has no value, it returns the defaultValue parameter. If the attribute has a non-numeric value, it throws an IllegalArgumentException.
      • setIntAttribute

        protected void setIntAttribute​(java.lang.String name,
                                       int value)
        Helper method, sets the value of the given attribute from an integer.
      • getBoolAttribute

        protected boolean getBoolAttribute​(java.lang.String name)
        Helper method, returns the value of the given attribute as boolean (true/false). If the attribute has no value it returns false; otherwise it returns Boolean.valueOf(boolean).
        See Also:
        Boolean.valueOf(boolean)
      • setBoolAttribute

        protected void setBoolAttribute​(java.lang.String name,
                                        boolean value)
        Helper method, sets the value of the given attribute from a boolean.
      • isDeleted

        public boolean isDeleted()
        Returns true is this element has been mark as deleted.
        See Also:
        delete(Object)
      • isDirty

        public boolean isDirty()
        Returns true is this element or one of its children has been modified programatically after being loaded.
      • newSource

        protected ConfigurationSource newSource​(java.lang.String srcKey,
                                                CustomizationInfo c)
        Create a new ElementSource and adds to the list of sources of this element. If there is already an ElementSource for the given key, this method will return the same instance, but this should be avoided to prevent infinite recursive loops with the config-src attribute.
      • getSource

        protected ConfigurationSource getSource​(java.lang.String key)
        Gets the ElementSource for the given key. If there is no ConfigurationSource for the given key, a new source is automatically added.
      • isInSource

        protected boolean isInSource​(java.lang.String sourceKey)
        Returns true if the element already contains an ElementSource for the given key.
      • initFromXML

        public void initFromXML​(org.w3c.dom.Node root)
        Initialize the attributes and child elements from the values in the given Node
        Specified by:
        initFromXML in interface ConfigurationElement
        Parameters:
        root - Node intance representing the configuration element properties
      • initFromXML

        protected void initFromXML​(org.w3c.dom.Node root,
                                   java.lang.String sourceKey,
                                   CustomizationInfo c)
                            throws ConfigException
        Initialize the attributes and child elements from the values in the given Node
        Parameters:
        root - The DOM Node from where the information is read
        sourceKey - The key that identifies the ElementSource where the values are being read
        c - CustomizationInfo class where the ElementSource was loaded from.
        Throws:
        ConfigException - If an error occurs while reading the definition, typically if there is a problem when reading the file pointed by the config-src attribute.
      • setChildOriginals

        protected void setChildOriginals()
      • setCustomized

        public void setCustomized​(boolean value)
        set if this element is a customized element or not. If user adds a new element it is considered a customized element and user needs to set this element as custom.
        Parameters:
        value -
      • isCustomized

        public boolean isCustomized()
        Returns:
        true - if it is a customized element false - if it is an OOTB element
      • initPrototype

        protected void initPrototype​(java.lang.String protoName)
        Inits the prototype object of this element. This element will inherit all the attribute and child elements from the prototype, but then any values defined through the config-src file or inline take precedence over the prototype. The name attribute represents the name of the prototype as specified in the XML. Typically this is the name of a sibling node in the xml. If name is empty, a different sibling might be used as prototype (like in the case of the PageInfo, which the page marked as isDefault is used as the default prototype). If this object already has a prototype, or if the prototype is not found in the siblings collections this methods throws an Exception.
        Parameters:
        protoName - Prototype name, typically the name of a sibling node in the xml.
      • setPrototype

        protected void setPrototype​(AbstractConfigurationElement prototype)
        Sets the prototype object for this instance. The attributes and elements of the prototype are copied into this instance.
      • removeDefaults

        protected void removeDefaults​(CustomizationInfo c)
        This method is called when the use-default attribute is set false, so all previous values of attributes and children must be cleared.
      • initElementFromXML

        protected void initElementFromXML​(org.w3c.dom.Node child,
                                          java.lang.String sourceKey,
                                          CustomizationInfo c)
                                   throws ConfigException
        Initializes a single child-element from the given Node
        Throws:
        ConfigException
      • getLineNumber

        public int getLineNumber()
        Returns the line number (if known) of the element in the XML file.
        Returns:
        The line number (if known). Otherwise, return -1.
      • setLineNumber

        public void setLineNumber​(int lineNumber)
        Sets the line number of the element in the XML file.
        Parameters:
        lineNumber - The line number of this AbstractConfigurationElement in the XML file.
      • getOrCreateElement

        protected AbstractConfigurationElement getOrCreateElement​(java.lang.String nodeName,
                                                                  java.lang.Object key)
        Returns the current child instance; if null but the child is registered, it creates a new instance for it.
      • initFromFile

        protected void initFromFile​(java.lang.String filePath,
                                    CustomizationInfo c)
                             throws ConfigException
        Initializes this configuration element by loading the contents of the given filePath using the corresponding CustomizationInfo.
        Throws:
        ConfigException
      • addFileSource

        protected void addFileSource​(java.lang.String filePath,
                                     java.lang.String appPath,
                                     long lastLoaded)
        Adds a reference to a file from a config-source. This file will then be automatically reloaded if changed and will be used when the save() method is called.
      • initFromResource

        public void initFromResource​(java.lang.String resourceName)
                              throws ConfigException
        Initializes this configuration element by loading the contents a resource that exists in the class path.
        Throws:
        ConfigException
      • getXMLParserParameters

        protected ParserParameters getXMLParserParameters​(java.lang.String fileName)
        Returns an instance of ParserParameters used by the XML parser. By default if using validation creates a new ParserParameters instance with a SimpleErrorHandler and FileLoaderEntityResolver; otherwise it returns null;
      • getDTDFileName

        protected java.lang.String getDTDFileName()
        Returns the name of a DTD file that will be added as SystemID to the XML resulting from serializing the contents of this ConfigurationElement into a file; null by default. This method should be extended if the concrete instance of an element has a predefined DTD file associated.
      • setUseValidation

        public void setUseValidation​(boolean value)
        Description copied from interface: ConfigurationFile
        Defines whether the XML content should validated using a DTD.
        Specified by:
        setUseValidation in interface ConfigurationFile
        Parameters:
        value - true requires that the XML is parsed with DTD validation on.
      • useValidation

        public boolean useValidation()
        Description copied from interface: ConfigurationFile
        Returns whether the XML content should be validated using a DTD. If true when the XML is parsed the file will be validated using the corresponding DTD (as defined in the XML itself).
        Specified by:
        useValidation in interface ConfigurationFile
      • save

        public void save()
                  throws ConfigException
        Saves this ConfigurationElement back into the files where it was loaded from. All in-memory changes are automatically applied into the last ElementSource used to load this element.
        Specified by:
        save in interface ConfigurationFile
        Throws:
        ConfigException
      • saveChangesAs

        public void saveChangesAs​(java.lang.String fileName)
                           throws ConfigException
        Saves all in-memory changes to the given file. If this ConfigurationElement was loaded from that file, the resulting file includes the original contents plus the changes.
        Throws:
        ConfigException
      • saveConfig

        public final void saveConfig​(java.lang.String filePath)
                              throws ConfigException
        Deprecated.
        To save in a different location, set a custom FileLoader and use the save() method.
        Saves this element configuration into the given filePath. Notice that this method has been deprecated: To save the configuration file into a different location it's better to create a FileLoader with the new folder path and assign it to the root element:
        PageManager pm = new PageManager(); pm.load(".\\WEB-INF\\xml\\pageConfig.xml"); FileLoader fl = new FileLoader(System.getProperty("user.dir") + OUTPUT_FOLDER); //Save it in a different folder: pm.setFileLoader(fl); pm.save();
        This makes sure all config-src are saved into their corresponding file.
        Throws:
        ConfigException
      • cleanUpDeletedElements

        public void cleanUpDeletedElements()
        This method when called will delete all the child elements that are marked as deleted.
      • saveFlatXML

        public void saveFlatXML​(java.lang.String fileName)
                         throws ConfigException
        Saves the current element structure, in XML format, into the given file.
        Throws:
        ConfigException
      • saveNode

        protected void saveNode​(org.w3c.dom.Node node,
                                java.lang.String fileLocation)
                         throws ConfigException
        Saves an XML node into a file in the given location.
        Parameters:
        node - the xml node to save
        fileLocation - An absolute path for the file location
        Throws:
        ConfigException
      • mergeChanges

        protected void mergeChanges​(java.lang.String srcKey)
        Removes deltas and applies them to the given source.
      • getSelfInitPath

        public java.lang.String getSelfInitPath()
        Returns the path to the file where this configuration element was originally loaded from. It only returns a non-null value when this element was loaded using the load(java.lang.String) method, or if it was loaded from a node that had the "config-src" attribute specified.
      • setSelfInitPath

        protected void setSelfInitPath​(java.lang.String value)
      • toXML

        public org.w3c.dom.Element toXML​(org.w3c.dom.Document doc)
        Generates the DOM representation of this ConfigurationElement. This method returns the list of attributes and elements merged from all ElementSource. Note that the resulting Element will not be associated with the Document parameter. It is important to ensure that all DOM trees have a Document root as some serializers do not behave correctly otherwise. Use toXML() if the resulting DOM is not going to be appended in another DOM structure.
        Specified by:
        toXML in interface ConfigurationElement
        Parameters:
        doc - factory for creating underlying Element
        Returns:
        DOM of this instance
      • toXML

        public org.w3c.dom.Element toXML()
        Generates the DOM representation of this ConfigurationElement. This method returns the list of attributes and elements merged from all ElementSource.
        Returns:
        a stand alone DOM with its own document root instance
      • toXML

        protected org.w3c.dom.Element toXML​(java.lang.String sourceKey)
        Generates the DOM representation of this ConfigurationElement for the list of attributes and elements defined in the given ElementSource.
        Returns:
        a stand alone DOM with its own document root instance
      • toXML

        protected org.w3c.dom.Element toXML​(org.w3c.dom.Document doc,
                                            java.lang.String sourceKey)
        Generates the DOM representation of this ConfigurationElement for the list of attributes and elements defined in the given ElementSource. Note that the resulting Element will not be associated with the Document parameter. It is important to ensure that all DOM trees have a Document root as some serializers do not behave correctly otherwise.
      • exportAttributesToXML

        protected void exportAttributesToXML​(org.w3c.dom.Element element,
                                             ConfigurationSource source)
        Appends the list of attributes of this ConfigurationElement into the given node. The list is filter to include only attributes defined in the given ElementSource. If sourceKey is null, it appends the list of attributes merged from all ElementSources.
      • exportElementsToXML

        protected void exportElementsToXML​(org.w3c.dom.Element element,
                                           ConfigurationSource source)
        Appends the list of child-elements of this ConfigurationElement into the given node. The list is filter to include only elements defined in the given ElementSource. If sourceKey is null, it appends the list of elements merged from all ElementSources.
      • exportNodeValueToXML

        protected void exportNodeValueToXML​(org.w3c.dom.Element element,
                                            ConfigurationSource source)
        Appends the node value associated with the given source key into the given node. If sourceKey is null, it appends the current node value.
      • toString

        public java.lang.String toString()
        Generates the String representation of this ConfigurationElement.
        Overrides:
        toString in class java.lang.Object
      • printAttributes

        protected void printAttributes​(java.lang.StringBuffer outString)
        Appends the list of attributes of this ConfigurationElement into the given StringBuffer. It includes the list attributes merged from all ElementSources.
      • printElements

        protected void printElements​(java.lang.StringBuffer outString)
        Appends the list of child-elements of this ConfigurationElement into the given StringBuffer. It appends the list of elements merged from all ElementSources.
      • printNodeValue

        protected void printNodeValue​(java.lang.StringBuffer outString)
        Appends the node value into the given StringBuffer. It appends the node value of elements merged from all ElementSources.
      • load

        public void load​(java.lang.String fileName)
                  throws ConfigException
        Loads the file with the given name and initializes this ConfigurationElement with its content.
        Specified by:
        load in interface ConfigurationFile
        Parameters:
        fileName - The path to the configuration file. This path will be resolved by the FileLoader
        Throws:
        ConfigException
      • reloadPrototype

        protected void reloadPrototype()
        Loops through all the ElementSource of this ConfigurationElement and reloads the content of those whose underlying configuration file has changed.
      • original

        public final AbstractConfigurationElement original()
        Returns a new instance of this object, populated only with the out of the box values of Microstrategy Web, that is, only default values or those that came from the load method. Values from customizations or programatic changes are not included.

      • deltas

        public final AbstractConfigurationElement deltas()
        Returns the deltas between the original() and this objects. The returned value therefore includes all changes to this object after it was loaded; this includes both programatic changes and plugins changes.
        See Also:
        original(), deltas()
      • deltas

        public AbstractConfigurationElement deltas​(AbstractConfigurationElement other)

        Returns a partial instance of this object that contains the attributes and elements required to make this object equals to the other paramter. It is used to identify the differences between the two instances of this class.

        Being a partial instance, the resulting delta includes strictly those attributes and elements required to make it equal to the other object; typically default attributes and elements are not included so its possible that getter methods for properties and/or chidlren will return null.

        Notice that if both x and y are AbstractConfigurationElement, and
        x != y
        , then
         d = x.deltas(y)
         x + d = y
         
        Or programatically:
         if (!x.equals(y)) {
           AbstractConfigurationElement d = x.deltas(y);
           x.populates(d).equals(y); //returns true
         }
         
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
        Returns:
        a new instance of this object with the same values.
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • equalsIncludingDeletedElements

        public boolean equalsIncludingDeletedElements​(java.lang.Object object)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • hashCodeAtts

        protected int hashCodeAtts()
        Returns the hashcode for attributes.
      • hashCodeElements

        protected int hashCodeElements()
        Returns the hashcode for attributes.
      • hashCodeNodeValues

        protected int hashCodeNodeValues()
        Returns the hashcode for attributes.
      • equalAtts

        protected boolean equalAtts​(AbstractConfigurationElement other)
        Returns true if the list of active attributes of the given AbstractConfigurationElement is equal to this list of active attributes of this AbstractConfigurationElement.
      • equalElements

        protected boolean equalElements​(AbstractConfigurationElement other)
        Returns true if the list of all child elements of the given AbstractConfigurationElement is equal to this list of all child-elements of this AbstractConfigurationElement.
      • equalNodeValues

        protected boolean equalNodeValues​(AbstractConfigurationElement other)
        Returns true if the node value of both configuration elements is the same.
      • setFileLoader

        public void setFileLoader​(FileLoader fl)
        Sets the FileLoader instance to be used to load files. This method is typically used to set a different root folder for relative paths. Normally, all relative paths (for example "/WEB-INF/web.xml") are relative to the application's root folder, to change this root folder users can create a new FileLoader instance and set it to this ConfigurationElement, then relative paths are resolved relative to the new FileLoader base path, for example:
        FileLoader fl = new FileLoader("C:\\Temp"); PagaManager pm = new PageManager(); pm.load("/WEB-INF/xml/pageConfig.xml", true);
        In the previous sample, "/WEB-INF/xml/pageConfig.xml" is resolved to C:\Temp\WEB-INF\xml\pageConfig.xml as the FileLoader's base path is "C:\Temp"
      • populate

        public ConfigurationElement populate​(ConfigurationElement other)
        This method takes another configuration element and populates this element with the other's attributes and child-elements. Existing values are merged in this process. After this method is called, attributes and elements from the other will be available in this element.
        Returns:
        this same object.
      • getChildKey

        protected java.lang.Object getChildKey​(org.w3c.dom.Node node)
        Returns the key that uniquely identifies the child element associated with the given Node.
      • getNextKey

        public java.lang.Object getNextKey()
        Returns an object that can be used as key for a list of child-elements that doesn't have a key by itself.