Package com.microstrategy.web.blocks
Class Block
- java.lang.Object
-
- com.microstrategy.web.blocks.BlockTarget
-
- com.microstrategy.web.blocks.BlockListElement
-
- com.microstrategy.web.blocks.Block
-
- All Implemented Interfaces:
java.io.Serializable
public class Block extends BlockListElement
This class represents a generic Block. A Block essentially consists of a set of PROPERTIES and a RENDERER. It also has a NAME which is used by the FACTORY. It is essentially a specialized DATA CONTAINER with a well-defined way to RENDER its contents through a generic RENDERER interface.- Since:
- MicroStrategy Web 8.1.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.microstrategy.web.blocks.BlockListElement
BlockListElement.ListAction
-
Nested classes/interfaces inherited from class com.microstrategy.web.blocks.BlockTarget
BlockTarget.PathInfo
-
-
Field Summary
-
Fields inherited from class com.microstrategy.web.blocks.BlockTarget
TARGETTYPE_BLOCK, TARGETTYPE_LIST, TARGETTYPE_PROPERTY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(BlockVisitor visitor)
Accept a BlockVisitor to this Block.void
accept(BlockVisitor visitor, java.util.Comparator<BlockProperty> blockPropertyComparator)
Accept a BlockVisitor to this Block.BlockProperty
defineProperty(java.lang.String name, java.lang.String type)
Defines a new property for a Block.MarkupOutput
generateMarkup(BlockContext blockContext)
Generate the markup for this Block using the RENDERER instance (or fully qualified class name)..BlockPropertyAnnotationGroups
getAnnotationGroups(boolean create)
Returns the annotation groups associated with this Block.java.util.Iterator<java.lang.String>
getBaseBlocks(boolean expand)
Returns anIterator
of Block names: either just the directly specified base Blocks (expand == false) or all base Blocks (expand == true).java.lang.String
getFileName()
Returns the file name where the Block was read from.java.lang.String
getName()
Returns the name of this Block.BlockProperty
getOrCreateProperty(java.lang.String propName, java.lang.String propType)
Returns a property whose name is 'propName'.BlockProperty
getProperty(java.lang.String name)
Returns the Property with a given name.BlockProperty
getPropertyByIndex(int index)
Returns the Property at a given numeric index.int
getPropertySize()
Returns the number of properties in this Block.boolean
hasAnnotationGroups()
Returns whether there are any annotation groups associated with this Block.boolean
propertyExists(java.lang.String name)
Returns true if a property with a specific name exists.void
put(java.lang.String propName, boolean propValue)
Sets property value.void
put(java.lang.String propName, double propValue)
Sets property value.void
put(java.lang.String propName, int propValue)
Sets property value.void
put(java.lang.String propName, long propValue)
Sets property value.void
put(java.lang.String propName, Block propValue)
Sets property value.void
put(java.lang.String propName, BlockList propValue)
Sets property value.void
put(java.lang.String propName, java.lang.String propValue)
Sets property value.Block
putNewBlock(java.lang.String propName)
Block
putNewBlock(java.lang.String propName, java.lang.String blockName)
BlockList
putNewList(java.lang.String propName)
void
setName(java.lang.String name)
Sets the name of this Block.BlockProperty
setOrCreateProperty(java.lang.String propName, java.lang.String propType, java.lang.Object propValue)
Sets a property (creating it, if necessary) to a specific value.java.lang.String
toString()
-
Methods inherited from class com.microstrategy.web.blocks.BlockListElement
getListAction, getListElementKey, getListItem, setListAction, setListElementKey, setListItem, setListItem
-
Methods inherited from class com.microstrategy.web.blocks.BlockTarget
findProperties, getTargetType, resolvePath, resolvePath
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this Block.- Returns:
- The name of this Block.
-
setName
public void setName(java.lang.String name)
Sets the name of this Block.- Parameters:
name
- The name of this Block.
-
getPropertySize
public int getPropertySize()
Returns the number of properties in this Block.- Returns:
- The number of properties in this Block.
-
defineProperty
public BlockProperty defineProperty(java.lang.String name, java.lang.String type) throws java.lang.Exception
Defines a new property for a Block.- Parameters:
name
- The name of the property.type
- The type of the property.- Returns:
- The newly created
BlockProperty
. - Throws:
java.lang.Exception
- If the property is already defined.- Since:
- MicroStrategy Web 9.0.0
-
propertyExists
public boolean propertyExists(java.lang.String name)
Returns true if a property with a specific name exists.- Parameters:
name
- The name of the property to check for.- Returns:
- True, if the property exists; otherwise, false.
-
getProperty
public BlockProperty getProperty(java.lang.String name)
Returns the Property with a given name.- Parameters:
name
- The name of the property to return.- Returns:
- The
BlockProperty
object with the specified name, if it exists. If it does not exist, then returns null.
-
getOrCreateProperty
public BlockProperty getOrCreateProperty(java.lang.String propName, java.lang.String propType)
Returns a property whose name is 'propName'. If it does not exist, then create that property (whose type is 'propType').- Parameters:
propName
- The name of the property that you want to get (or create).propType
- The type of the property (a value of one of the PROPTYPE_Xxx constants inBlockProperty
).- Returns:
- The
BlockProperty
that you wanted to access. - Since:
- MicroStrategy Web 9.0.0
- See Also:
getProperty(String)
,defineProperty(String, String)
-
put
public void put(java.lang.String propName, int propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, java.lang.String propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, long propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, double propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, boolean propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, Block propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
put
public void put(java.lang.String propName, BlockList propValue)
Sets property value. If the property is not present then it will be created.- Parameters:
propName
- The property namepropValue
- The property value
-
putNewBlock
public Block putNewBlock(java.lang.String propName)
-
putNewBlock
public Block putNewBlock(java.lang.String propName, java.lang.String blockName) throws java.lang.Exception
- Throws:
java.lang.Exception
-
putNewList
public BlockList putNewList(java.lang.String propName)
-
setOrCreateProperty
public BlockProperty setOrCreateProperty(java.lang.String propName, java.lang.String propType, java.lang.Object propValue)
Sets a property (creating it, if necessary) to a specific value.- Parameters:
propName
- The name of the property to set.propType
- The type of the property fromEnumBlockPropertyTypes
propValue
- The value of the property.- Returns:
- The
BlockProperty
object that was set (or created). - Since:
- MicroStrategy Web 9.0.0
- See Also:
defineProperty(String, String)
,getProperty(String)
-
getPropertyByIndex
public BlockProperty getPropertyByIndex(int index)
Returns the Property at a given numeric index.- Parameters:
index
- The index of the Property to return (first index=0).- Returns:
- The
BlockProperty
object at the specified index, if it exists. If it does not exist, then an IllegalArgumentException is thrown. - Throws:
java.lang.IllegalArgumentException
- If the index is out of range.
-
generateMarkup
public MarkupOutput generateMarkup(BlockContext blockContext) throws java.lang.Exception
Generate the markup for this Block using the RENDERER instance (or fully qualified class name)..- Parameters:
blockContext
- TheBlockContext
that defines information about how Blocks are constructed, expanded and serialized.- Returns:
- A
MarkupOutput
object containing the markup generated for this Block. - Throws:
java.lang.Exception
- If we are unable to create an instance of the desired RENDERER or there is an exception in the process of generating the markup.- Since:
- MicroStrategy Web 9.0.0
-
getBaseBlocks
public java.util.Iterator<java.lang.String> getBaseBlocks(boolean expand)
Returns anIterator
of Block names: either just the directly specified base Blocks (expand == false) or all base Blocks (expand == true).- Parameters:
expand
- Whether or not to expand the list of Block names to all indirectly accessible Blocks or just the direct ones.- Returns:
- An
Iterator
of Block names.
-
getFileName
public java.lang.String getFileName()
Returns the file name where the Block was read from.- Returns:
- The file name where the Block was read from.
- Since:
- MicroStrategy Web 9.0.0
-
accept
public void accept(BlockVisitor visitor)
Accept a BlockVisitor to this Block. The visitor is notified in the following way:- First, at the start of the Block
BlockVisitor.visitBlockStart(Block, BlockTarget)
- If the return value of
BlockVisitor.visitBlockStart(Block, BlockTarget)
is true, then each of the BlockProperties are visited. - Finally, at the end of the Block
BlockVisitor.visitBlockEnd(Block, BlockTarget)
.
- Parameters:
visitor
- TheBlockVisitor
instance which will visit this Block.- Since:
- MicroStrategy Web 9.0.0
- First, at the start of the Block
-
accept
public void accept(BlockVisitor visitor, java.util.Comparator<BlockProperty> blockPropertyComparator)
Accept a BlockVisitor to this Block. The visitor is notified in the following way:- First, at the start of the Block
BlockVisitor.visitBlockStart(Block, BlockTarget)
- If the return value of
BlockVisitor.visitBlockStart(Block, BlockTarget)
is true, then each of the BlockProperties are visited. - Finally, at the end of the Block
BlockVisitor.visitBlockEnd(Block, BlockTarget)
. - However, the order of the BlockProperty instances is defined by the supplied Comparator instance
- Parameters:
visitor
- TheBlockVisitor
instance which will visit this Block.blockPropertyComparator
- TheXmlRendererANF.BlockPropertyComparator
instance which will be used to compare the block property.- Since:
- MicroStrategy Web 9.0.1
- First, at the start of the Block
-
hasAnnotationGroups
public boolean hasAnnotationGroups()
Returns whether there are any annotation groups associated with this Block.- Returns:
- Whether there are any annotation groups associated with this Block.
-
getAnnotationGroups
public BlockPropertyAnnotationGroups getAnnotationGroups(boolean create)
Returns the annotation groups associated with this Block.- Parameters:
create
- If no annotation groups exists, this indicates whether a new set should be created.- Returns:
- A
BlockPropertyAnnotationGroups
object (if it exists or the caller set 'create' to true); otherwise it is null.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-