Knopflerfish OSGi 5.2.0

org.knopflerfish.util.metatype
Class OCD

java.lang.Object
  extended by org.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, java.util.Dictionary<java.lang.String,?> props)
          Creates an OCD with attribute definitions from an existing dictionary.
OCD(java.lang.String id, java.lang.String name, java.lang.String desc, java.net.URL sourceURL)
          Create a new, empty ObjectClassDefinition.
 
Method Summary
 void add(AD attr, int filter)
          Add an attribute definition
 void addIcon(int size, java.lang.String url)
           
 AttributeDefinition[] getAttributeDefinitions(int filter)
          Return the attribute definitions for this object class.
 java.lang.String getDescription()
          Get description of OCD.
 java.io.InputStream getIcon(int size)
          This code handles multiple icon sizes but the specification currently only allows on size.
 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 object 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,
           java.net.URL sourceURL)
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<java.lang.String,?> 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 attributes.
Throws:
java.lang.IllegalArgumentException - if id is or empty
Method Detail

add

public void add(AD 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 for this object class.

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 description of this object class.

getIcon

public java.io.InputStream getIcon(int size)
                            throws java.io.IOException
This code handles multiple icon sizes but the specification currently only allows on size.

Specified by:
getIcon in interface ObjectClassDefinition
Parameters:
size - Size of icon requested, if size is 0 return largest icon.
Returns:
An InputStream representing an icon or null
Throws:
java.io.IOException - If the InputStream cannot be returned.

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


addIcon

public void addIcon(int size,
                    java.lang.String url)

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 of this object class.

getName

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

Specified by:
getName in interface ObjectClassDefinition
Returns:
The name of this object class.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Knopflerfish OSGi 5.2.0