org.ow2.jasmine.probe.collectors.jmx.internal
Class FragmentUtil

java.lang.Object
  extended by org.ow2.jasmine.probe.collectors.jmx.internal.FragmentUtil

public class FragmentUtil
extends Object

Manage JMX Attribute fragments. Attribute fragments are elements of complex attributes. Sometimes, users need to poll such attribute elements, for example an item in a Map, and don't need the entire attribute value. A naming policy is necessary to define the attributes elements to be polled by a JMX indicator. Also, when a JMX indicator specifies an attribute (or an attribute fragment) whose value has a complex type, the value must be decomposed in simple elements (elementary fragments). The naming policy is used to identify the fragments returned by a probe polling this indicator.

Author:
danesa

Field Summary
static String BRACKLEFT
           
static String BRACKRIGHT
           
static String COMMA
           
static String DOT
           
 
Constructor Summary
FragmentUtil()
           
 
Method Summary
static String getAttributeName(String name)
          Get the attribute name from the attribute fragment name
static String getElementName(String fragmentName)
          Get the name of an element from a fragment name.
static String getElementName(String name, String attributeName)
          Get the first attribute element's name in a String having the following expected format: ...
static String getIndexes(String name, String attributeName)
          Get the indexes in an indexed attribute element having the following expected format: ..., where has form indexes
static String getItemName(String fragmentName)
          Get the name of an item's key from a fragment name.
static String getKeyName(String name, String attributeName)
           
static String getNameForArrayElement(String name, String index)
          Generate the name of an element of an Array.
static String getNameForElem(String name, String elemName)
          Generate the name of a fragment corresponding to an Array or TabularData's item
static String getNameForItem(String name, String key)
          Generate the name of a fragment corresponding to a CompositeData's item.
static String getNameForTabularElement(String name, Object[] indexes)
          Generate the name of a fragment corresponding to a row of in a TabularData
static boolean isFragmentName(String name)
           
static String nameForIndexElement(String name, String index)
          Generate the name of an element of indexed object.
static String nameForItem(String name, String key)
          Generate the name of a fragment corresponding to a CompositeData's item.
static boolean nextElementIsIndex(String name, String attributeName)
          Check if the first attribute element in the given String corresponds to an indexed element.
static boolean nextElementIsKey(String name, String attributeName)
          Check if the first attribute element in the given String corresponds to a key element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOT

public static String DOT

COMMA

public static String COMMA

BRACKLEFT

public static String BRACKLEFT

BRACKRIGHT

public static String BRACKRIGHT
Constructor Detail

FragmentUtil

public FragmentUtil()
Method Detail

isFragmentName

public static boolean isFragmentName(String name)
Parameters:
name - attribute or fragment name
Returns:
true if the name has a fragment name pattern

getNameForItem

public static String getNameForItem(String name,
                                    String key)
Generate the name of a fragment corresponding to a CompositeData's item.

Parameters:
name - composite's name
key - the item's name

getNameForElem

public static String getNameForElem(String name,
                                    String elemName)
Generate the name of a fragment corresponding to an Array or TabularData's item

Parameters:
name -
elemName -
Returns:

getNameForArrayElement

public static String getNameForArrayElement(String name,
                                            String index)
Generate the name of an element of an Array.

Parameters:
name - the name of the Array attribute or fragment
index - the element's index
Returns:

getNameForTabularElement

public static String getNameForTabularElement(String name,
                                              Object[] indexes)
Generate the name of a fragment corresponding to a row of in a TabularData

Parameters:
name - the name of the TabularData attribute or fragment
indexes - the row's indexes
Returns:

getItemName

public static String getItemName(String fragmentName)
                          throws FragmentNameException
Get the name of an item's key from a fragment name. Suppose that the fragment name has the following format: nameDOTkey

Parameters:
fragmentName - fragment name
Returns:
key
Throws:
FragmentNameException - A key name could not be identified.

getElementName

public static String getElementName(String fragmentName)
                             throws FragmentNameException
Get the name of an element from a fragment name. Suppose that the fragment name has the following format: nameBRACKLEFTindexesBRACKRIGHT

Parameters:
fragmentName - fragment name
Returns:
the element name
Throws:
FragmentNameException

nameForIndexElement

public static String nameForIndexElement(String name,
                                         String index)
Generate the name of an element of indexed object.

Parameters:
name - the name associated to the indexed object.
index - the element's index
Returns:

nameForItem

public static String nameForItem(String name,
                                 String key)
Generate the name of a fragment corresponding to a CompositeData's item.

Parameters:
name - composite's name
key - the item's name

getAttributeName

public static String getAttributeName(String name)
                               throws FragmentNameException
Get the attribute name from the attribute fragment name

Parameters:
name - attribute fragment name
Returns:
attribute name
Throws:
FragmentNameException - An attribute name could not be identified as no DOT nor BRACKLEFT found.

getKeyName

public static String getKeyName(String name,
                                String attributeName)

getIndexes

public static String getIndexes(String name,
                                String attributeName)
                         throws FragmentNameException
Get the indexes in an indexed attribute element having the following expected format: ..., where has form indexes

Parameters:
name - The String to process.
attributeName - The supposed starting attribute name
Returns:
the found indexes
Throws:
FragmentNameException - the given String does not have the expected format

getElementName

public static String getElementName(String name,
                                    String attributeName)
                             throws FragmentNameException
Get the first attribute element's name in a String having the following expected format: ...

Parameters:
name - The String to process.
attributeName - The supposed starting attribute name
Returns:
the element name
Throws:
FragmentNameException

nextElementIsKey

public static boolean nextElementIsKey(String name,
                                       String attributeName)
                                throws FragmentNameException
Check if the first attribute element in the given String corresponds to a key element

Parameters:
name - A String having the expected format: ...
attributeName - The supposed starting attribute name
Returns:
true if the first attribute element has the expected format: .
Throws:
FragmentNameException

nextElementIsIndex

public static boolean nextElementIsIndex(String name,
                                         String attributeName)
                                  throws FragmentNameException
Check if the first attribute element in the given String corresponds to an indexed element.

Parameters:
name - A String having the expected format: ...
attributeName - The supposed starting attribute name
Returns:
true if the first attribute element has the expected format: [index]
Throws:
FragmentNameException


Copyright © 2012 OW2 Consortium. All Rights Reserved.