Package com.microstrategy.web.platform
Class AbstractParameterBuilder
- java.lang.Object
-
- com.microstrategy.web.platform.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 Summary
Fields Modifier and Type Field Description protected int
_initialSize
The initial size of the buffer to hold the ParameterBuilder contents...protected NamespaceEncoder
_namespaceEncoder
A storedNamespaceEncoder
instance which is managed by this class.protected Parameters
_parameters
An array of key/value pairs that were added...protected java.lang.String
_targetBase
The Target Baseprotected java.lang.String
_targetPrefix
The Target Prefixprotected java.lang.String
_targetSuffix
The Target Suffix
-
Constructor Summary
Constructors Constructor Description AbstractParameterBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventInfo(WebEvent event, int eventElements, int howMuchChildState)
Adds into the current object the event information in the format of key/value pairs.void
addParameter(java.lang.String name, java.lang.String value)
Add a name/value pair.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.static boolean
areAllBitsSet(int intVal, int bits)
Determines whether the specified integer value has set all its bits specified through the the parameterbits
.NamespaceEncoder
getNamespaceEncoder()
The currentNamespaceEncoder
associated with this ParameterBuilder.java.util.Iterator
getParameters()
Return an iterator for the list of parameters.java.lang.String
getTargetBase()
Returns the target base supplied to this ParameterBuilder viasetTargetBase(java.lang.String)
.java.lang.String
getTargetPrefix()
Returns the target prefix supplied to this ParameterBuilder viasetTargetPrefix(java.lang.String)
.java.lang.String
getTargetSuffix()
Returns the target suffix supplied to this ParameterBuilder viasetTargetSuffix(java.lang.String)
.void
init(java.lang.Object parent)
Initializes this class by attaching up a namespace encoder (as provided by the parent).static boolean
isAnyBitSet(int intVal, int bits)
Determines whether the specified integer value has set any bit specified through the the parameterbits
.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).protected void
parseURLParameterFragment(java.lang.String fragment)
This method parses a string fragment that is believed to contain only URL parameters ("...&key1=value1&...").void
setInitialSize(int chars)
The initial size of theParameterBuilder
in number of characters.void
setNamespaceEncoder(NamespaceEncoder nse)
Assign the suppliedNamespaceEncoder
to this ParameterBuilder instance.void
setTargetBase(java.lang.String targetBase)
Specify a target base URI (for URL generation).void
setTargetPrefix(java.lang.String targetPrefix)
Specifies a prefix string to appear before the Target Base.void
setTargetSuffix(java.lang.String targetSuffix)
Specifies a suffix string to appear after the Target Base.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microstrategy.web.platform.ParameterBuilder
addFragment, isEmpty, toString
-
-
-
-
Field Detail
-
_namespaceEncoder
protected NamespaceEncoder _namespaceEncoder
A storedNamespaceEncoder
instance which is managed by this class.
-
_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...
-
-
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 interfaceParameterBuilder
- Parameters:
parent
- The enclosing parent for this ParameterBuilder instance.
-
setInitialSize
public void setInitialSize(int chars)
The initial size of theParameterBuilder
in number of characters.- Specified by:
setInitialSize
in interfaceParameterBuilder
- Parameters:
chars
- A rough estimate of the total number of characters added in all key/value pairs.
-
getNamespaceEncoder
public NamespaceEncoder getNamespaceEncoder()
The currentNamespaceEncoder
associated with this ParameterBuilder.- Specified by:
getNamespaceEncoder
in interfaceParameterBuilder
- Returns:
- The
NamespaceEncoder
associated with this ParameterBuilder.
-
setNamespaceEncoder
public void setNamespaceEncoder(NamespaceEncoder nse)
Assign the suppliedNamespaceEncoder
to this ParameterBuilder instance.- Specified by:
setNamespaceEncoder
in interfaceParameterBuilder
- Parameters:
nse
- TheNamespaceEncoder
instance to use with this ParameterBuilder.
-
addParameter
public void addParameter(java.lang.String name, java.lang.String value)
Add a name/value pair.- Specified by:
addParameter
in interfaceParameterBuilder
- 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 interfaceParameterBuilder
- 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
-
getTargetBase
public java.lang.String getTargetBase()
Returns the target base supplied to this ParameterBuilder viasetTargetBase(java.lang.String)
. If none was supplied, then this method returnsnull
.- Specified by:
getTargetBase
in interfaceParameterBuilder
- Returns:
- The value supplied by the caller in the last call to
setTargetBase(java.lang.String)
. If never called, it returnsnull
.
-
getTargetPrefix
public java.lang.String getTargetPrefix()
Returns the target prefix supplied to this ParameterBuilder viasetTargetPrefix(java.lang.String)
. If none was supplied, then this method returnsnull
. 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 interfaceParameterBuilder
- Returns:
- The value supplied by the caller in the last call to
setTargetPrefix(java.lang.String)
. If never called, it returnsnull
.
-
getTargetSuffix
public java.lang.String getTargetSuffix()
Returns the target suffix supplied to this ParameterBuilder viasetTargetSuffix(java.lang.String)
. If none was supplied, then this method returnsnull
.- Specified by:
getTargetSuffix
in interfaceParameterBuilder
- Returns:
- The value supplied by the caller in the last call to
setTargetSuffix(java.lang.String)
. If never called, it returnsnull
.
-
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 withsetTargetPrefix(java.lang.String)
andsetTargetSuffix(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 interfaceParameterBuilder
- 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 interfaceParameterBuilder
- 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 interfaceParameterBuilder
- 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 usingaddParameter(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 parameterbits
.- Parameters:
intVal
- an integer value whose bits to be checkedbits
- the bits to check- Returns:
true
if all bits specified through the parameterbits
are set in the specified integer valueintVal
.
-
isAnyBitSet
public static boolean isAnyBitSet(int intVal, int bits)
Determines whether the specified integer value has set any bit specified through the the parameterbits
.- Parameters:
intVal
- an integer value whose bits to be checkedbits
- the bits to check- Returns:
true
if any bit specified through the parameterbits
is set in the specified integer valueintVal
.
-
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 interfaceParameterBuilder
- Parameters:
event
- the event whose information to be added.eventElements
- A bit mask value composed of constants fromEnumEventElement
. These determine what elements of the event is added.howMuchChildState
- If children state is to be added, this parameter (whose values come fromEnumWebPersistableState
) 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 viasetTargetBase(java.lang.String)
. The remaining string is parsed viaparseURLParameterFragment(java.lang.String)
.- Parameters:
fragment
- A string representing a complete URL.
-
-