Class AbstractParameterBuilder

  • All Implemented Interfaces:
    ParameterBuilder
    Direct Known Subclasses:
    AbstractConfigurableParameterBuilder

    public abstract class AbstractParameterBuilder
    extends java.lang.Object
    implements ParameterBuilder
    An abstract implementation for ParameterBuilder which stores all information supplied, but is unable to convert it to a string. Each subclass implements the toString and the isEmpty methods.
    Since:
    MicroStrategy Web 8.0.0
    • Field Detail

      • _targetPrefix

        protected java.lang.String _targetPrefix
        The Target Prefix
      • _targetBase

        protected java.lang.String _targetBase
        The Target Base
      • _targetSuffix

        protected java.lang.String _targetSuffix
        The Target Suffix
      • _parameters

        protected Parameters _parameters
        An array of key/value pairs that were added...
      • _initialSize

        protected int _initialSize
        The initial size of the buffer to hold the ParameterBuilder contents...
    • Constructor Detail

      • AbstractParameterBuilder

        public AbstractParameterBuilder()
    • Method Detail

      • init

        public void init​(java.lang.Object parent)
        Initializes this class by attaching up a namespace encoder (as provided by the parent).
        Specified by:
        init in interface ParameterBuilder
        Parameters:
        parent - The enclosing parent for this ParameterBuilder instance.
      • setInitialSize

        public void setInitialSize​(int chars)
        The initial size of the ParameterBuilder in number of characters.
        Specified by:
        setInitialSize in interface ParameterBuilder
        Parameters:
        chars - A rough estimate of the total number of characters added in all key/value pairs.
      • addParameter

        public void addParameter​(java.lang.String name,
                                 java.lang.String value)
        Add a name/value pair.
        Specified by:
        addParameter in interface ParameterBuilder
        Parameters:
        name - The name of a WebEvent element.
        value - The value of a WebEvent element.
      • addParameterUnique

        public void addParameterUnique​(java.lang.String name,
                                       java.lang.String value,
                                       boolean overwrite)
        DE191250: Unexpected behaviors when parameters are added multiple time by mistake Add a non-repeated unique key/value pair.
        Specified by:
        addParameterUnique in interface ParameterBuilder
        Parameters:
        name - The name of a WebEvent element.
        value - The value of a WebEvent element.
        overwrite - Whether to overwrite the value when the key is already in the WebEvent Parameters
      • getTargetPrefix

        public java.lang.String getTargetPrefix()
        Returns the target prefix supplied to this ParameterBuilder via setTargetPrefix(java.lang.String). If none was supplied, then this method returns null. A prefix is often to use to prepend an absolute path to a relative one. If supplied, it will be added directly before the target base.
        Specified by:
        getTargetPrefix in interface ParameterBuilder
        Returns:
        The value supplied by the caller in the last call to setTargetPrefix(java.lang.String). If never called, it returns null.
      • setTargetBase

        public void setTargetBase​(java.lang.String targetBase)
        Specify a target base URI (for URL generation). In the event that this ParameterBuilder is used to build a URI, then the supplied string should be used as the base URI (with all key/value pairs added after an initial '?'). This method works in conjunction with setTargetPrefix(java.lang.String) and setTargetSuffix(java.lang.String). When a string form of the ParameterBuilder object is requested (via #toString), then targetURI (if present) is added to the string along with a prefix or suffix. If a target was not supplied, then neither prefix or suffix will be added to the string (even if they are non-empty).
        Specified by:
        setTargetBase in interface ParameterBuilder
        Parameters:
        targetBase - The base URI to be used for this set of key/value pairs.
        See Also:
        setTargetPrefix(java.lang.String), setTargetSuffix(java.lang.String)
      • setTargetPrefix

        public void setTargetPrefix​(java.lang.String targetPrefix)
        Specifies a prefix string to appear before the Target Base. A prefix is often to use to prepend an absolute path to a relative one. If supplied, it will be added directly before the target base (without any other characters). This string is not added if the TargetBase has not been explicitly set.
        Specified by:
        setTargetPrefix in interface ParameterBuilder
        Parameters:
        targetPrefix - A string to be prepended to the Target Base.
        See Also:
        setTargetBase(java.lang.String)
      • setTargetSuffix

        public void setTargetSuffix​(java.lang.String targetSuffix)
        Specifies a suffix string to appear after the Target Base. A suffix is often to use to append extra path information or extra parameters (e.g., ";key=value"). If supplied, it will be added directly after the target base (without any other characters). This string is not added if the TargetBase has not been explicitly set.
        Specified by:
        setTargetSuffix in interface ParameterBuilder
        Parameters:
        targetSuffix - A string to be appended to the Target Base.
        See Also:
        setTargetBase(java.lang.String)
      • getParameters

        public java.util.Iterator getParameters()
        Return an iterator for the list of parameters.
        Returns:
        An iterator on the supplied parameters.
      • parseURLParameterFragment

        protected void parseURLParameterFragment​(java.lang.String fragment)
        This method parses a string fragment that is believed to contain only URL parameters ("...&key1=value1&..."). The fragment is first tokenized by the ampersand character (to yield a key/value pair separated by '='). Next, each pair is tokenized by the equals sign and broken into a key and value. Each pair is then saved using addParameter(java.lang.String, java.lang.String).
        Parameters:
        fragment - A string representing a set of URL parameters.
      • areAllBitsSet

        public static boolean areAllBitsSet​(int intVal,
                                            int bits)
        Determines whether the specified integer value has set all its bits specified through the the parameter bits.
        Parameters:
        intVal - an integer value whose bits to be checked
        bits - the bits to check
        Returns:
        true if all bits specified through the parameter bits are set in the specified integer value intVal.
      • isAnyBitSet

        public static boolean isAnyBitSet​(int intVal,
                                          int bits)
        Determines whether the specified integer value has set any bit specified through the the parameter bits.
        Parameters:
        intVal - an integer value whose bits to be checked
        bits - the bits to check
        Returns:
        true if any bit specified through the parameter bits is set in the specified integer value intVal.
      • addEventInfo

        public void addEventInfo​(WebEvent event,
                                 int eventElements,
                                 int howMuchChildState)
        Adds into the current object the event information in the format of key/value pairs.
        Specified by:
        addEventInfo in interface ParameterBuilder
        Parameters:
        event - the event whose information to be added.
        eventElements - A bit mask value composed of constants from EnumEventElement. These determine what elements of the event is added.
        howMuchChildState - If children state is to be added, this parameter (whose values come from EnumWebPersistableState) determines how much state.
      • parseEntireURLStringFragment

        protected void parseEntireURLStringFragment​(java.lang.String fragment)
        This method parses a string fragment that is belived to contain an entire URL (base URI plus zero or more parameters). If the base URI is found (which is any non-empty string before the first '?' character), then it is added via setTargetBase(java.lang.String). The remaining string is parsed via parseURLParameterFragment(java.lang.String).
        Parameters:
        fragment - A string representing a complete URL.