Knopflerfish OSGi 1.3.3

org.knopflerfish.util.metatype
Class OCD

java.lang.Object
  extended byorg.knopflerfish.util.metatype.OCD
All Implemented Interfaces:
ObjectClassDefinition

public class OCD
extends java.lang.Object
implements ObjectClassDefinition

Implementation of the ObjectClassDefinition interface.


Field Summary
 
Fields inherited from interface org.osgi.service.metatype.ObjectClassDefinition
ALL, OPTIONAL, REQUIRED
 
Constructor Summary
OCD(java.lang.String id, java.lang.String name, java.lang.String desc)
          Create a new, empty ObjectClassDefinition.
OCD(java.lang.String id, java.lang.String name, java.lang.String desc, java.util.Dictionary props)
          Creates an OCD with attribute definitions from an existing dictionary.
 
Method Summary
 void add(AttributeDefinition attr, int filter)
          Add an attribute definition
 AttributeDefinition[] getAttributeDefinitions(int filter)
          Return the attribute definitions.
 java.lang.String getDescription()
          Get description of OCD.
 java.io.InputStream getIcon(int size)
          Get icon stream using the getIconURL URL.
 java.lang.String getIconURL()
          Get URL to icon data
 java.lang.String getID()
          Return the id of this object class.
 int getMaxInstances()
          Get maximum number of instances.
 java.lang.String getName()
          Return the name of this class.
 void setIconURL(java.lang.String url)
          Set URL to icon
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OCD

public OCD(java.lang.String id,
           java.lang.String name,
           java.lang.String desc)
Create a new, empty ObjectClassDefinition.

Parameters:
id - unique ID of the definition.
name - human-readable name of the definition. If set to null, use id as name.
desc - human-readable description of the definition
Throws:
java.lang.IllegalArgumentException - if id is or empty

OCD

public OCD(java.lang.String id,
           java.lang.String name,
           java.lang.String desc,
           java.util.Dictionary props)
Creates an OCD with attribute definitions from an existing dictionary.

Parameters:
id - unique ID of the definition.
name - human-readable name of the definition. If set to null, use id as name.
desc - human-readable description of the definition
props - set of key value pairs used for attribute definitions. all entries in props will be set as REQUIRED atttributes.
Throws:
java.lang.IllegalArgumentException - if id is or empty
Method Detail

add

public void add(AttributeDefinition attr,
                int filter)
Add an attribute definition

Parameters:
attr - definition to add
filter - either OPTIONAL or REQUIRED
Throws:
Illegalargumentexception - if filter is not OPTIONAL or REQUIRED

getAttributeDefinitions

public AttributeDefinition[] getAttributeDefinitions(int filter)
Description copied from interface: ObjectClassDefinition
Return the attribute definitions.

Return a set of attributes. The filter parameter can distinguish between ALL, REQUIRED or the OPTIONAL attributes.

Specified by:
getAttributeDefinitions in interface ObjectClassDefinition
Parameters:
filter - ALL, REQUIRED, OPTIONAL
Returns:
An array of attribute definitions or null if no attributes are selected

getDescription

public java.lang.String getDescription()
Get description of OCD.

Specified by:
getDescription in interface ObjectClassDefinition
Returns:
The localized description of the definition.

getIcon

public java.io.InputStream getIcon(int size)
                            throws java.io.IOException
Get icon stream using the getIconURL URL.

Specified by:
getIcon in interface ObjectClassDefinition
Parameters:
size - icon size hint is ignored.
Returns:
An InputStream representing an icon or null
Throws:
java.io.IOException

getMaxInstances

public int getMaxInstances()
Get maximum number of instances. Services return 1, factories > 1.


setIconURL

public void setIconURL(java.lang.String url)
Set URL to icon


getIconURL

public java.lang.String getIconURL()
Get URL to icon data


getID

public java.lang.String getID()
Description copied from interface: ObjectClassDefinition
Return the id of this object class.

ObjectDefintion objects share a global namespace in the registry. They share this aspect with LDAP/X.500 attributes. In these standards the OSI Object Identifier (OID) is used to uniquely identify object classes. If such an OID exists, (which can be requested at several standard organisations and many companies already have a node in the tree) it can be returned here. Otherwise, a unique id should be returned which can be a java class name (reverse domain name) or generated with a GUID algorithm. Note that all LDAP defined object classes already have an OID associated. It is strongly advised to define the object classes from existing LDAP schemes which will give the OID for free. Many such schemes exist ranging from postal addresses to DHCP parameters.

Specified by:
getID in interface ObjectClassDefinition
Returns:
The id or oid

getName

public java.lang.String getName()
Description copied from interface: ObjectClassDefinition
Return the name of this class.

Specified by:
getName in interface ObjectClassDefinition
Returns:
The name of the described class.

toString

public java.lang.String toString()

Knopflerfish OSGi 1.3.3