Apply our formatting rules (particularly with respect to opening braces)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1399637 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/MetaData.java b/metatype/src/main/java/org/apache/felix/metatype/MetaData.java
index 9abf244..0985c87 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/MetaData.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/MetaData.java
@@ -39,6 +39,7 @@
private Map designates;
private URL source;
+
public String getLocalePrefix()
{
return localePrefix;
diff --git a/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java b/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
index 482529d..d96ffc3 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
@@ -78,12 +78,18 @@
private KXmlParser parser = new KXmlParser();
/** Sets of attributes belonging to XML elements. */
- private final Set AD_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "name", "description", "id", "type", "cardinality", "min", "max", "default", "required" }));
- private final Set ATTRIBUTE_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "adref", "content" }));
- private final Set DESIGNATE_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "pid", "factoryPid", "bundle", "optional", "merge" }));
- private final Set DESIGNATEOBJECT_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "ocdref" }));
- private final Set METADATA_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "localization" }));
- private final Set OCD_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "name", "description", "id" }));
+ private final Set AD_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "name", "description", "id", "type", "cardinality", "min", "max", "default", "required" } ) );
+ private final Set ATTRIBUTE_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "adref", "content" } ) );
+ private final Set DESIGNATE_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "pid", "factoryPid", "bundle", "optional", "merge" } ) );
+ private final Set DESIGNATEOBJECT_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "ocdref" } ) );
+ private final Set METADATA_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "localization" } ) );
+ private final Set OCD_ATTRIBUTES = new HashSet( Arrays.asList( new String[]
+ { "name", "description", "id" } ) );
/**
@@ -183,7 +189,7 @@
if ( "MetaData".equals( this.parser.getName() ) )
{
checkMetatypeNamespace();
- mti = this.readMetaData( );
+ mti = this.readMetaData();
}
else
{
@@ -197,15 +203,16 @@
}
- private void readOptionalAttributes(OptionalAttributes entity, Set attributes) {
+ private void readOptionalAttributes( OptionalAttributes entity, Set attributes )
+ {
int count = this.parser.getAttributeCount();
- for (int i = 0; i < count; i++)
+ for ( int i = 0; i < count; i++ )
{
- String name = this.parser.getAttributeName(i);
- if (!attributes.contains(name))
+ String name = this.parser.getAttributeName( i );
+ if ( !attributes.contains( name ) )
{
- String value = this.parser.getAttributeValue(i);
- entity.addOptionalAttribute(name, value);
+ String value = this.parser.getAttributeValue( i );
+ entity.addOptionalAttribute( name, value );
}
}
}
@@ -216,7 +223,7 @@
MetaData mti = this.createMetaData();
mti.setLocalePrefix( this.getOptionalAttribute( "localization" ) );
- readOptionalAttributes(mti, METADATA_ATTRIBUTES);
+ readOptionalAttributes( mti, METADATA_ATTRIBUTES );
int eventType = this.parser.next();
while ( eventType != XmlPullParser.END_DOCUMENT )
@@ -259,7 +266,7 @@
ocd.setName( this.getRequiredAttribute( "name" ) );
ocd.setDescription( this.getOptionalAttribute( "description" ) );
- readOptionalAttributes(ocd, OCD_ATTRIBUTES);
+ readOptionalAttributes( ocd, OCD_ATTRIBUTES );
int eventType = this.parser.next();
while ( eventType != XmlPullParser.END_DOCUMENT )
@@ -324,7 +331,7 @@
designate.setOptional( this.getOptionalAttribute( "optional", false ) );
designate.setMerge( this.getOptionalAttribute( "merge", false ) );
- readOptionalAttributes(designate, DESIGNATE_ATTRIBUTES);
+ readOptionalAttributes( designate, DESIGNATE_ATTRIBUTES );
int eventType = this.parser.next();
while ( eventType != XmlPullParser.END_DOCUMENT )
@@ -369,7 +376,7 @@
ad.setDefaultValue( this.getOptionalAttribute( "default" ) );
ad.setRequired( this.getOptionalAttribute( "required", true ) );
- readOptionalAttributes(ad, AD_ATTRIBUTES);
+ readOptionalAttributes( ad, AD_ATTRIBUTES );
Map options = new LinkedHashMap();
int eventType = this.parser.next();
@@ -413,7 +420,7 @@
DesignateObject oh = this.createDesignateObject();
oh.setOcdRef( this.getRequiredAttribute( "ocdref" ) );
- readOptionalAttributes(oh, DESIGNATEOBJECT_ATTRIBUTES);
+ readOptionalAttributes( oh, DESIGNATEOBJECT_ATTRIBUTES );
int eventType = this.parser.next();
while ( eventType != XmlPullParser.END_DOCUMENT )
@@ -450,7 +457,7 @@
ah.setAdRef( this.getRequiredAttribute( "adref" ) );
ah.addContent( this.getOptionalAttribute( "content" ), true );
- readOptionalAttributes(ah, ATTRIBUTE_ATTRIBUTES);
+ readOptionalAttributes( ah, ATTRIBUTE_ATTRIBUTES );
int eventType = this.parser.next();
while ( eventType != XmlPullParser.END_DOCUMENT )
diff --git a/metatype/src/main/java/org/apache/felix/metatype/OptionalAttributes.java b/metatype/src/main/java/org/apache/felix/metatype/OptionalAttributes.java
index 365643c..6ce7078 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/OptionalAttributes.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/OptionalAttributes.java
@@ -18,22 +18,28 @@
*/
package org.apache.felix.metatype;
+
import java.util.HashMap;
import java.util.Map;
-public class OptionalAttributes {
+
+public class OptionalAttributes
+{
private Map optionalAttributes;
-
- public void addOptionalAttribute(String name, String value)
+
+
+ public void addOptionalAttribute( String name, String value )
{
- if (optionalAttributes == null)
+ if ( optionalAttributes == null )
{
optionalAttributes = new HashMap();
}
- optionalAttributes.put(name, value);
+ optionalAttributes.put( name, value );
}
-
- public Map getOptionalAttributes() {
+
+
+ public Map getOptionalAttributes()
+ {
return optionalAttributes;
}
}
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/Activator.java b/metatype/src/main/java/org/apache/felix/metatype/internal/Activator.java
index 44f026b..e399b0d 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/Activator.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/Activator.java
@@ -120,6 +120,7 @@
BundleResources.clearResourcesCache();
}
+
//---------- Logging Support ----------------------------------------------
// log to stdout or use LogService
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java b/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
index e511dda..d18dc32 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/LocalizedObjectClassDefinition.java
@@ -156,7 +156,7 @@
// just create an URL based on the source of the metadata
// see FELIX2868
- URL url = new URL(this.ocd.getMetadata().getSource(), iconPath);
+ URL url = new URL( this.ocd.getMetadata().getSource(), iconPath );
return url.openStream();
}
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
index dbf3772..22ac3fe 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.metatype.internal;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
@@ -36,6 +37,7 @@
import org.osgi.service.metatype.MetaTypeProvider;
import org.osgi.service.metatype.ObjectClassDefinition;
+
/**
* The <code>MetaTypeInformationImpl</code> class implements the
* <code>MetaTypeInformation</code> interface returned from the
@@ -43,7 +45,8 @@
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
-public class MetaTypeInformationImpl implements MetaTypeInformation {
+public class MetaTypeInformationImpl implements MetaTypeInformation
+{
// also defined in org.osgi.service.cm.ConfigurationAdmin, but copied
// here to not create a synthetic dependency
@@ -59,68 +62,82 @@
private Map metaTypeProviders;
- protected MetaTypeInformationImpl(Bundle bundle) {
+
+ protected MetaTypeInformationImpl( Bundle bundle )
+ {
this.bundle = bundle;
this.pids = new TreeSet();
this.factoryPids = new TreeSet();
this.metaTypeProviders = new HashMap();
}
+
/*
* (non-Javadoc)
*
* @see org.osgi.service.metatype.MetaTypeInformation#getBundle()
*/
- public Bundle getBundle() {
+ public Bundle getBundle()
+ {
return this.bundle;
}
+
/*
* (non-Javadoc)
*
* @see org.osgi.service.metatype.MetaTypeInformation#getFactoryPids()
*/
- public String[] getFactoryPids() {
- return (String[]) this.factoryPids.toArray(new String[this.factoryPids.size()]);
+ public String[] getFactoryPids()
+ {
+ return ( String[] ) this.factoryPids.toArray( new String[this.factoryPids.size()] );
}
+
/*
* (non-Javadoc)
*
* @see org.osgi.service.metatype.MetaTypeInformation#getPids()
*/
- public String[] getPids() {
- return (String[]) this.pids.toArray(new String[this.pids.size()]);
+ public String[] getPids()
+ {
+ return ( String[] ) this.pids.toArray( new String[this.pids.size()] );
}
+
/*
* (non-Javadoc)
*
* @see org.osgi.service.metatype.MetaTypeProvider#getLocales()
*/
- public String[] getLocales() {
- if (this.locales == null) {
- synchronized (this) {
+ public String[] getLocales()
+ {
+ if ( this.locales == null )
+ {
+ synchronized ( this )
+ {
Set newLocales = new TreeSet();
- for (Iterator mi = this.metaTypeProviders.values().iterator(); mi.hasNext();) {
- MetaTypeProvider mtp = (MetaTypeProvider) mi.next();
- this.addValues(newLocales, mtp.getLocales());
+ for ( Iterator mi = this.metaTypeProviders.values().iterator(); mi.hasNext(); )
+ {
+ MetaTypeProvider mtp = ( MetaTypeProvider ) mi.next();
+ this.addValues( newLocales, mtp.getLocales() );
}
this.locales = newLocales;
}
}
- return (String[]) this.locales.toArray(new String[this.locales.size()]);
+ return ( String[] ) this.locales.toArray( new String[this.locales.size()] );
}
+
/*
* (non-Javadoc)
*
* @see org.osgi.service.metatype.MetaTypeProvider#getObjectClassDefinition(java.lang.String,
* java.lang.String)
*/
- public ObjectClassDefinition getObjectClassDefinition(String id,
- String locale) {
+ public ObjectClassDefinition getObjectClassDefinition( String id, String locale )
+ {
if ( id == null || id.length() == 0 )
{
@@ -142,6 +159,7 @@
return ocd;
}
+
// ---------- internal support for metadata -------------------------------
Designate getDesignate( String pid )
@@ -155,27 +173,33 @@
return null;
}
+
// ---------- setters to fill the values -----------------------------------
- protected void addMetaData(MetaData md) {
- if (md.getDesignates() != null) {
+ protected void addMetaData( MetaData md )
+ {
+ if ( md.getDesignates() != null )
+ {
// meta type provide to register by PID
- DefaultMetaTypeProvider dmtp = new DefaultMetaTypeProvider(this.bundle, md);
+ DefaultMetaTypeProvider dmtp = new DefaultMetaTypeProvider( this.bundle, md );
Iterator designates = md.getDesignates().values().iterator();
- while (designates.hasNext()) {
- Designate designate = (Designate) designates.next();
+ while ( designates.hasNext() )
+ {
+ Designate designate = ( Designate ) designates.next();
// get the OCD reference, ignore the designate if none
DesignateObject object = designate.getObject();
- String ocdRef = (object == null) ? null : object.getOcdRef();
- if (ocdRef == null) {
+ String ocdRef = ( object == null ) ? null : object.getOcdRef();
+ if ( ocdRef == null )
+ {
continue;
}
// get ocd for the reference, ignore designate if none
- OCD ocd = (OCD) md.getObjectClassDefinitions().get(ocdRef);
- if (ocd == null) {
+ OCD ocd = ( OCD ) md.getObjectClassDefinitions().get( ocdRef );
+ if ( ocd == null )
+ {
continue;
}
@@ -194,41 +218,58 @@
}
}
- protected void addPids(String[] pids) {
- this.addValues(this.pids, pids);
+
+ protected void addPids( String[] pids )
+ {
+ this.addValues( this.pids, pids );
}
- protected void removePid(String pid) {
- this.pids.remove(pid);
+
+ protected void removePid( String pid )
+ {
+ this.pids.remove( pid );
}
- protected void addFactoryPids(String[] factoryPids) {
- this.addValues(this.factoryPids, factoryPids);
+
+ protected void addFactoryPids( String[] factoryPids )
+ {
+ this.addValues( this.factoryPids, factoryPids );
}
- protected void removeFactoryPid(String factoryPid) {
- this.factoryPids.remove(factoryPid);
+
+ protected void removeFactoryPid( String factoryPid )
+ {
+ this.factoryPids.remove( factoryPid );
}
- protected void addMetaTypeProvider(String key, MetaTypeProvider mtp) {
- if (key != null && mtp != null) {
- this.metaTypeProviders.put(key, mtp);
+
+ protected void addMetaTypeProvider( String key, MetaTypeProvider mtp )
+ {
+ if ( key != null && mtp != null )
+ {
+ this.metaTypeProviders.put( key, mtp );
this.locales = null;
}
}
- protected MetaTypeProvider removeMetaTypeProvider(String key) {
- if (key != null) {
+
+ protected MetaTypeProvider removeMetaTypeProvider( String key )
+ {
+ if ( key != null )
+ {
this.locales = null;
- return (MetaTypeProvider) this.metaTypeProviders.remove(key);
+ return ( MetaTypeProvider ) this.metaTypeProviders.remove( key );
}
return null;
}
- private void addValues(Collection dest, Object[] values) {
- if (values != null && values.length > 0) {
- dest.addAll(Arrays.asList(values));
+
+ private void addValues( Collection dest, Object[] values )
+ {
+ if ( values != null && values.length > 0 )
+ {
+ dest.addAll( Arrays.asList( values ) );
}
}
}
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
index d4fbd31..d659f56 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
@@ -100,7 +100,8 @@
try
{
MetaData metaData = reader.parse( doc );
- if (metaData != null) {
+ if ( metaData != null )
+ {
cmti.addMetaData( metaData );
}
}
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
index 03f86eb..771d89a 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
@@ -163,13 +163,13 @@
Properties props = new Properties( parentProperties );
URL resURL = bundle.getEntry( resourceName );
-
+
// FELIX-607 backwards compatibility, support
if ( resURL == null )
{
resURL = bundle.getEntry( MetaTypeService.METATYPE_DOCUMENTS_LOCATION + "/" + resourceName );
}
-
+
if ( resURL != null )
{
InputStream ins = null;
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/Resources.java b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/Resources.java
index 6a45754..29a043a 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/Resources.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/Resources.java
@@ -18,8 +18,10 @@
*/
package org.apache.felix.metatype.internal.l10n;
+
import java.util.Properties;
+
/**
* The <code>Resources</code> TODO
*
@@ -30,21 +32,29 @@
private String locale;
private Properties resources;
-
- Resources(String locale, Properties resources) {
+
+
+ Resources( String locale, Properties resources )
+ {
this.locale = locale;
this.resources = resources;
}
-
- public String getLocale() {
+
+
+ public String getLocale()
+ {
return locale;
}
-
- Properties getResources() {
+
+
+ Properties getResources()
+ {
return resources;
}
-
- public String getResource(String resourceName) {
- return resources.getProperty( resourceName, resourceName );
+
+
+ public String getResource( String resourceName )
+ {
+ return resources.getProperty( resourceName, resourceName );
}
}
diff --git a/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java b/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java
index f5d497f..8f10a10 100644
--- a/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java
+++ b/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java
@@ -66,6 +66,7 @@
assertNull( mti.getObjectClassDefinitions() );
}
+
public void testOptionalAttributesInMetaData() throws IOException, XmlPullParserException
{
String name = "myattribute";
@@ -78,9 +79,10 @@
assertNull( mti.getObjectClassDefinitions() );
assertNotNull( mti.getOptionalAttributes() );
assertEquals( 1, mti.getOptionalAttributes().size() );
- assertEquals( value, mti.getOptionalAttributes().get(name) );
+ assertEquals( value, mti.getOptionalAttributes().get( name ) );
}
+
public void testWithNamespace_1_0_0() throws IOException, XmlPullParserException
{
String empty = "<metatype:MetaData xmlns:metatype=\"http://www.osgi.org/xmlns/metatype/v1.0.0\" "