You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2010/08/02 19:08:20 UTC
svn commit: r981604 [4/22] - in /felix/trunk/sigil:
common/core.tests/src/org/apache/felix/sigil/common/core/
common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/
common/core/src/org/apache/felix/sigil/common/bnd/ common/core/s...
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java Mon Aug 2 17:08:03 2010
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.HashMap;
import java.util.Map;
-
public abstract class ModelElementFactory
{
static class ElementInfo
@@ -33,8 +31,7 @@ public abstract class ModelElementFactor
String groupName;
String groupURI;
-
- public ElementInfo( Class<? extends IModelElement> implType, String name, String groupName, String groupURI )
+ public ElementInfo(Class<? extends IModelElement> implType, String name, String groupName, String groupURI)
{
this.implType = implType;
this.name = name;
@@ -42,34 +39,30 @@ public abstract class ModelElementFactor
this.groupURI = groupURI;
}
-
public Class<? extends IModelElement> getImplType()
{
return implType;
}
-
public String getName()
{
return name;
}
-
public String getGroupName()
{
return groupName;
}
-
public String getGroupURI()
{
return groupURI;
}
-
public String toString()
{
- return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":" + implType.getCanonicalName() + "]";
+ return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":"
+ + implType.getCanonicalName() + "]";
}
}
@@ -78,25 +71,21 @@ public abstract class ModelElementFactor
private ElementInfo e;
-
- public ModelInfo( ElementInfo e )
+ public ModelInfo(ElementInfo e)
{
this.e = e;
}
-
public String getGroupName()
{
return e.getGroupName();
}
-
public String getGroupURI()
{
return e.getGroupURI();
}
-
public String getName()
{
return e.getName();
@@ -108,92 +97,88 @@ public abstract class ModelElementFactor
{
private HashMap<Class<? extends IModelElement>, ElementInfo> elementInfo = new HashMap<Class<? extends IModelElement>, ElementInfo>();
-
@SuppressWarnings("unchecked")
@Override
- public <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException
+ public <T extends IModelElement> T newModelElement(Class<T> type)
+ throws ModelElementFactoryException
{
- ElementInfo info = elementInfo.get( type );
- if ( info == null )
+ ElementInfo info = elementInfo.get(type);
+ if (info == null)
{
- throw new ModelElementFactoryException( "No implementation registered for " + type );
+ throw new ModelElementFactoryException(
+ "No implementation registered for " + type);
}
try
{
- return ( T ) info.getImplType().newInstance();
+ return (T) info.getImplType().newInstance();
}
- catch ( InstantiationException e )
+ catch (InstantiationException e)
{
- throw new ModelElementFactoryException( e );
+ throw new ModelElementFactoryException(e);
}
- catch ( IllegalAccessException e )
+ catch (IllegalAccessException e)
{
- throw new ModelElementFactoryException( e );
+ throw new ModelElementFactoryException(e);
}
}
-
@Override
- public <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
- String groupName, String groupURI )
+ public <T extends IModelElement> void register(Class<T> type,
+ Class<? extends T> impl, String name, String groupName, String groupURI)
{
- elementInfo.put( type, new ElementInfo( impl, name, groupName, groupURI ) );
+ elementInfo.put(type, new ElementInfo(impl, name, groupName, groupURI));
}
-
@Override
- public <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl )
+ public <T extends IModelElement> void unregister(Class<T> type,
+ Class<? extends T> impl)
{
- ElementInfo info = elementInfo.get( type );
- if ( info != null && info.getImplType() == impl )
+ ElementInfo info = elementInfo.get(type);
+ if (info != null && info.getImplType() == impl)
{
- elementInfo.remove( type );
+ elementInfo.remove(type);
}
}
-
@Override
- public IModelInfo getModelInfo( Class<? extends IModelElement> type )
+ public IModelInfo getModelInfo(Class<? extends IModelElement> type)
{
- ElementInfo e = findElementInfo( type );
+ ElementInfo e = findElementInfo(type);
- if ( e == null )
+ if (e == null)
{
return null;
}
- return new ModelInfo( e );
+ return new ModelInfo(e);
}
-
@Override
- public IModelElement newModelElement( String namespaceURI, String localPart )
+ public IModelElement newModelElement(String namespaceURI, String localPart)
throws ModelElementFactoryException
{
- for ( Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet() )
+ for (Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet())
{
ElementInfo i = e.getValue();
- if ( equal( namespaceURI, i.getGroupURI() ) && equal( i.getName(), localPart ) )
+ if (equal(namespaceURI, i.getGroupURI()) && equal(i.getName(), localPart))
{
- return newModelElement( e.getKey() );
+ return newModelElement(e.getKey());
}
}
return null;
}
-
- private boolean equal( String val1, String val2 )
+ private boolean equal(String val1, String val2)
{
- return val1 == null ? val2 == null : val1.equals( val2 );
+ return val1 == null ? val2 == null : val1.equals(val2);
}
-
- private ElementInfo findElementInfo( Class<? extends IModelElement> type )
+ private ElementInfo findElementInfo(Class<? extends IModelElement> type)
{
- for ( ElementInfo e : elementInfo.values() )
+ for (ElementInfo e : elementInfo.values())
{
- if ( e.getImplType() == type )
+ if (e.getImplType() == type)
{
return e;
}
@@ -204,26 +189,22 @@ public abstract class ModelElementFactor
}
-
- public abstract <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException;
-
-
- public abstract IModelElement newModelElement( String namespaceURI, String localPart )
+ public abstract <T extends IModelElement> T newModelElement(Class<T> type)
throws ModelElementFactoryException;
+ public abstract IModelElement newModelElement(String namespaceURI, String localPart)
+ throws ModelElementFactoryException;
- public abstract <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
- String groupName, String groupURI );
-
-
- public abstract <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl );
+ public abstract <T extends IModelElement> void register(Class<T> type,
+ Class<? extends T> impl, String name, String groupName, String groupURI);
+ public abstract <T extends IModelElement> void unregister(Class<T> type,
+ Class<? extends T> impl);
- public abstract IModelInfo getModelInfo( Class<? extends IModelElement> type );
+ public abstract IModelInfo getModelInfo(Class<? extends IModelElement> type);
private static ModelElementFactory instance = new DefaultModelElementFactory();
-
public static ModelElementFactory getInstance()
{
return instance;
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java Mon Aug 2 17:08:03 2010
@@ -19,22 +19,19 @@
package org.apache.felix.sigil.common.model;
-
public class ModelElementFactoryException extends RuntimeException
{
private static final long serialVersionUID = 1L;
-
- public ModelElementFactoryException( Throwable t )
+ public ModelElementFactoryException(Throwable t)
{
- super( t );
+ super(t);
}
-
- public ModelElementFactoryException( String msg )
+ public ModelElementFactoryException(String msg)
{
- super( msg );
+ super(msg);
}
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.reflect.Array;
@@ -37,22 +36,17 @@ import java.util.logging.Logger;
import org.apache.felix.sigil.common.model.annotations.Required;
-
public class ModelElementSupport implements Serializable
{
- private static final Logger log = Logger.getLogger( ModelElementSupport.class.getName() );
+ private static final Logger log = Logger.getLogger(ModelElementSupport.class.getName());
private static final long serialVersionUID = 1L;
- private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[]
- {};
- private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[]
- {};
- private static final Object[] ZERO_ARGS = new Object[]
- {};
- private static final Class<?>[] ZERO_PARAMS = new Class[]
- {};
+ private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[] {};
+ private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[] {};
+ private static final Object[] ZERO_ARGS = new Object[] {};
+ private static final Class<?>[] ZERO_PARAMS = new Class[] {};
private static final WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>> adapterCache = new WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>>();;
private static final WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>> propertyCache = new WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>>();;
@@ -63,172 +57,168 @@ public class ModelElementSupport impleme
private transient SoftReference<ChildAdapter[]> childrenReference;
private transient SoftReference<Set<String>> propertyNameReference;
-
- public ModelElementSupport( IModelElement target )
+ public ModelElementSupport(IModelElement target)
{
this.target = target;
}
-
- public void setProperty( String name, Object value ) throws NoSuchMethodException
+ public void setProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getWriteMethod(), value );
+ invoke(target, p.getWriteMethod(), value);
}
-
- public void addProperty( String name, Object value ) throws NoSuchMethodException
+ public void addProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getAddMethod(), value );
+ invoke(target, p.getAddMethod(), value);
}
-
- public void removeProperty( String name, Object value ) throws NoSuchMethodException
+ public void removeProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getRemoveMethod(), value );
+ invoke(target, p.getRemoveMethod(), value);
}
-
- public Object getProperty( String name ) throws NoSuchMethodException
+ public Object getProperty(String name) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, null );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, null);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- return invoke( target, p.getReadMethod(), ZERO_ARGS );
+ return invoke(target, p.getReadMethod(), ZERO_ARGS);
}
-
public Set<String> getPropertyNames()
{
- Set<String> names = propertyNameReference == null ? null : propertyNameReference.get();
+ Set<String> names = propertyNameReference == null ? null
+ : propertyNameReference.get();
- if ( names == null )
+ if (names == null)
{
names = new HashSet<String>();
- PropertyAdapter[] props = cachedProps( target.getClass() );
- for ( PropertyAdapter prop : props )
+ PropertyAdapter[] props = cachedProps(target.getClass());
+ for (PropertyAdapter prop : props)
{
- names.add( prop.getName() );
+ names.add(prop.getName());
}
- propertyNameReference = new SoftReference<Set<String>>( names );
+ propertyNameReference = new SoftReference<Set<String>>(names);
}
return names;
}
-
- public Object getDefaultPropertyValue( String name )
+ public Object getDefaultPropertyValue(String name)
{
try
{
- Method m = target.getClass().getMethod( makeDefaultPropertyValue( name ), ZERO_PARAMS );
- return invoke( target, m, ZERO_ARGS );
+ Method m = target.getClass().getMethod(makeDefaultPropertyValue(name),
+ ZERO_PARAMS);
+ return invoke(target, m, ZERO_ARGS);
}
- catch ( SecurityException e )
+ catch (SecurityException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
// fine no default
return null;
}
}
-
- public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+ public Class<?> getPropertyType(String name) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, null );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, null);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
return p.getPropertyType();
}
-
@SuppressWarnings("unchecked")
- public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+ public <T extends IModelElement> T[] childrenOfType(Class<T> type)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
// return (T[]) EMPTY_ELEMENTS;
- return ( ( T[] ) Array.newInstance( type, 0 ) );
+ return ((T[]) Array.newInstance(type, 0));
}
ArrayList<T> elements = new ArrayList<T>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- Collection<? extends IModelElement> val = adapter.members( target );
+ Collection<? extends IModelElement> val = adapter.members(target);
- for ( IModelElement e : val )
+ for (IModelElement e : val)
{
- if ( type.isInstance( e ) )
+ if (type.isInstance(e))
{
- elements.add( ( T ) e );
+ elements.add((T) e);
}
}
}
//return elements.toArray( (T[]) EMPTY_ELEMENTS );
- return elements.toArray( ( T[] ) Array.newInstance( type, elements.size() ) );
+ return elements.toArray((T[]) Array.newInstance(type, elements.size()));
}
-
public IModelElement[] children()
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
return EMPTY_ELEMENTS;
}
ArrayList<IModelElement> elements = new ArrayList<IModelElement>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- elements.addAll( adapter.members( target ) );
+ elements.addAll(adapter.members(target));
}
- return elements.toArray( EMPTY_ELEMENTS );
+ return elements.toArray(EMPTY_ELEMENTS);
}
-
- public boolean addChild( IModelElement element ) throws InvalidModelException
+ public boolean addChild(IModelElement element) throws InvalidModelException
{
- if ( element.getParent() == null )
+ if (element.getParent() == null)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length > 0 )
+ if (adapters.length > 0)
{
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.add( target, element ) )
+ if (adapter.add(target, element))
{
- element.setParent( target );
+ element.setParent(target);
return true;
}
}
@@ -238,20 +228,19 @@ public class ModelElementSupport impleme
return false;
}
-
- public boolean removeChild( IModelElement element )
+ public boolean removeChild(IModelElement element)
{
- if ( element.getParent() == target )
+ if (element.getParent() == target)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length > 0 )
+ if (adapters.length > 0)
{
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.remove( target, element ) )
+ if (adapter.remove(target, element))
{
- element.setParent( null );
+ element.setParent(null);
return true;
}
}
@@ -261,27 +250,26 @@ public class ModelElementSupport impleme
return false;
}
-
- public Set<Class<? extends IModelElement>> getChildrenTypes( boolean required )
+ public Set<Class<? extends IModelElement>> getChildrenTypes(boolean required)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
return Collections.emptySet();
}
HashSet<Class<? extends IModelElement>> types = new HashSet<Class<? extends IModelElement>>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.isRequired() == required )
+ if (adapter.isRequired() == required)
{
Class<? extends IModelElement> type = adapter.getType();
- if ( type != null )
+ if (type != null)
{
- types.add( type );
+ types.add(type);
}
}
}
@@ -289,21 +277,21 @@ public class ModelElementSupport impleme
return types;
}
-
- private PropertyAdapter findProperty( String name, Object value )
+ private PropertyAdapter findProperty(String name, Object value)
{
- PropertyAdapter[] props = propertyReference == null ? null : propertyReference.get();
+ PropertyAdapter[] props = propertyReference == null ? null
+ : propertyReference.get();
- if ( props == null )
+ if (props == null)
{
- props = cachedProps( target.getClass() );
- propertyReference = new SoftReference<PropertyAdapter[]>( props );
+ props = cachedProps(target.getClass());
+ propertyReference = new SoftReference<PropertyAdapter[]>(props);
}
- for ( PropertyAdapter prop : props )
+ for (PropertyAdapter prop : props)
{
- if ( prop.getName().equals( name )
- && ( value == null || prop.getRawType().isAssignableFrom( value.getClass() ) ) )
+ if (prop.getName().equals(name)
+ && (value == null || prop.getRawType().isAssignableFrom(value.getClass())))
{
return prop;
}
@@ -312,152 +300,144 @@ public class ModelElementSupport impleme
return null;
}
-
- private static synchronized PropertyAdapter[] cachedProps( Class<? extends IModelElement> type )
+ private static synchronized PropertyAdapter[] cachedProps(
+ Class<? extends IModelElement> type)
{
- SoftReference<PropertyAdapter[]> ref = propertyCache.get( type );
+ SoftReference<PropertyAdapter[]> ref = propertyCache.get(type);
PropertyAdapter[] props = ref == null ? null : ref.get();
- if ( props == null )
+ if (props == null)
{
- props = loadProps( type );
- propertyCache.put( type, new SoftReference<PropertyAdapter[]>( props ) );
+ props = loadProps(type);
+ propertyCache.put(type, new SoftReference<PropertyAdapter[]>(props));
}
return props;
}
-
- private static PropertyAdapter[] loadProps( Class<? extends IModelElement> type )
+ private static PropertyAdapter[] loadProps(Class<? extends IModelElement> type)
{
ArrayList<PropertyAdapter> props = new ArrayList<PropertyAdapter>();
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
- if ( isValidProperty( m ) )
+ if (isValidProperty(m))
{
try
{
- PropertyAdapter p = new PropertyAdapter( m, type );
- props.add( p );
+ PropertyAdapter p = new PropertyAdapter(m, type);
+ props.add(p);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
// fine not a bean method
- log.finer( "Invalid bean property method " + m + ": " + e.getMessage() );
+ log.finer("Invalid bean property method " + m + ": " + e.getMessage());
}
}
}
- return props.toArray( EMPTY_PROPS );
+ return props.toArray(EMPTY_PROPS);
}
-
- private static boolean isValidProperty( Method m )
+ private static boolean isValidProperty(Method m)
{
- return m.getName().startsWith( "get" ) && m.getParameterTypes().length == 0
- && !m.getDeclaringClass().equals( Object.class )
- && !IModelElement.class.isAssignableFrom( m.getReturnType() );
+ return m.getName().startsWith("get") && m.getParameterTypes().length == 0
+ && !m.getDeclaringClass().equals(Object.class)
+ && !IModelElement.class.isAssignableFrom(m.getReturnType());
}
-
- private static String makeDefaultPropertyValue( String name )
+ private static String makeDefaultPropertyValue(String name)
{
- return "getDefault" + capitalise( name );
+ return "getDefault" + capitalise(name);
}
-
- private static String capitalise( String name )
+ private static String capitalise(String name)
{
- return Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
-
- private static String decapitalise( String substring )
+ private static String decapitalise(String substring)
{
- return Character.toLowerCase( substring.charAt( 0 ) ) + substring.substring( 1 );
+ return Character.toLowerCase(substring.charAt(0)) + substring.substring(1);
}
-
private ChildAdapter[] cachedAdapters()
{
- ChildAdapter[] adapters = childrenReference == null ? null : childrenReference.get();
+ ChildAdapter[] adapters = childrenReference == null ? null
+ : childrenReference.get();
- if ( adapters == null )
+ if (adapters == null)
{
- adapters = loadAdapters( target );
- childrenReference = new SoftReference<ChildAdapter[]>( adapters );
+ adapters = loadAdapters(target);
+ childrenReference = new SoftReference<ChildAdapter[]>(adapters);
}
return adapters;
}
-
- private static synchronized ChildAdapter[] loadAdapters( IModelElement target )
+ private static synchronized ChildAdapter[] loadAdapters(IModelElement target)
{
Class<? extends IModelElement> type = target.getClass();
- SoftReference<ChildAdapter[]> ref = adapterCache.get( type );
+ SoftReference<ChildAdapter[]> ref = adapterCache.get(type);
ChildAdapter[] adapters = ref == null ? null : ref.get();
- if ( adapters == null )
+ if (adapters == null)
{
- adapters = buildAdapters( type );
- adapterCache.put( type, new SoftReference<ChildAdapter[]>( adapters ) );
+ adapters = buildAdapters(type);
+ adapterCache.put(type, new SoftReference<ChildAdapter[]>(adapters));
}
return adapters;
}
-
- private static ChildAdapter[] buildAdapters( Class<? extends IModelElement> type )
+ private static ChildAdapter[] buildAdapters(Class<? extends IModelElement> type)
{
ArrayList<ChildAdapter> adapters = new ArrayList<ChildAdapter>();
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
ChildAdapter adapter = null;
- if ( isValidGetProperty( m ) )
+ if (isValidGetProperty(m))
{
- adapter = buildGetAdapter( m );
+ adapter = buildGetAdapter(m);
}
- else if ( isValidSetProperty( m ) )
+ else if (isValidSetProperty(m))
{
- adapter = buildSetAdapter( m );
+ adapter = buildSetAdapter(m);
}
- else if ( isValidAddProperty( m ) )
+ else if (isValidAddProperty(m))
{
- adapter = buildAddAdapter( m );
+ adapter = buildAddAdapter(m);
}
- else if ( isValidRemoveProperty( m ) )
+ else if (isValidRemoveProperty(m))
{
- adapter = buildRemoveAdapter( m );
+ adapter = buildRemoveAdapter(m);
}
- if ( adapter != null )
+ if (adapter != null)
{
- adapters.add( adapter );
+ adapters.add(adapter);
}
}
- return adapters.toArray( new ChildAdapter[adapters.size()] );
+ return adapters.toArray(new ChildAdapter[adapters.size()]);
}
-
- private static ChildAdapter buildGetAdapter( Method m )
+ private static ChildAdapter buildGetAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getReturnType() ) )
+ if (IModelElement.class.isAssignableFrom(m.getReturnType()))
{
- return new GetPropertyAdapter( m );
+ return new GetPropertyAdapter(m);
}
- else if ( Collection.class.isAssignableFrom( m.getReturnType() ) )
+ else if (Collection.class.isAssignableFrom(m.getReturnType()))
{
- return new GetCollectionAdapter( m );
+ return new GetCollectionAdapter(m);
}
- else if ( isModelArray( m.getReturnType() ) )
+ else if (isModelArray(m.getReturnType()))
{
- return new GetArrayAdapter( m );
+ return new GetArrayAdapter(m);
}
else
{
@@ -465,12 +445,11 @@ public class ModelElementSupport impleme
}
}
-
- private static ChildAdapter buildSetAdapter( Method m )
+ private static ChildAdapter buildSetAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new SetPropertyAdapter( m );
+ return new SetPropertyAdapter(m);
}
else
{
@@ -478,12 +457,11 @@ public class ModelElementSupport impleme
}
}
-
- private static ChildAdapter buildAddAdapter( Method m )
+ private static ChildAdapter buildAddAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new AddPropertyAdapter( m );
+ return new AddPropertyAdapter(m);
}
else
{
@@ -491,12 +469,11 @@ public class ModelElementSupport impleme
}
}
-
- private static ChildAdapter buildRemoveAdapter( Method m )
+ private static ChildAdapter buildRemoveAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new RemovePropertyAdapter( m );
+ return new RemovePropertyAdapter(m);
}
else
{
@@ -504,71 +481,66 @@ public class ModelElementSupport impleme
}
}
-
- private static boolean isValidRemoveProperty( Method m )
+ private static boolean isValidRemoveProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "remove" )
- && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("remove")
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static boolean isValidAddProperty( Method m )
+ private static boolean isValidAddProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "add" )
- && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("add")
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static boolean isDeclared( Class<? extends IModelElement> element, Method m )
+ private static boolean isDeclared(Class<? extends IModelElement> element, Method m)
{
try
{
- element.getMethod( m.getName(), m.getParameterTypes() );
+ element.getMethod(m.getName(), m.getParameterTypes());
return true;
}
- catch ( SecurityException e )
+ catch (SecurityException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
return false;
}
}
-
- private static boolean isValidSetProperty( Method m )
+ private static boolean isValidSetProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "set" )
- && !isDeclared( IModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("set")
+ && !isDeclared(IModelElement.class, m);
}
-
- private static boolean isValidGetProperty( Method m )
+ private static boolean isValidGetProperty(Method m)
{
- return m.getParameterTypes().length == 0 && m.getName().startsWith( "get" )
- && !isDeclared( IModelElement.class, m ) && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 0 && m.getName().startsWith("get")
+ && !isDeclared(IModelElement.class, m)
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static Object invoke( Object target, Method m, Object... args )
+ private static Object invoke(Object target, Method m, Object... args)
{
try
{
- return m.invoke( target, args );
+ return m.invoke(target, args);
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
// this should already have been tested
- throw new IllegalStateException( e );
+ throw new IllegalStateException(e);
}
- catch ( IllegalAccessException e )
+ catch (IllegalAccessException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- throw new UndeclaredThrowableException( e.getCause() );
+ throw new UndeclaredThrowableException(e.getCause());
}
}
@@ -583,138 +555,131 @@ public class ModelElementSupport impleme
Method r;
Class<?> propertyType;
-
- public PropertyAdapter( Method g, Class<?> type ) throws SecurityException, NoSuchMethodException
+ public PropertyAdapter(Method g, Class<?> type) throws SecurityException, NoSuchMethodException
{
- if ( g.getReturnType().isArray() || Iterable.class.isAssignableFrom( g.getReturnType() ) )
+ if (g.getReturnType().isArray()
+ || Iterable.class.isAssignableFrom(g.getReturnType()))
{
- prop = g.getName().substring( 3 );
+ prop = g.getName().substring(3);
// remove trailing s - as in addWibble, removeWibble, getWibbles
- prop = prop.substring( 0, prop.length() - 1 );
- name = decapitalise( prop );
- a = find( "add", prop, g.getReturnType(), type );
+ prop = prop.substring(0, prop.length() - 1);
+ name = decapitalise(prop);
+ a = find("add", prop, g.getReturnType(), type);
propertyType = a.getParameterTypes()[0];
- r = find( "remove", prop, g.getReturnType(), type );
- if ( r.getParameterTypes()[0] != propertyType )
+ r = find("remove", prop, g.getReturnType(), type);
+ if (r.getParameterTypes()[0] != propertyType)
{
- throw new NoSuchMethodException( "Add remove property method types do not match" );
+ throw new NoSuchMethodException(
+ "Add remove property method types do not match");
}
- propertyType = Array.newInstance( propertyType, 0 ).getClass();
+ propertyType = Array.newInstance(propertyType, 0).getClass();
}
else
{
- prop = g.getName().substring( 3 );
- name = decapitalise( prop );
+ prop = g.getName().substring(3);
+ name = decapitalise(prop);
propertyType = g.getReturnType();
- s = find( "set", prop, propertyType, type );
+ s = find("set", prop, propertyType, type);
}
this.g = g;
}
-
public Class<?> getRawType()
{
- return propertyType.isArray() ? propertyType.getComponentType() : propertyType;
+ return propertyType.isArray() ? propertyType.getComponentType()
+ : propertyType;
}
-
public Class<?> getPropertyType()
{
return propertyType;
}
-
public Method getReadMethod()
{
return g;
}
-
public Method getAddMethod() throws NoSuchMethodException
{
- if ( a == null )
+ if (a == null)
{
- throw new NoSuchMethodException( "No such method add" + prop );
+ throw new NoSuchMethodException("No such method add" + prop);
}
return a;
}
-
public Method getRemoveMethod() throws NoSuchMethodException
{
- if ( r == null )
+ if (r == null)
{
- throw new NoSuchMethodException( "No such method remove" + prop );
+ throw new NoSuchMethodException("No such method remove" + prop);
}
return r;
}
-
public Method getWriteMethod() throws NoSuchMethodException
{
- if ( s == null )
+ if (s == null)
{
- throw new NoSuchMethodException( "No such method set" + prop );
+ throw new NoSuchMethodException("No such method set" + prop);
}
return s;
}
-
@Override
public String toString()
{
return "PropertyAdapter[" + name + "]";
}
-
- private Method find( String prefix, String prop, Class<?> returnType, Class<?> type ) throws SecurityException,
- NoSuchMethodException
+ private Method find(String prefix, String prop, Class<?> returnType, Class<?> type)
+ throws SecurityException, NoSuchMethodException
{
String methodName = prefix + prop;
- if ( returnType.isArray() )
+ if (returnType.isArray())
{
Class<?> t = returnType.getComponentType();
- return type.getMethod( methodName, new Class[]
- { t } );
+ return type.getMethod(methodName, new Class[] { t });
}
- else if ( Iterable.class.isAssignableFrom( returnType ) )
+ else if (Iterable.class.isAssignableFrom(returnType))
{
Method f = null;
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
- if ( m.getParameterTypes().length == 1 && m.getName().equals( methodName )
- && !IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (m.getParameterTypes().length == 1
+ && m.getName().equals(methodName)
+ && !IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- if ( f == null )
+ if (f == null)
{
f = m;
}
else
{
- throw new NoSuchMethodException( "Found duplicate " + methodName );
+ throw new NoSuchMethodException("Found duplicate "
+ + methodName);
}
}
}
- if ( f == null )
+ if (f == null)
{
- throw new NoSuchMethodException( "No such method " + methodName );
+ throw new NoSuchMethodException("No such method " + methodName);
}
return f;
}
else
{
- return type.getMethod( methodName, new Class[]
- { returnType } );
+ return type.getMethod(methodName, new Class[] { returnType });
}
}
-
public String getName()
{
return name;
@@ -726,40 +691,33 @@ public class ModelElementSupport impleme
{
Method m;
-
- ChildAdapter( Method m )
+ ChildAdapter(Method m)
{
this.m = m;
}
-
public boolean isRequired()
{
- return m.isAnnotationPresent( Required.class );
+ return m.isAnnotationPresent(Required.class);
}
-
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
return false;
}
-
abstract Class<? extends IModelElement> getType();
-
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
return false;
}
-
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
return Collections.emptyList();
}
-
@Override
public String toString()
{
@@ -769,67 +727,64 @@ public class ModelElementSupport impleme
private static class GetPropertyAdapter extends ChildAdapter
{
- GetPropertyAdapter( Method m )
+ GetPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- IModelElement member = ( IModelElement ) invoke( target, m, ZERO_ARGS );
- if ( member == null )
+ IModelElement member = (IModelElement) invoke(target, m, ZERO_ARGS);
+ if (member == null)
{
return Collections.emptyList();
}
else
{
- return Collections.<IModelElement> singleton( member );
+ return Collections.<IModelElement> singleton(member);
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getReturnType();
+ return (Class<? extends IModelElement>) m.getReturnType();
}
}
private static class GetCollectionAdapter extends ChildAdapter
{
- public GetCollectionAdapter( Method m )
+ public GetCollectionAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@SuppressWarnings("unchecked")
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- Collection members = ( Collection ) invoke( target, m, ZERO_ARGS );
- if ( members == null )
+ Collection members = (Collection) invoke(target, m, ZERO_ARGS);
+ if (members == null)
{
return Collections.emptyList();
}
else
{
- ArrayList<IModelElement> safe = new ArrayList<IModelElement>( members.size() );
- for ( Object o : members )
+ ArrayList<IModelElement> safe = new ArrayList<IModelElement>(
+ members.size());
+ for (Object o : members)
{
- if ( o instanceof IModelElement )
+ if (o instanceof IModelElement)
{
- safe.add( ( IModelElement ) o );
+ safe.add((IModelElement) o);
}
}
return safe;
}
}
-
@Override
Class<? extends IModelElement> getType()
{
@@ -841,50 +796,46 @@ public class ModelElementSupport impleme
private static class GetArrayAdapter extends ChildAdapter
{
- public GetArrayAdapter( Method m )
+ public GetArrayAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- IModelElement[] array = ( IModelElement[] ) invoke( target, m, ZERO_ARGS );
- if ( array == null || array.length == 0 )
+ IModelElement[] array = (IModelElement[]) invoke(target, m, ZERO_ARGS);
+ if (array == null || array.length == 0)
{
return Collections.emptyList();
}
else
{
- return ( Collection<? extends IModelElement> ) Arrays.asList( array );
+ return (Collection<? extends IModelElement>) Arrays.asList(array);
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getReturnType().getComponentType();
+ return (Class<? extends IModelElement>) m.getReturnType().getComponentType();
}
}
private static class SetPropertyAdapter extends ChildAdapter
{
- public SetPropertyAdapter( Method m )
+ public SetPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -893,14 +844,12 @@ public class ModelElementSupport impleme
}
}
-
@Override
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { null } );
+ invoke(target, m, new Object[] { null });
return true;
}
else
@@ -909,30 +858,27 @@ public class ModelElementSupport impleme
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
private static class AddPropertyAdapter extends ChildAdapter
{
- public AddPropertyAdapter( Method m )
+ public AddPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -941,31 +887,28 @@ public class ModelElementSupport impleme
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
private static class RemovePropertyAdapter extends ChildAdapter
{
- public RemovePropertyAdapter( Method m )
+ public RemovePropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -974,18 +917,17 @@ public class ModelElementSupport impleme
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
-
- private static boolean isModelArray( Class<?> returnType )
+ private static boolean isModelArray(Class<?> returnType)
{
- return returnType.isArray() && IModelElement.class.isAssignableFrom( returnType.getComponentType() );
+ return returnType.isArray()
+ && IModelElement.class.isAssignableFrom(returnType.getComponentType());
}
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java Mon Aug 2 17:08:03 2010
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.HashMap;
import java.util.Map;
-
/**
* @author dave
*
@@ -38,32 +36,29 @@ public enum OverrideOptions
static
{
- for ( OverrideOptions option : OverrideOptions.values() )
+ for (OverrideOptions option : OverrideOptions.values())
{
- map.put( option.str.toLowerCase(), option );
+ map.put(option.str.toLowerCase(), option);
}
}
-
- private OverrideOptions( String str )
+ private OverrideOptions(String str)
{
this.str = str;
}
-
- public static OverrideOptions parse( String val )
+ public static OverrideOptions parse(String val)
{
- OverrideOptions option = map.get( val.toLowerCase() );
+ OverrideOptions option = map.get(val.toLowerCase());
- if ( option == null )
+ if (option == null)
{
- throw new IllegalArgumentException( "Invalid override value " + val );
+ throw new IllegalArgumentException("Invalid override value " + val);
}
return option;
}
-
@Override
public String toString()
{
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.annotations;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
@@ -27,7 +26,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java Mon Aug 2 17:08:03 2010
@@ -24,5 +24,6 @@ import org.osgi.framework.Version;
public interface IBundleCapability extends ICapabilityModelElement
{
String getSymbolicName();
+
Version getVersion();
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java Mon Aug 2 17:08:03 2010
@@ -19,33 +19,25 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.osgi.framework.Version;
-
public interface ILibrary extends IModelElement
{
String getName();
-
- void setName( String name );
-
+ void setName(String name);
Version getVersion();
+ void setVersion(Version version);
- void setVersion( Version version );
-
-
- void addImport( IPackageImport pi );
-
-
- void removeImport( IPackageImport pi );
+ void addImport(IPackageImport pi);
+ void removeImport(IPackageImport pi);
Collection<IPackageImport> getImports();
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java Mon Aug 2 17:08:03 2010
@@ -19,21 +19,16 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public interface ILibraryImport extends IModelElement
{
String getLibraryName();
-
- void setLibraryName( String name );
-
+ void setLibraryName(String name);
VersionRange getVersions();
-
- void setVersions( VersionRange range );
+ void setVersions(VersionRange range);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -32,94 +31,70 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IVersionedModelElement;
-
/**
* @author dave
*
*/
public interface ISigilBundle extends ICompoundModelElement, IVersionedModelElement
{
- void synchronize( IProgressMonitor monitor ) throws IOException;
-
+ void synchronize(IProgressMonitor monitor) throws IOException;
boolean isSynchronized();
-
IBundleModelElement getBundleInfo();
-
String getSymbolicName();
-
- void setBundleInfo( IBundleModelElement bundle );
-
+ void setBundleInfo(IBundleModelElement bundle);
// TODO rename this method...
- void addSourcePath( Resource path );
-
-
- void removeSourcePath( Resource path );
+ void addSourcePath(Resource path);
+ void removeSourcePath(Resource path);
Collection<Resource> getSourcePaths();
-
void clearSourcePaths();
-
Collection<String> getClasspathEntrys();
+ void addClasspathEntry(String encodedClasspath);
- void addClasspathEntry( String encodedClasspath );
-
-
- void removeClasspathEntry( String encodedClasspath );
-
+ void removeClasspathEntry(String encodedClasspath);
// XXX must be file due to SiglCore.isBundlePath
File getLocation();
-
// XXX must be file due to SiglCore.isBundlePath
- void setLocation( File location );
-
+ void setLocation(File location);
File getSourcePathLocation();
-
- void setSourcePathLocation( File location );
-
+ void setSourcePathLocation(File location);
String getSourceRootPath();
+ void setSourceRootPath(String location);
- void setSourceRootPath( String location );
-
-
- void setLicencePathLocation( File cacheSourceLocation );
-
+ void setLicencePathLocation(File cacheSourceLocation);
File getLicencePathLocation();
-
/**
* get package names included in bundle.
* Can contain wildcards e.g. org.foo.*
*/
Collection<String> getPackages();
-
/**
* remove package name from those included in bundle.
*/
- boolean removePackage( String pkg );
-
+ boolean removePackage(String pkg);
/**
* add package name to be included in bundle.
*/
- void addPackage( String pkg );
-
+ void addPackage(String pkg);
/**
* Attempt to find a package export that matches the given name or return null if none specified
@@ -127,16 +102,14 @@ public interface ISigilBundle extends IC
* @param elementName
* @return
*/
- IPackageExport findExport( String elementName );
-
+ IPackageExport findExport(String elementName);
/**
* Attempt to find a package import that matches the given name or return null if none specified
* @param packageName
* @return
*/
- IPackageImport findImport( String packageName );
-
+ IPackageImport findImport(String packageName);
IBundleCapability getBundleCapability();
}
\ No newline at end of file
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.osgi;
-
import java.net.URI;
import java.util.Collection;
import java.util.Set;
@@ -29,129 +28,88 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
import org.osgi.framework.Version;
-
public interface IBundleModelElement extends INamedModelElement, ICompoundModelElement, IVersionedModelElement
{
String getActivator();
-
- void setActivator( String activator );
-
+ void setActivator(String activator);
String getCategory();
-
- void setCategory( String category );
-
+ void setCategory(String category);
String getContactAddress();
-
- void setContactAddress( String contactAddress );
-
+ void setContactAddress(String contactAddress);
String getCopyright();
-
- void setCopyright( String copyright );
-
+ void setCopyright(String copyright);
URI getDocURI();
-
- void setDocURI( URI docURI );
-
+ void setDocURI(URI docURI);
Collection<IPackageExport> getExports();
+ void addExport(IPackageExport packageExport);
- void addExport( IPackageExport packageExport );
-
-
- void removeExport( IPackageExport packageExport );
-
+ void removeExport(IPackageExport packageExport);
Collection<IPackageImport> getImports();
+ void addImport(IPackageImport packageImport);
- void addImport( IPackageImport packageImport );
-
-
- void removeImport( IPackageImport packageImport );
-
+ void removeImport(IPackageImport packageImport);
Collection<IRequiredBundle> getRequiredBundles();
+ void addRequiredBundle(IRequiredBundle bundle);
- void addRequiredBundle( IRequiredBundle bundle );
-
-
- void removeRequiredBundle( IRequiredBundle bundle );
-
+ void removeRequiredBundle(IRequiredBundle bundle);
- void addLibraryImport( ILibraryImport library );
-
-
- void removeLibraryImport( ILibraryImport library );
+ void addLibraryImport(ILibraryImport library);
+ void removeLibraryImport(ILibraryImport library);
Set<ILibraryImport> getLibraryImports();
-
URI getLicenseURI();
-
- void setLicenseURI( URI licenseURI );
-
+ void setLicenseURI(URI licenseURI);
URI getSourceLocation();
-
- void setSourceLocation( URI sourceLocation );
-
+ void setSourceLocation(URI sourceLocation);
String getSymbolicName();
-
- void setSymbolicName( String symbolicName );
-
+ void setSymbolicName(String symbolicName);
URI getUpdateLocation();
-
- void setUpdateLocation( URI updateLocation );
-
+ void setUpdateLocation(URI updateLocation);
String getVendor();
-
- void setVendor( String vendor );
-
+ void setVendor(String vendor);
Version getVersion();
+ void setVersion(Version version);
- void setVersion( Version version );
-
-
- void setDescription( String elementText );
-
+ void setDescription(String elementText);
String getDescription();
-
Collection<String> getClasspaths();
+ void addClasspath(String path);
- void addClasspath( String path );
-
-
- void removeClasspath( String path );
-
-
- void setFragmentHost( IRequiredBundle fragmentHost );
+ void removeClasspath(String path);
+ void setFragmentHost(IRequiredBundle fragmentHost);
IRequiredBundle getFragmentHost();
}
\ No newline at end of file
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java Mon Aug 2 17:08:03 2010
@@ -19,26 +19,20 @@
package org.apache.felix.sigil.common.model.osgi;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.ICapabilityModelElement;
import org.osgi.framework.Version;
-
public interface IPackageExport extends IPackageModelElement, IVersionedModelElement, Comparable<IPackageExport>, ICapabilityModelElement
{
- void addUse( String uses );
-
-
- void removeUse( String uses );
+ void addUse(String uses);
+ void removeUse(String uses);
Collection<String> getUses();
-
- void setUses( Collection<String> asList );
-
+ void setUses(Collection<String> asList);
Version getRawVersion();
}
\ No newline at end of file
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java Mon Aug 2 17:08:03 2010
@@ -19,12 +19,9 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IRequirementModelElement;
-
-public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement,
- Comparable<IPackageImport>
+public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement, Comparable<IPackageImport>
{
/**
* indicates whether import is needed at compile-time.
@@ -33,9 +30,7 @@ public interface IPackageImport extends
*/
boolean isDependency();
-
- void setDependency( boolean dependency );
-
+ void setDependency(boolean dependency);
/**
* indicates whether import should be added to OSGi Package-Import header.
@@ -43,8 +38,7 @@ public interface IPackageImport extends
*/
OSGiImport getOSGiImport();
-
- void setOSGiImport( OSGiImport osgiImport );
+ void setOSGiImport(OSGiImport osgiImport);
enum OSGiImport
{
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,16 +19,13 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IModelElement;
-
public interface IPackageModelElement extends IModelElement
{
String getPackageName();
-
- void setPackageName( String packageName );
+ void setPackageName(String packageName);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java Mon Aug 2 17:08:03 2010
@@ -19,22 +19,17 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.IRequirementModelElement;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public interface IRequiredBundle extends IModelElement, IRequirementModelElement, Comparable<IRequiredBundle>
{
String getSymbolicName();
-
- void setSymbolicName( String symbolicName );
-
+ void setSymbolicName(String symbolicName);
VersionRange getVersions();
-
- void setVersions( VersionRange versions );
+ void setVersions(VersionRange versions);
}
\ No newline at end of file
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java Mon Aug 2 17:08:03 2010
@@ -26,7 +26,6 @@ public interface IVersionRangeModelEleme
VersionRange getVersions();
-
- void setVersions( VersionRange version );
+ void setVersions(VersionRange version);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,16 +19,13 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.osgi.framework.Version;
-
public interface IVersionedModelElement
{
Version getVersion();
-
- void setVersion( Version version );
+ void setVersion(Version version);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -39,89 +38,79 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public abstract class AbstractBundleRepository implements IBundleRepository
{
private final String id;
private final HashSet<IBundleRepositoryListener> listeners = new HashSet<IBundleRepositoryListener>();
-
- public AbstractBundleRepository( String id )
+ public AbstractBundleRepository(String id)
{
this.id = id;
}
+ public abstract void accept(IRepositoryVisitor visitor, int options);
- public abstract void accept( IRepositoryVisitor visitor, int options );
-
-
- public void addBundleRepositoryListener( IBundleRepositoryListener listener )
+ public void addBundleRepositoryListener(IBundleRepositoryListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.add( listener );
+ listeners.add(listener);
}
}
-
- public void removeBundleRepositoryListener( IBundleRepositoryListener listener )
+ public void removeBundleRepositoryListener(IBundleRepositoryListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.remove( listener );
+ listeners.remove(listener);
}
}
-
protected void notifyChange()
{
- for ( IBundleRepositoryListener l : listeners )
+ for (IBundleRepositoryListener l : listeners)
{
- l.notifyChange( this );
+ l.notifyChange(this);
}
}
-
public String getId()
{
return id;
}
-
- public void accept( IRepositoryVisitor visitor )
+ public void accept(IRepositoryVisitor visitor)
{
- accept( visitor, 0 );
+ accept(visitor, 0);
}
-
- public void writeOBR( OutputStream out ) throws IOException
+ public void writeOBR(OutputStream out) throws IOException
{
throw new UnsupportedOperationException();
}
-
- public Collection<ISigilBundle> findProviders( final ILibrary library, int options )
+ public Collection<ISigilBundle> findProviders(final ILibrary library, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( library );
+ final ILicensePolicy policy = findPolicy(library);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- for ( IPackageImport pi : library.getImports() )
+ for (IPackageImport pi : library.getImports())
{
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() )
- && pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getPackageName().equals(e.getPackageName())
+ && pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
break;
}
}
@@ -131,64 +120,63 @@ public abstract class AbstractBundleRepo
}
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public Collection<ISigilBundle> findAllProviders( final IRequiredBundle req, int options )
+ public Collection<ISigilBundle> findAllProviders(final IRequiredBundle req,
+ int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( req );
+ final ILicensePolicy policy = findPolicy(req);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( req.getSymbolicName().equals( info.getSymbolicName() )
- && req.getVersions().contains( info.getVersion() ) )
+ if (req.getSymbolicName().equals(info.getSymbolicName())
+ && req.getVersions().contains(info.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
}
}
return true;
}
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public Collection<ISigilBundle> findAllProviders( final IPackageImport pi, int options )
+ public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( pi );
+ final ILicensePolicy policy = findPolicy(pi);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( info != null )
+ if (info != null)
{
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() ) )
+ if (pi.getPackageName().equals(e.getPackageName()))
{
- if ( pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
break;
}
}
@@ -200,31 +188,30 @@ public abstract class AbstractBundleRepo
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public ISigilBundle findProvider( final IPackageImport pi, int options )
+ public ISigilBundle findProvider(final IPackageImport pi, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( pi );
+ final ILicensePolicy policy = findPolicy(pi);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() )
- && pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getPackageName().equals(e.getPackageName())
+ && pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
return false;
}
}
@@ -234,30 +221,29 @@ public abstract class AbstractBundleRepo
};
- accept( visitor, options );
+ accept(visitor, options);
return found.isEmpty() ? null : found.iterator().next();
}
-
- public ISigilBundle findProvider( final IRequiredBundle req, int options )
+ public ISigilBundle findProvider(final IRequiredBundle req, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( req );
+ final ILicensePolicy policy = findPolicy(req);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( req.getSymbolicName().equals( info.getSymbolicName() )
- && req.getVersions().contains( info.getVersion() ) )
+ if (req.getSymbolicName().equals(info.getSymbolicName())
+ && req.getVersions().contains(info.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
return false;
}
}
@@ -266,19 +252,17 @@ public abstract class AbstractBundleRepo
};
- accept( visitor, options );
+ accept(visitor, options);
return found.isEmpty() ? null : found.iterator().next();
}
-
- public IBundleModelElement buildBundleModelElement( Manifest mf )
+ public IBundleModelElement buildBundleModelElement(Manifest mf)
{
return ManifestUtil.buildBundleModelElement(mf);
}
-
- protected ILicensePolicy findPolicy( IModelElement elem )
+ protected ILicensePolicy findPolicy(IModelElement elem)
{
ILicenseManager man = BldCore.getLicenseManager();