Class ReplaceInterfacesStorage


  • public class ReplaceInterfacesStorage
    extends java.lang.Object
    Storage for replace interfaces.
    Since:
    7.0.0
    Version:
    $Revision: 24803 $ $Date: 2022-01-17 17:30:07 -0300 (Mon, 17 Jan 2022) $
    • Constructor Summary

      Constructors 
      Constructor Description
      ReplaceInterfacesStorage​(java.lang.String replaceInterfacesStr)
      Constructs a new storage with the given string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getBaseItemForItem​(java.lang.String item)
      Returns the base item (root item) that is being replaced for the given item.
      java.util.Map<java.lang.String,​java.lang.String> getMap()
      Returns the replace map.
      protected java.lang.String getReplaceInterfaceParametersParameterName()  
      java.lang.String getStackTopByExistentItem​(java.lang.String item)
      Returns the top of replace stack by a given item.
      java.lang.String getStateString()
      Returns the state of replace interface information as a string in the format for PortalRequestParameters.PAGE_PARAMETER_REPLACE_INTERFACES_STATE.
      java.lang.String handleReplaceInterfaceOperations​(java.lang.String currentInterfaceInstanceId, java.lang.String[] replaceInterfaceOperations, PortalRequestParameters parameters)
      Handles the replace interface commands.
      java.lang.String put​(java.lang.String source, java.lang.String target)
      Creates a new replace mapping source -> target.
      java.lang.String remove​(java.lang.String item)
      Removes the given interface instance from the replace map (searching it as the mapping key).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReplaceInterfacesStorage

        public ReplaceInterfacesStorage​(java.lang.String replaceInterfacesStr)
                                 throws java.io.UnsupportedEncodingException
        Constructs a new storage with the given string.

        The string must be formatted as following:
        originInterfaceInstance=destinationInterfaceInstance(;originInterfaceInstance=destinationInterfaceInstance)*
        Where:

        • originInterfaceInstance is the original interface instance.
        • destinationInterfaceInstance is the interface instance that is replacing the original one.

        If the given string is null or empty no interface instance is being replaced.
        Parameters:
        replaceInterfacesStr - the string of replaces.
        Throws:
        java.io.UnsupportedEncodingException
        Since:
        7.0.0
    • Method Detail

      • getMap

        public java.util.Map<java.lang.String,​java.lang.String> getMap()
        Returns the replace map.
        Returns:
        the replace map.
        Since:
        7.0.0
      • getStackTopByExistentItem

        public java.lang.String getStackTopByExistentItem​(java.lang.String item)
        Returns the top of replace stack by a given item.
        Parameters:
        item - the item used to search in the map.
        Returns:
        the top of replace stack by a given item.
        Since:
        7.0.0
      • getBaseItemForItem

        public java.lang.String getBaseItemForItem​(java.lang.String item)
        Returns the base item (root item) that is being replaced for the given item.
        Parameters:
        item - the item used to search in the map.
        Returns:
        the base item.
        Since:
        7.1.1
      • remove

        public java.lang.String remove​(java.lang.String item)
        Removes the given interface instance from the replace map (searching it as the mapping key).
        Parameters:
        item - the item to be removed.
        Returns:
        the result of Map.remove(Object).
        Since:
        7.0.0
      • put

        public java.lang.String put​(java.lang.String source,
                                    java.lang.String target)
        Creates a new replace mapping source -> target.
        Parameters:
        source - the interface instance that is going to be replaced.
        target - the interface instance that is going to replace.
        Returns:
        the result of Map.put(Object, Object).
        Since:
        7.0.0
      • handleReplaceInterfaceOperations

        public java.lang.String handleReplaceInterfaceOperations​(java.lang.String currentInterfaceInstanceId,
                                                                 java.lang.String[] replaceInterfaceOperations,
                                                                 PortalRequestParameters parameters)
                                                          throws PortalException
        Handles the replace interface commands. Also applies the properly parameters in PortalRequestParameters if needed. Returns the result interface instance after the commands are applied. The commands are formatted in a string array. Each command string may have multiple commands separated by a ',' character.

        The supported commands are:

        • r: removes the current interface instance from the replaces map. After this command is executed, the current interface instance becomes the one that it was replacing.
          In other words, if the current interface instance is II-2, there is an interface instance II-1 such that II-2 is replacing II-1 and a command r is executed, the current interface instance becomes II-1.
        • a: this command adds a new replace mapping. It must be followed by the interface instance that is going to replace the current interface instance. After this command is executed, the current interface instance becomes the given one.
          In other words, if II-1 is the current interface instance and the command aII-2 is executed, the interface instance II-2 replaces the interface instance II-1 and II-2 becomes the current interface instance.

        Parameters:
        currentInterfaceInstanceId - the current interface instance.
        replaceInterfaceOperations - the replace commands array.
        parameters - the replace interface parameters.
        Returns:
        the result interface instance after the commands are applied.
        Throws:
        PortalException
        Since:
        7.0.0
      • getReplaceInterfaceParametersParameterName

        protected java.lang.String getReplaceInterfaceParametersParameterName()