Class 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
    • 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 in BlockProperty).
        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 name
        propValue - 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 name
        propValue - 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 name
        propValue - 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 name
        propValue - 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 name
        propValue - 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 name
        propValue - 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 name
        propValue - 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 from EnumBlockPropertyTypes
        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 - The BlockContext 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 an Iterator 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
      • 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 class java.lang.Object