com.adventnet.html.staticssi
Class StaticUtil

java.lang.Object
  extended by com.adventnet.html.staticssi.StaticUtil

public class StaticUtil
extends java.lang.Object

In the case of HTTP communcation, the displayed html page can be generated in two ways.

          1. Dynamic Html Page generation.

          2. Customized Html Page generation using SSI tags.

In the first case the user don't need to type any html file for his instrumentation. The HtmlMain and DynamicHtml classes will generate dynamic html files and take care of all the necessary operations like modify value, create value, etc.

In the second case, using the .shtml files generated from the MibCompiler that contains required ssi tags to display the instrumented information, the user can customize the html pages.

This class is the common class to handle both type of html generation. The servlet should create an instance of this class and invoke corresponding functions from here.

See Also:
com.adventnet.ssiparser.HtmlParser, com.adventnet.ssiparser.DynamicHtml

Field Summary
static int CANCEL
          If cancel button is invoked from the client
static int DELETE_ROW
           
static int DO_GET
          If get or refresh button is invoked from the client
static int DO_OPER
          If Get Operation is performed on the Attribute
(package private) static int endIndex
           
(package private)  boolean isNextButtonNeeded
           
(package private)  boolean isPrevButtonNeeded
           
(package private) static Log log
          Logger used to log the error,debug,trace messages, etc
static int NEW_ROW
          If new row button is invoked from the client
static int NEXT_ROW
           
(package private)  boolean nextRowFlag
           
 java.lang.String page
           
static int POST_ERROR
          If any error in the post
static int PREV_ROW
           
(package private)  boolean prevRowFlag
           
static int REFRESH
          If refresh button is invoked from the client
(package private) static int stIndex
           
 
Constructor Summary
StaticUtil(ServerOperations serverOp)
          Default Constructor for HtmlMain.
 
Method Summary
 void addFormAndTableTags(java.lang.StringBuffer strBuf, javax.management.ObjectName objName, boolean isDynamicHtmlPage, java.lang.String varName, java.lang.String searchAttrbName)
          Add the starting tags for form and table.
static java.lang.String convertArrayToString(java.lang.String attrbType, java.lang.Object attrbValue)
          Method to convert the given attrbValue into string.
static void createAttrbNameAccessTypeVector(java.lang.Object mbean, java.util.Vector variable, java.util.Vector access, java.util.Vector type)
          Create vectors for attribute names, their access and their basic data types from the xml file.
 javax.jmx.openmbean.CompositeData[] createCompositeDataForModifyOrDelete(java.util.Hashtable table, java.lang.String objName, boolean modifyFlag)
           
 boolean createTable(java.lang.StringBuffer strBuf, java.lang.Object obj, javax.management.ObjectName objName, java.lang.Object mbean, boolean isDynamicHtmlPage, int sIndex, int eIndex, boolean implementsModelListener)
          If the given attribute is table then this function will be called to generate html table.
 void createTableHeader(java.util.Vector ve, java.util.Vector type, java.lang.StringBuffer strBuf)
           
 boolean createTableRow(java.util.Vector varVect, java.util.Vector valVect, java.util.Vector typeVect, java.lang.String indexes, java.util.Vector accessVec, java.lang.StringBuffer strBuf, java.lang.String varName)
          Used to create a dynamic row in the HTML table.
 javax.jmx.openmbean.TabularData createTabularDataForModifyOrDelete(java.util.Hashtable table, java.lang.String objName, boolean modifyFlag)
           
 java.lang.String getAttributeValue(java.lang.String name, java.lang.String searchAttrbName, java.lang.Object searchAttrbValue, boolean isForSetMethod, boolean isDynamicHtmlPage, boolean fromSetAttributeValue)
          It will retrieve or update the MBean's attributes with the given parameters from the client.
 java.lang.String getFilter()
          Getter for the filter value.
(package private) static java.util.Hashtable getHeaderTable()
           
 HtmlParser getHtmlParser()
          Return the HtmlParser object reference.
(package private) static java.lang.Object getMBean(java.lang.String objName)
          Getter for the MBean.
 java.lang.String getNotifTable()
           
