org.apache.felix.metatype.internal
Class LocalizedObjectClassDefinition

java.lang.Object
  extended by org.apache.felix.metatype.internal.LocalizedObjectClassDefinition
All Implemented Interfaces:
org.osgi.service.metatype.ObjectClassDefinition

public class LocalizedObjectClassDefinition
extends java.lang.Object
implements org.osgi.service.metatype.ObjectClassDefinition

The LocalizedObjectClassDefinition class is the implementation of the ObjectClassDefinition interface. This class delegates calls to the underlying OCD localizing the results of the following methods: getName(), getDescription(), and getIcon(int).

Author:
fmeschbe

Field Summary
 
Fields inherited from interface org.osgi.service.metatype.ObjectClassDefinition
ALL, OPTIONAL, REQUIRED
 
Constructor Summary
LocalizedObjectClassDefinition(org.osgi.framework.Bundle bundle, OCD ocd, Resources resources)
          Creates and instance of this localizing facade.
 
Method Summary
 org.osgi.service.metatype.AttributeDefinition[] getAttributeDefinitions(int filter)
           
 java.lang.String getDescription()
           
 java.io.InputStream getIcon(int size)
           
 java.lang.String getID()
           
 java.lang.String getName()
           
protected  Resources getResources()
          Returns the Resources assigned to this instance.
protected  java.lang.String localize(java.lang.String string)
          Localizes the string using the ResourceBundle set on this instance if string starts with the percent character (%).
protected  java.lang.String[] localize(java.lang.String[] strings)
          Calls localize(String) for each string in the array and returns an array of the resulting localized strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalizedObjectClassDefinition

public LocalizedObjectClassDefinition(org.osgi.framework.Bundle bundle,
                                      OCD ocd,
                                      Resources resources)
Creates and instance of this localizing facade.

Parameters:
bundle - The Bundle providing this object class definition.
ocd - The OCD to which calls are delegated.
resources - The Resources used to localize return values of localizable methods.
Method Detail

getAttributeDefinitions

public org.osgi.service.metatype.AttributeDefinition[] getAttributeDefinitions(int filter)
Specified by:
getAttributeDefinitions in interface org.osgi.service.metatype.ObjectClassDefinition
Parameters:
filter -
See Also:
ObjectClassDefinition.getAttributeDefinitions(int)

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface org.osgi.service.metatype.ObjectClassDefinition
See Also:
ObjectClassDefinition.getDescription()

getIcon

public java.io.InputStream getIcon(int size)
                            throws java.io.IOException
Specified by:
getIcon in interface org.osgi.service.metatype.ObjectClassDefinition
Parameters:
size -
Throws:
java.io.IOException
See Also:
ObjectClassDefinition.getIcon(int)

getID

public java.lang.String getID()
Specified by:
getID in interface org.osgi.service.metatype.ObjectClassDefinition
See Also:
ObjectClassDefinition.getID()

getName

public java.lang.String getName()
Specified by:
getName in interface org.osgi.service.metatype.ObjectClassDefinition
See Also:
ObjectClassDefinition.getName()

getResources

protected Resources getResources()
Returns the Resources assigned to this instance.


localize

protected java.lang.String[] localize(java.lang.String[] strings)
Calls localize(String) for each string in the array and returns an array of the resulting localized strings. If strings is null null is returned.

Parameters:
strings - An array of non-null strings to localize.
Returns:
null if strings is null or an array of the same size as the strings array containing localized strings.

localize

protected java.lang.String localize(java.lang.String string)
Localizes the string using the ResourceBundle set on this instance if string starts with the percent character (%). If the string is null, does not start with a percent character or the resource whose key is the string without the leading the percent character is not found the string is returned without the leading percent character.

Examples of different localizations:

string Key Resource Result
null - - null
sample - - sample
%sample sample - sample
%sample sample resource resource

Parameters:
string - The string to localize
Returns:
The localized string