org.jboss.mx.util
Class ObjectNameConverter

java.lang.Object
  extended byorg.jboss.mx.util.ObjectNameConverter

public class ObjectNameConverter
extends java.lang.Object

Converts forbidden characters in the key and value of an object name to valid characters and back.
Character Conversion Table: (based on RFC 1738 style escapes
'%' => '%25'
'*' => '%2a'
',' => '%2c'
':' => '%3a'
'?' => '%3f'
'=' => '%3d'

Thanx to William Hoyle for mention this
Attention:When you have a comma in one of your property value then you have to use a Hashtable to provide the properties otherwise the property parsing will fail.


Constructor Summary
ObjectNameConverter()
           
 
Method Summary
static ObjectName (src) convert(java.lang.String pObjectName)
          Parses the given Object Name String representation and replaces any invalid characters in property keays and values with valid characters.
static ObjectName (src) convert(java.lang.String pDomainName, java.util.Hashtable pProperties)
          Check the keys and values of the properties and convert invalid characters
static java.lang.String convertCharacters(java.lang.String pValue, boolean pEncrypt)
          Encrypt or decrypt the forbidden characters in an Object Name value property
static java.util.Hashtable getProperties(ObjectName (src)  pObjectName)
          Takes the properties from the given Object Name and convert special characters back
static java.lang.String getString(ObjectName (src)  pObjectName)
          Takes the properties from the given Object Name and convert special characters back
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectNameConverter

public ObjectNameConverter()
Method Detail

convert

public static ObjectName (src)  convert(java.lang.String pObjectName)
                          throws MalformedObjectNameException (src) 
Parses the given Object Name String representation and replaces any invalid characters in property keays and values with valid characters. Attention: Do not use this method when a property key or value contain a comma because then the parsing will fail. Please use the convert( String, Hashtable ) instead because the properties are already parsed (by you).

Parameters:
pObjectName - String representing an Object Name which must not contain a comman inside a property value
Returns:
Created Object Name with the converted keys and values of the given Object Name
Throws:
MalformedObjectNameException (src) - If the given Object Name is not correct

convert

public static ObjectName (src)  convert(java.lang.String pDomainName,
                                 java.util.Hashtable pProperties)
                          throws MalformedObjectNameException (src) 
Check the keys and values of the properties and convert invalid characters

Parameters:
pDomainName - Name of the Domain
Returns:
Created Object Name with the converted keays and values
Throws:
MalformedObjectNameException (src) - If the given Object Name is not correct

getProperties

public static java.util.Hashtable getProperties(ObjectName (src)  pObjectName)
Takes the properties from the given Object Name and convert special characters back

Parameters:
pObjectName - Given Object Name
Returns:
Hashtable with the back converted properties in it and will contain a "*" as key if the given object name is a property pattern for queries.

getString

public static java.lang.String getString(ObjectName (src)  pObjectName)
Takes the properties from the given Object Name and convert special characters back

Parameters:
pObjectName - Given Object Name
Returns:
String with the original Object Name String representation and when a property pattern Object Name for queries it contains a ",*" at the end.

convertCharacters

public static java.lang.String convertCharacters(java.lang.String pValue,
                                                 boolean pEncrypt)
Encrypt or decrypt the forbidden characters in an Object Name value property

Parameters:
pValue - Property Value of the Object Name's property list to be en- or decrypted
pEncrypt - True if the value must be encrypted otherwise decrypted
Returns:
A en- or decrypted String according to the conversion table above