static boolean isTable(java.lang.String name)
           
 void registerMBean(java.lang.String domain, java.lang.String keys, java.lang.String className, java.lang.String loader, java.lang.String xmlFile)
          It is used to instantiate and register an MBean from the browser.
 int setAttributeValue(java.util.Hashtable table)
          It is used to set the attributes value received from the client(browser).
 java.lang.String setAttributeValue(java.lang.String objName, java.lang.String searchAttrbName, java.lang.String searchAttrbValue)
          It will update the MBean's attribute with the given value from the client.
 void setEndIndex(int value)
           
 void setFilter(java.lang.String filter)
          Setter for the filter value.
 void setHtmlPageProp(HtmlPageProp htmlPageProp)
           
 void setNextRow(boolean flag)
           
 void setOperationsButtonNeeded(boolean value)
           
 void setPrevRow(boolean flag)
           
 void setRefreshTime(int time)
          Setter for the refresh time.
 int setScalarValues(java.util.Hashtable table, java.util.Hashtable hashtable, java.lang.String objName, boolean isTable)
           
 void setServletName(java.lang.String name)
          Method to set the servlet name.
 void setStartIndex(int value)
           
 int setTableValues(java.util.Hashtable table, java.lang.String objName, boolean implementsModelListener, boolean addRowFlag, boolean deleteRowFlag)
           
 void unregisterMBean(java.lang.String domain, java.lang.String keys)
          It is used to unregister an MBean from the MBeanServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static Log log
Logger used to log the error,debug,trace messages, etc


CANCEL

public static int CANCEL
If cancel button is invoked from the client


DO_GET

public static int DO_GET
If get or refresh button is invoked from the client


NEW_ROW

public static int NEW_ROW
If new row button is invoked from the client


DELETE_ROW

public static int DELETE_ROW

NEXT_ROW

public static int NEXT_ROW

PREV_ROW

public static int PREV_ROW

nextRowFlag

boolean nextRowFlag

prevRowFlag

boolean prevRowFlag

isNextButtonNeeded

boolean isNextButtonNeeded

isPrevButtonNeeded

boolean isPrevButtonNeeded

REFRESH

public static int REFRESH
If refresh button is invoked from the client


POST_ERROR

public static int POST_ERROR
If any error in the post


DO_OPER

public static int DO_OPER
If Get Operation is performed on the Attribute


page

public java.lang.String page

stIndex

static int stIndex

endIndex

static int endIndex
Constructor Detail

StaticUtil

public StaticUtil(ServerOperations serverOp)
Default Constructor for HtmlMain.

Method Detail

setHtmlPageProp

public void setHtmlPageProp(HtmlPageProp htmlPageProp)

getHtmlParser

public HtmlParser getHtmlParser()
Return the HtmlParser object reference. Using this the user can invoke methods from the servlet.

Returns:
the reference of HtmlParser.

setServletName

public void setServletName(java.lang.String name)
Method to set the servlet name.

Parameters:
name - the servlet name

setNextRow

public void setNextRow(boolean flag)

setPrevRow

public void setPrevRow(boolean flag)

setOperationsButtonNeeded

public void setOperationsButtonNeeded(boolean value)

setRefreshTime

public void setRefreshTime(int time)
Setter for the refresh time.

Parameters:
time - the time value for refesh time.

setFilter

public void setFilter(java.lang.String filter)
Setter for the filter value.

Parameters:
filter - the value for filter.

getFilter

public java.lang.String getFilter()
Getter for the filter value.

Returns:
the value for filter.

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name,
                                          java.lang.String searchAttrbName,
                                          java.lang.Object searchAttrbValue,
                                          boolean isForSetMethod,
                                          boolean isDynamicHtmlPage,
                                          boolean fromSetAttributeValue)
                                   throws java.lang.Exception
It will retrieve or update the MBean's attributes with the given parameters from the client. The parameter name is MBean object name, using this MBean's attributes is updated.

Parameters:
name - the MBean ObjectName.
searchAttrbName - the attribute of the MBean name.
searchAttrbValue - the value of the MBean atrribute.
isForSetMethod - to say the operation is set or get.
isDynamicHtmlPage - to say about the html page will be generated dynamically or not.
Returns:
the generated html page.
Throws:
java.lang.Exception

setAttributeValue

public java.lang.String setAttributeValue(java.lang.String objName,
                                          java.lang.String searchAttrbName,
                                          java.lang.String searchAttrbValue)
                                   throws java.lang.Exception
It will update the MBean's attribute with the given value from the client. The parameter name is nothing but the MBean object name using this we can update the MBean's attributes.

Parameters:
objName - the domain MBean ObjectName.
searchAttrbName - the MBean's attribute name.
searchAttrbValue - the MBean's attribute value.
Returns:
the html page in the case of http errro.
Throws:
java.lang.Exception

setAttributeValue

public int setAttributeValue(java.util.Hashtable table)
It is used to set the attributes value received from the client(browser).

Parameters:
table - the hash table cotains param and its value.
Returns:
CANCEL - if cancel button is pressed,
NEW_ROW - if new Row button is pressed,
REFRESH - if refresh button is pressed and
DO_GET - if set is success, and to reurn the modified html page. NEXT_ROW - if Next Button is Pressed in the case of Tables. PREV_ROW - if Previous button is pressed in case of Tables.

getMBean

static java.lang.Object getMBean(java.lang.String objName)
Getter for the MBean. If you give the object name it will give the corresponding MBean if it exist. Otherwise null will be returned.

Parameters:
objName - - the string representation of the ObjectName.
Returns:
the MBean.

registerMBean

public void registerMBean(java.lang.String domain,
                          java.lang.String keys,
                          java.lang.String className,
                          java.lang.String loader,
                          java.lang.String xmlFile)
It is used to instantiate and register an MBean from the browser.

Parameters:
domain - the DomanName of the ObjectName of MBean.
keys - the key list of the ObjectName.
className - the class name of the MBean.
loader - the loader object name
xmlFile - the xml file name in the case of model mbean.

unregisterMBean

public void unregisterMBean(java.lang.String domain,
                            java.lang.String keys)
It is used to unregister an MBean from the MBeanServer.

Parameters:
domain - the DomanName of the ObjectName of MBean.
keys - the key list of the ObjectName.

setStartIndex

public void setStartIndex(int value)

setEndIndex

public void setEndIndex(int value)

createTabularDataForModifyOrDelete

public javax.jmx.openmbean.TabularData createTabularDataForModifyOrDelete(java.util.Hashtable table,
                                                                          java.lang.String objName,
                                                                          boolean modifyFlag)

createCompositeDataForModifyOrDelete

public javax.jmx.openmbean.CompositeData[] createCompositeDataForModifyOrDelete(java.util.Hashtable table,
                                                                                java.lang.String objName,
                                                                                boolean modifyFlag)

getHeaderTable

static java.util.Hashtable getHeaderTable()

createTable

public boolean createTable(java.lang.StringBuffer strBuf,
                           java.lang.Object obj,
                           javax.management.ObjectName objName,
                           java.lang.Object mbean,
                           boolean isDynamicHtmlPage,
                           int sIndex,
                           int eIndex,
                           boolean implementsModelListener)
If the given attribute is table then this function will be called to generate html table. It will give all necessary information like read/write access, type, default and legal values.

Parameters:
strBuf - to store the created html information about table.
obj - the TabularData of the table.
objName - the object name of the registed MBean.
mbean - the MBean object of the table.
Returns:
the modify access of the table.

createAttrbNameAccessTypeVector

public static void createAttrbNameAccessTypeVector(java.lang.Object mbean,
                                                   java.util.Vector variable,
                                                   java.util.Vector access,
                                                   java.util.Vector type)
Create vectors for attribute names, their access and their basic data types from the xml file.

Parameters:
modelMBean - the registered mbean.
variable - vector to store variable (column) name.
access - vector to store the access of the variable (column).
type - vector to store the type of the variable (coulmn).

setTableValues

public int setTableValues(java.util.Hashtable table,
                          java.lang.String objName,
                          boolean implementsModelListener,
                          boolean addRowFlag,
                          boolean deleteRowFlag)

setScalarValues

public int setScalarValues(java.util.Hashtable table,
                           java.util.Hashtable hashtable,
                           java.lang.String objName,
                           boolean isTable)

addFormAndTableTags

public void addFormAndTableTags(java.lang.StringBuffer strBuf,
                                javax.management.ObjectName objName,
                                boolean isDynamicHtmlPage,
                                java.lang.String varName,
                                java.lang.String searchAttrbName)
Add the starting tags for form and table.

Parameters:
strBuf - to store the generated tags information.
objName - the ObjectName of the MBean.

createTableHeader

public void createTableHeader(java.util.Vector ve,
                              java.util.Vector type,
                              java.lang.StringBuffer strBuf)

createTableRow

public boolean createTableRow(java.util.Vector varVect,
                              java.util.Vector valVect,
                              java.util.Vector typeVect,
                              java.lang.String indexes,
                              java.util.Vector accessVec,
                              java.lang.StringBuffer strBuf,
                              java.lang.String varName)
Used to create a dynamic row in the HTML table.

Parameters:
indexs - the index string in the case of table.
ve - vector contains the each column value of a row.
accessFlag - to tell about the attribute is read only or read write.
strBuf - the resultant html table will be stored in this variable.

convertArrayToString

public static java.lang.String convertArrayToString(java.lang.String attrbType,
                                                    java.lang.Object attrbValue)
Method to convert the given attrbValue into string. If the given attrbValue is an array then it will take each entry from the list and make a single string with ';' as field separator.

Parameters:
attrbType - the basic type of the object.
attrbValue - the value of the object.

isTable

public static boolean isTable(java.lang.String name)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getNotifTable

public java.lang.String getNotifTable()