Framework Professional Edition Package


org.mbs.services.metatype
Interface MetaTypeUtils


public interface MetaTypeUtils

This interface is meant to facilitate applications dealing with metatyping and OSGi service configurations. As many of them will manage Strings, instead of real objects, this interface provides some utility method for working with String representations of objects.


Field Summary
static int VALIDATE_ALL
          Constant used by validateProperties(String, Dictionary, int).
static int VALIDATE_SINGLE
          Constant used by validateProperties(String, Dictionary, int).
 
Method Summary
 java.util.Dictionary convertProperties(java.lang.String pid, java.util.Dictionary properties)
          Converts the given dictionary to one appropriate to be used by the Configuration.update(java.util.Dictionary) method.
 java.lang.String[] getTypeAndString(java.lang.Object object)
          Returns the class name and the String represetation of an object.
 java.util.Dictionary validateProperties(java.lang.String pid, java.util.Dictionary properties, int validationType)
          This method checks if the the given properties are valid for use by the ConfigurationAdmin (see OSGi ConfigurationAdmin specification) service for the given pid.
 

Field Detail

VALIDATE_SINGLE

static final int VALIDATE_SINGLE
Constant used by validateProperties(String, Dictionary, int). Indicates that properties must be validated by one. No checking for missing required attributes will be performed.

See Also:
Constant Field Values

VALIDATE_ALL

static final int VALIDATE_ALL
Constant used by validateProperties(String, Dictionary, int). Indicates that properties must be validated as a whole. Checking for missing required attributes will be performed, too.

See Also:
Constant Field Values
Method Detail

getTypeAndString

java.lang.String[] getTypeAndString(java.lang.Object object)
                                    throws java.lang.IllegalArgumentException
Returns the class name and the String represetation of an object. See Convertor class for more information about converting objects to String and the supported object types.

Parameters:
object - The object to be converted to String.
Returns:
two element array: first is holding displayClass name, second - the string format of the object
Throws:
java.lang.IllegalArgumentException - if object is not among the supported types

validateProperties

java.util.Dictionary validateProperties(java.lang.String pid,
                                        java.util.Dictionary properties,
                                        int validationType)
                                        throws java.lang.IllegalArgumentException
This method checks if the the given properties are valid for use by the ConfigurationAdmin (see OSGi ConfigurationAdmin specification) service for the given pid. The dictionary MUST contain configuration keys and values. The values should be the String representations of the real objects. These String representations could be retrieved either as the second element of the returned by the getTypeAndString(java.lang.Object) method array or by the Convertor.objectToString(java.lang.Object) method.
First MetaDataManager is consulted for existence of MetaTypeProvider with the corresponding pid. If exists, each ObjectClassDefinition.REQUIRED attribute is checked for presence into the specified dictionary and any of ObjectClassDefinition.ALL attributes if present is checked for correctness (via AttributeDefinition.validate(java.lang.String) method). Attribute values and definitions are matched through the equality of the corresponding keys and the ID returned by the AttributeDefinition.getID() method.

Parameters:
pid - A non null String, holding the pid of a configuration.
properties - Dictionary holding String reprsentations of the real values.
validationType - The validation type. Should be VALIDATE_ALL or VALIDATE_SINGLE.
Returns:
if any of the properties could not be validated its key and an error description will be contained within the returned dictionary. If there are no errors, null is returned.
Throws:
java.lang.IllegalArgumentException - if the pid is null, the parameter properties are null or empty, or the provider not found.

convertProperties

java.util.Dictionary convertProperties(java.lang.String pid,
                                       java.util.Dictionary properties)
                                       throws java.lang.IllegalArgumentException
Converts the given dictionary to one appropriate to be used by the Configuration.update(java.util.Dictionary) method. The dictionary MUST contain configuration keys and values. The values must be the String representation of the real object. These String representations could be retrieved either as the second element of the returned by the getTypeAndString(java.lang.Object) method array or by the Convertor.objectToString(java.lang.Object) method.

Parameters:
pid - A non null String, holding the pid of a configuration.
properties - Dictionary containing mapping of AttributeDefinition IDs to represented as String values.
Returns:
Dictionary with keys the keys of the passed dictionary and values created by the counterpart value of the dictionary parameter passed according to the rules of the matching attribute definition.
Throws:
java.lang.IllegalArgumentException - If the pid is null, the properties are null or empty, there is no provider found for the specified pid, attribute definition with id matching some of the passed dictionary keys was not found or if a dictionary value is not of the syntax the definition requires.

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved