Small adaptation of the code to use Java 5 generics.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1159877 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
index f5ece7d..f99c763 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ClassChecker.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -33,7 +33,7 @@
/**
* Checks that a POJO is already manipulated or not.
- * Moreover it allows to get manipulation data about this class.
+ * Moreover it allows to get manipulation data about this class.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ClassChecker extends EmptyVisitor implements ClassVisitor, Opcodes {
@@ -46,33 +46,33 @@
/**
* Interfaces implemented by the component.
*/
- private List m_itfs = new ArrayList();
+ private List<String> m_itfs = new ArrayList<String>();
/**
* Field map [field name, type] discovered in the component class.
*/
- private Map m_fields = new HashMap();
+ private Map<String, String> m_fields = new HashMap<String, String>();
/**
* Method List of method descriptor discovered in the component class.
*/
- private List m_methods = new ArrayList()/* <MethodDesciptor> */;
-
+ private List<MethodDescriptor> m_methods = new ArrayList<MethodDescriptor>();
+
/**
* Super class if not java.lang.Object.
*/
private String m_superClass;
-
+
/**
* Class name.
*/
private String m_className;
-
+
/**
* List of visited inner class owned by the implementation class.
*/
- private List m_inners = new ArrayList();
-
+ private List<String> m_inners = new ArrayList<String>();
+
/**
* <code>true</code> if the class supports annotations.
* This enables the analysis of the code to find and moves annotations.
@@ -101,7 +101,7 @@
} else if ((access & ACC_STATIC) == ACC_STATIC) {
return null;
}
-
+
Type type = Type.getType(desc);
if (type.getSort() == Type.ARRAY) {
if (type.getInternalName().startsWith("L")) {
@@ -119,7 +119,7 @@
return null;
}
-
+
/**
* Add the inner class to the list of inner class to manipulate.
* The method checks that the inner class is really owned by the implementation class.
@@ -159,17 +159,17 @@
String superName, String[] interfaces) {
m_supportAnnotation = version > V1_4 && version < V1_1;
-
+
if (! superName.equals("java/lang/Object")) {
m_superClass = superName.replace('/', '.');
}
-
+
for (int i = 0; i < interfaces.length; i++) {
if (! interfaces[i].equals("org/apache/felix/ipojo/Pojo")) {
m_itfs.add(interfaces[i].replace('/', '.'));
}
}
-
+
m_className = name;
}
@@ -186,13 +186,13 @@
*/
public MethodVisitor visitMethod(int access, String name, String desc,
String signature, String[] exceptions) {
- if (!name.equals("<clinit>")) {
-
+ if (!name.equals("<clinit>")) {
+
if (name.equals("<init>")) {
final MethodDescriptor md = new MethodDescriptor("$init", desc);
m_methods.add(md);
if (m_supportAnnotation) {
- return new AnnotationCollector(md);
+ return new AnnotationCollector(md);
}
} else {
// no constructors.
@@ -203,21 +203,21 @@
final MethodDescriptor md = new MethodDescriptor(name, desc);
m_methods.add(md);
if (m_supportAnnotation) {
- return new AnnotationCollector(md);
+ return new AnnotationCollector(md);
}
}
}
-
- }
-
+
+ }
+
return null;
}
-
+
/**
* Get collected interfaces.
* @return the interfaces implemented by the component class.
*/
- public List getInterfaces() {
+ public List<String> getInterfaces() {
return m_itfs;
}
@@ -225,7 +225,7 @@
* Get collected fields.
* @return the field map [field_name, type].
*/
- public Map getFields() {
+ public Map<String, String> getFields() {
return m_fields;
}
@@ -233,21 +233,21 @@
* Get collected methods.
* @return the method list of [method, signature].
*/
- public List getMethods() {
+ public List<MethodDescriptor> getMethods() {
return m_methods;
}
-
+
public String getSuperClass() {
return m_superClass;
}
-
- public List getInnerClasses() {
+
+ public List<String> getInnerClasses() {
return m_inners;
}
-
+
/**
* This class collects annotations in a method.
- * This class creates an {@link AnnotationDescriptor}
+ * This class creates an {@link AnnotationDescriptor}
* if an annotation is found during the visit.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@@ -256,7 +256,7 @@
* The method descriptor of the visited method.
*/
private MethodDescriptor m_method;
-
+
/**
* Creates an annotation collector.
* @param md the method descriptor of the visited method.
@@ -264,7 +264,7 @@
private AnnotationCollector(MethodDescriptor md) {
m_method = md;
}
-
+
/**
* Visits an annotation.
* This class checks the visibility. If the annotation is visible,
@@ -295,10 +295,10 @@
}
return null;
}
-
-
+
+
}
-
+
/**
* Describes a method or constructor annotation.
* This allows creating a copy of the annotations found in the original class
@@ -325,24 +325,24 @@
/**
* The list of 'simple' attributes.
*/
- private List m_simples = new ArrayList(0);
+ private List<SimpleAttribute> m_simples = new ArrayList<SimpleAttribute>(0);
/**
* The list of attribute containing an
* enumeration value.
*/
- private List m_enums = new ArrayList(0);
+ private List<EnumAttribute> m_enums = new ArrayList<EnumAttribute>(0);
/**
* The list of attribute which are
* annotations.
*/
- private List m_nested = new ArrayList(0);
+ private List<AnnotationDescriptor> m_nested = new ArrayList<AnnotationDescriptor>(0);
/**
* The list of attribute which are
- * arrays.
+ * arrays.
*/
- private List m_arrays = new ArrayList(0);
-
-
+ private List<ArrayAttribute> m_arrays = new ArrayList<ArrayAttribute>(0);
+
+
/**
* Creates an annotation descriptor.
* This constructor is used for 'root' annotations.
@@ -353,7 +353,7 @@
m_name = name;
m_visible = visible;
}
-
+
/**
* Creates an annotation descriptor.
* This constructor is used for nested annotations.
@@ -423,35 +423,35 @@
public void visitEnum(String arg0, String arg1, String arg2) {
m_enums.add(new EnumAttribute(arg0, arg1, arg2));
}
-
+
/**
* Methods allowing to recreate the visited (stored) annotation
* into the destination method.
- * This method recreate the annotations itself and any other
+ * This method recreate the annotations itself and any other
* attributes.
* @param mv the method visitor visiting the destination method.
*/
public void visitAnnotation(MethodVisitor mv) {
AnnotationVisitor av = mv.visitAnnotation(m_name, m_visible);
for (int i = 0; i < m_simples.size(); i++) {
- ((SimpleAttribute) m_simples.get(i)).visit(av);
+ m_simples.get(i).visit(av);
}
for (int i = 0; i < m_enums.size(); i++) {
- ((EnumAttribute) m_enums.get(i)).visit(av);
+ m_enums.get(i).visit(av);
}
for (int i = 0; i < m_nested.size(); i++) {
- ((AnnotationDescriptor) m_nested.get(i)).visit(av);
+ m_nested.get(i).visit(av);
}
for (int i = 0; i < m_arrays.size(); i++) {
- ((ArrayAttribute) m_arrays.get(i)).visit(av);
+ m_arrays.get(i).visit(av);
}
av.visitEnd();
}
-
+
/**
* Methods allowing to recreate the visited (stored) parameter annotations
* into the destination method.
- * This method recreate the annotations itself and any other
+ * This method recreate the annotations itself and any other
* attributes.
* @param id the paramter id
* @param mv the method visitor visiting the destination method.
@@ -459,20 +459,20 @@
public void visitParameterAnnotation(int id, MethodVisitor mv) {
AnnotationVisitor av = mv.visitParameterAnnotation(id, m_name, m_visible);
for (int i = 0; i < m_simples.size(); i++) {
- ((SimpleAttribute) m_simples.get(i)).visit(av);
+ m_simples.get(i).visit(av);
}
for (int i = 0; i < m_enums.size(); i++) {
- ((EnumAttribute) m_enums.get(i)).visit(av);
+ m_enums.get(i).visit(av);
}
for (int i = 0; i < m_nested.size(); i++) {
- ((AnnotationDescriptor) m_nested.get(i)).visit(av);
+ m_nested.get(i).visit(av);
}
for (int i = 0; i < m_arrays.size(); i++) {
- ((ArrayAttribute) m_arrays.get(i)).visit(av);
+ m_arrays.get(i).visit(av);
}
av.visitEnd();
}
-
+
/**
* Method allowing to recreate the visited (stored) annotation
* into the destination annotation. This method is used only
@@ -483,23 +483,23 @@
public void visit(AnnotationVisitor mv) {
AnnotationVisitor av = mv.visitAnnotation(m_name, m_desc);
for (int i = 0; i < m_simples.size(); i++) {
- ((SimpleAttribute) m_simples.get(i)).visit(av);
+ m_simples.get(i).visit(av);
}
for (int i = 0; i < m_enums.size(); i++) {
- ((EnumAttribute) m_enums.get(i)).visit(av);
+ m_enums.get(i).visit(av);
}
for (int i = 0; i < m_nested.size(); i++) {
- ((AnnotationDescriptor) m_nested.get(i)).visit(av);
+ m_nested.get(i).visit(av);
}
for (int i = 0; i < m_arrays.size(); i++) {
- ((ArrayAttribute) m_arrays.get(i)).visit(av);
+ m_arrays.get(i).visit(av);
}
av.visitEnd();
}
-
-
+
+
}
-
+
/**
* Describes an array attribute.
* This class is able to visit an annotation array attribute, and to
@@ -514,8 +514,8 @@
/**
* The content of the parsed array.
*/
- private List m_content = new ArrayList();
-
+ private List<Object> m_content = new ArrayList<Object>();
+
/**
* Creates an array attribute.
* @param name the name of the attribute.
@@ -525,8 +525,8 @@
}
/**
- * Visits the content of the array. This method is called for
- * simple values.
+ * Visits the content of the array. This method is called for
+ * simple values.
* @param arg0 <code>null</code>
* @param arg1 the value
* @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
@@ -536,8 +536,8 @@
}
/**
- * Visits the content of the array. This method is called for
- * nested annotations (annotations contained in the array).
+ * Visits the content of the array. This method is called for
+ * nested annotations (annotations contained in the array).
* @param arg0 <code>null</code>
* @param arg1 the annotation descriptor
* @return an {@link AnnotationDescriptor} which creates a copy of
@@ -551,8 +551,8 @@
}
/**
- * Visits the content of the array. This method is called for
- * nested arrays (arrays contained in the array).
+ * Visits the content of the array. This method is called for
+ * nested arrays (arrays contained in the array).
* @param arg0 <code>null</code>
* @return an {@link ArrayDescriptor} which creates a copy of
* the contained array.
@@ -571,8 +571,8 @@
public void visitEnd() { }
/**
- * Visits the content of the array. This method is called for
- * enumeration values.
+ * Visits the content of the array. This method is called for
+ * enumeration values.
* @param arg0 <code>null</code>
* @param arg1 the enumeration descriptor
* @param arg2 the value
@@ -582,7 +582,7 @@
EnumAttribute ea = new EnumAttribute(null, arg1, arg2);
m_content.add(ea);
}
-
+
/**
* Recreates the visited array attribute. This method
* handle the generation of the object embedded in the
@@ -606,9 +606,9 @@
}
content.visitEnd();
}
-
+
}
-
+
/**
* Describes a simple attribute.
* This class is able to visit an annotation simple attribute, and to
@@ -624,7 +624,7 @@
* The value of the attribute.
*/
private Object m_value;
-
+
/**
* Creates a simple attribute.
* @param name the name of the attribute
@@ -634,7 +634,7 @@
m_name = name;
m_value = object;
}
-
+
/**
* Recreates the attribute on the given annotation.
* @param visitor the visitor on which the attribute needs
@@ -644,7 +644,7 @@
visitor.visit(m_name, m_value);
}
}
-
+
/**
* Describes an attribute. The value of this attribute is an enumerated
* value.
@@ -665,7 +665,7 @@
* The value of the attribute.
*/
private String m_value;
-
+
/**
* Creates a enumeration attribute.
* @param name the name of the attribute.
@@ -677,7 +677,7 @@
m_value = value;
m_desc = desc;
}
-
+
/**
* Recreates the attribute on the given annotation.
* @param visitor the visitor on which the attribute needs
@@ -686,7 +686,7 @@
public void visit(AnnotationVisitor visitor) {
visitor.visitEnum(m_name, m_desc, m_value);
}
-
+
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
index 7fec41e..144219c 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ConstructorCodeAdapter.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -30,35 +30,35 @@
/**
* Constructor Adapter.
* This class adds an instance manager argument (so switch variable index).
- * Moreover, it adapts field accesses to delegate accesses to the instance
+ * Moreover, it adapts field accesses to delegate accesses to the instance
* manager if needed.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ConstructorCodeAdapter extends GeneratorAdapter implements Opcodes {
- /**
+ /**
* The class containing the field.
* m_owner : String
*/
private String m_owner;
-
+
/**
* Is the super call detected ?
*/
private boolean m_superDetected;
-
+
/**
- * The super class.
+ * The super class.
*/
private String m_superClass;
-
+
/**
* Set of contained fields.
*/
- private Set m_fields;
+ private Set<String> m_fields;
- /**
+ /**
* PropertyCodeAdapter constructor.
* A new FiledCodeAdapter should be create for each method visit.
* @param mv the MethodVisitor
@@ -68,14 +68,14 @@
* @param desc the constructor descriptor
* @param name the name
*/
- public ConstructorCodeAdapter(final MethodVisitor mv, final String owner, Set fields, int access, String name, String desc, String superClass) {
+ public ConstructorCodeAdapter(final MethodVisitor mv, final String owner, Set<String> fields, int access, String name, String desc, String superClass) {
super(mv, access, name, desc);
m_owner = owner;
m_superDetected = false;
m_fields = fields;
m_superClass = superClass;
}
-
+
/**
* Visits an annotation.
* If the annotation is visible, the annotation is removed. In fact
@@ -97,7 +97,7 @@
}
- /**
+ /**
* Adapts field accesses.
* If the field is owned by the visited class:
* <ul>
@@ -129,7 +129,7 @@
}
super.visitFieldInsn(opcode, owner, name, desc);
}
-
+
/**
* Visits a method invocation instruction.
* After the super constructor invocation, insert the _setComponentManager invocation.
@@ -141,35 +141,35 @@
* @see org.objectweb.asm.MethodAdapter#visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
*/
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
-
+
// A method call is detected, check if it is the super call :
// the first init is not necessary the super call, so check that it is really the super class.
if (!m_superDetected && name.equals("<init>") && owner.equals(m_superClass)) {
- m_superDetected = true;
+ m_superDetected = true;
// The first invocation is the super call
// 1) Visit the super constructor :
-
- //mv.visitVarInsn(ALOAD, 0); The ALOAD 0 was already visited. This previous visit allows
+
+ //mv.visitVarInsn(ALOAD, 0); The ALOAD 0 was already visited. This previous visit allows
// Super constructor parameters.
mv.visitMethodInsn(opcode, owner, name, desc); // Super constructor invocation
-
- // 2) Load the object and the component manager argument
+
+ // 2) Load the object and the component manager argument
mv.visitVarInsn(ALOAD, 0);
//mv.visitVarInsn(ALOAD, Type.getArgumentTypes(m_constructorDesc).length);
mv.visitVarInsn(ALOAD, 1); // CM is always the first argument
- // 3) Initialize the field
+ // 3) Initialize the field
mv.visitMethodInsn(INVOKESPECIAL, m_owner, "_setInstanceManager", "(Lorg/apache/felix/ipojo/InstanceManager;)V");
-
- } else {
- mv.visitMethodInsn(opcode, owner, name, desc);
+
+ } else {
+ mv.visitMethodInsn(opcode, owner, name, desc);
}
}
-
+
/**
* Visits a variable instruction.
* This method increments the variable index if
* it is not <code>this</code> (i.e. 0). This increment
- * is due to the instance manager parameter added in the method
+ * is due to the instance manager parameter added in the method
* signature.
* @param opcode the opcode
* @param var the variable index
@@ -184,25 +184,25 @@
}
}
-
+
/**
* Visits an increment instruction.
* This method increments the variable index if
* it is not <code>this</code> (i.e. 0). This increment
- * is due to the instance manager parameter added in the method
+ * is due to the instance manager parameter added in the method
* signature.
* @param var the variable index
* @param increment the increment
* @see org.objectweb.asm.MethodAdapter#visitIincInsn(int, int)
*/
public void visitIincInsn(int var, int increment) {
- if (var != 0) {
- mv.visitIincInsn(var + 1, increment);
- } else {
+ if (var != 0) {
+ mv.visitIincInsn(var + 1, increment);
+ } else {
mv.visitIincInsn(var, increment); // Increment the current object ???
- }
+ }
}
-
+
/**
* Visits a local variable.
* Adds _manager and increment others variable indexes.
@@ -211,7 +211,7 @@
* @param name the variable name
* @param desc the variable descriptor
* @param signature the variable signature
- * @param start the beginning label
+ * @param start the beginning label
* @param end the ending label
* @param index the variable index
* @see org.objectweb.asm.MethodAdapter#visitLocalVariable(java.lang.String, java.lang.String, java.lang.String, org.objectweb.asm.Label, org.objectweb.asm.Label, int)
@@ -223,7 +223,7 @@
}
mv.visitLocalVariable(name, desc, signature, start, end, index + 1);
}
-
+
/**
* Visit max method.
* The stack size is incremented of 1. The
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassAdapter.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassAdapter.java
index 3eaece2..2a90496 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassAdapter.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassAdapter.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -31,16 +31,16 @@
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class InnerClassAdapter extends ClassAdapter implements Opcodes {
-
+
/**
* Implementation class name.
*/
private String m_outer;
-
+
/**
- * List of fields of the implementation class.
+ * List of fields of the implementation class.
*/
- private Set m_fields;
+ private Set<String> m_fields;
/**
* Creates the inner class adapter.
@@ -48,12 +48,12 @@
* @param outerClass outer class (implementation class)
* @param fields fields of the implementation class
*/
- public InnerClassAdapter(ClassVisitor arg0, String outerClass, Set fields) {
+ public InnerClassAdapter(ClassVisitor arg0, String outerClass, Set<String> fields) {
super(arg0);
m_outer = outerClass;
m_fields = fields;
}
-
+
/**
* Visits a method.
* This methods create a code visitor manipulating outer class field accesses.
@@ -68,7 +68,7 @@
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
return new MethodCodeAdapter(mv, m_outer, access, name, desc, m_fields);
- }
-
+ }
+
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassManipulator.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassManipulator.java
index 605ac23..a3f9799 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassManipulator.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/InnerClassManipulator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -37,18 +37,18 @@
* Outer class class name.
*/
private String m_outer;
-
+
/**
* Component class fields.
*/
- private Set m_fields;
+ private Set<String> m_fields;
/**
* Creates an inner class manipulator.
* @param classname : class name
* @param fields : fields
*/
- public InnerClassManipulator(String classname, Set fields) {
+ public InnerClassManipulator(String classname, Set<String> fields) {
m_outer = classname;
m_fields = fields;
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
index e1522ed..f7113f4 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
@@ -39,17 +39,17 @@
/**
* Store the visited fields : [name of the field, type of the field].
*/
- private Map m_fields;
+ private Map<String, String> m_fields;
/**
* Store the interface implemented by the class.
*/
- private List m_interfaces;
+ private List<String> m_interfaces;
/**
* Store the methods list.
*/
- private List m_methods;
+ private List<MethodDescriptor> m_methods;
/**
* Pojo super class.
@@ -127,10 +127,10 @@
elem.addElement(itf);
}
- for (Iterator it = m_fields.keySet().iterator(); it.hasNext();) {
+ for (Iterator<String> it = m_fields.keySet().iterator(); it.hasNext();) {
Element field = new Element("Field", "");
- String name = (String) it.next();
- String type = (String) m_fields.get(name);
+ String name = it.next();
+ String type = m_fields.get(name);
Attribute attName = new Attribute("name", name);
Attribute attType = new Attribute("type", type);
field.addAttribute(attName);
@@ -146,7 +146,7 @@
return elem;
}
- public Map getFields() {
+ public Map<String, String> getFields() {
return m_fields;
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCodeAdapter.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCodeAdapter.java
index 93f508f..5182977 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCodeAdapter.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCodeAdapter.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -36,14 +36,14 @@
* The owner class of the field. m_owner : String
*/
private String m_owner;
-
+
/**
* Contained fields.
*/
- private Set m_fields;
+ private Set<String> m_fields;
/**
- * MethodCodeAdapter constructor.
+ * MethodCodeAdapter constructor.
* @param mv : MethodVisitor
* @param owner : Name of the class
* @param access : Method access
@@ -51,7 +51,7 @@
* @param desc : Method descriptor
* @param fields : Contained fields
*/
- public MethodCodeAdapter(final MethodVisitor mv, final String owner, int access, String name, String desc, Set fields) {
+ public MethodCodeAdapter(final MethodVisitor mv, final String owner, int access, String name, String desc, Set<String> fields) {
super(mv, access, name, desc);
m_owner = owner;
m_fields = fields;
@@ -79,7 +79,7 @@
}
super.visitFieldInsn(opcode, owner, name, desc);
}
-
+
/**
* Visits an annotation.
* If the annotation is visible, the annotation is removed. In fact
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
index a4992a1..60cff80 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
@@ -19,7 +19,6 @@
package org.apache.felix.ipojo.manipulation;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -101,26 +100,26 @@
* Set of fields detected in the class.
* (this set is given by the previous analysis)
*/
- private Set m_fields;
+ private Set<String> m_fields;
/**
* List of methods contained in the class.
* This set contains method id.
*/
- private List m_methods = new ArrayList(); // Contains method id.
+ private List<String> m_methods = new ArrayList<String>();
/**
* List of fields injected as method flag in the class.
* This set contains field name generate from method id.
*/
- private List m_methodFlags = new ArrayList();
+ private List<String> m_methodFlags = new ArrayList<String>();
/**
* The list of methods visited during the previous analysis.
* This list allows getting annotations to move to generated
* method.
*/
- private List m_visitedMethods = new ArrayList();
+ private List<MethodDescriptor> m_visitedMethods = new ArrayList<MethodDescriptor>();
/**
* Set to <code>true</code> when a suitable constructor
@@ -140,7 +139,7 @@
* @param fields : fields map detected during the previous class analysis.
* @param methods : the list of the detected method during the previous class analysis.
*/
- public MethodCreator(ClassVisitor arg0, Map fields, List methods) {
+ public MethodCreator(ClassVisitor arg0, Map<String, String> fields, List<MethodDescriptor> methods) {
super(arg0);
m_fields = fields.keySet();
m_visitedMethods = methods;
@@ -219,7 +218,7 @@
MethodDescriptor md = getMethodDescriptor(name, desc);
if (md == null) {
- generateMethodHeader(access, name, desc, signature, exceptions, new ArrayList(0), new HashMap());
+ generateMethodHeader(access, name, desc, signature, exceptions, null, null);
} else {
generateMethodHeader(access, name, desc, signature, exceptions, md.getAnnotations(), md.getParameterAnnotations());
}
@@ -245,7 +244,7 @@
*/
private MethodDescriptor getMethodDescriptor(String name, String desc) {
for (int i = 0; i < m_visitedMethods.size(); i++) {
- MethodDescriptor md = (MethodDescriptor) m_visitedMethods.get(i);
+ MethodDescriptor md = m_visitedMethods.get(i);
if (md.getName().equals(name) && md.getDescriptor().equals(desc)) {
return md;
}
@@ -308,7 +307,7 @@
* @param exceptions : declared exception
* @param annotations : the annotations to move to this constructor.
*/
- private void generateConstructor(int access, String descriptor, String signature, String[] exceptions, List annotations, Map paramAnnotations) {
+ private void generateConstructor(int access, String descriptor, String signature, String[] exceptions, List<AnnotationDescriptor> annotations, Map<Integer, List<AnnotationDescriptor>> paramAnnotations) {
GeneratorAdapter mv = new GeneratorAdapter(
cv.visitMethod(access, "<init>", descriptor, signature, exceptions),
access, "<init>", descriptor);
@@ -326,19 +325,19 @@
// Move annotations
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
- AnnotationDescriptor ad = (AnnotationDescriptor) annotations.get(i);
+ AnnotationDescriptor ad = annotations.get(i);
ad.visitAnnotation(mv);
}
}
// Move parameter annotations if any
if (paramAnnotations != null && ! paramAnnotations.isEmpty()) {
- Iterator ids = paramAnnotations.keySet().iterator();
+ Iterator<Integer> ids = paramAnnotations.keySet().iterator();
while(ids.hasNext()) {
- Integer id = (Integer) ids.next();
- List ads = (List) paramAnnotations.get(id);
+ Integer id = ids.next();
+ List<AnnotationDescriptor> ads = paramAnnotations.get(id);
for (int i = 0; i < ads.size(); i++) {
- AnnotationDescriptor ad = (AnnotationDescriptor) ads.get(i);
+ AnnotationDescriptor ad = ads.get(i);
ad.visitParameterAnnotation(id.intValue(), mv);
}
}
@@ -360,7 +359,7 @@
* @param annotations : the annotations to move to this method.
* @param paramAnnotations : the parameter annotations to move to this method.
*/
- private void generateMethodHeader(int access, String name, String desc, String signature, String[] exceptions, List annotations, Map paramAnnotations) {
+ private void generateMethodHeader(int access, String name, String desc, String signature, String[] exceptions, List<AnnotationDescriptor> annotations, Map<Integer, List<AnnotationDescriptor>> paramAnnotations) {
GeneratorAdapter mv = new GeneratorAdapter(cv.visitMethod(access, name, desc, signature, exceptions), access, name, desc);
mv.visitCode();
@@ -453,19 +452,19 @@
// Move annotations
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
- AnnotationDescriptor ad = (AnnotationDescriptor) annotations.get(i);
+ AnnotationDescriptor ad = annotations.get(i);
ad.visitAnnotation(mv);
}
}
// Move parameter annotations
if (paramAnnotations != null && ! paramAnnotations.isEmpty()) {
- Iterator ids = paramAnnotations.keySet().iterator();
+ Iterator<Integer> ids = paramAnnotations.keySet().iterator();
while(ids.hasNext()) {
- Integer id = (Integer) ids.next();
- List ads = (List) paramAnnotations.get(id);
+ Integer id = ids.next();
+ List<AnnotationDescriptor> ads = paramAnnotations.get(id);
for (int i = 0; i < ads.size(); i++) {
- AnnotationDescriptor ad = (AnnotationDescriptor) ads.get(i);
+ AnnotationDescriptor ad = ads.get(i);
ad.visitParameterAnnotation(id.intValue(), mv);
}
}
@@ -626,9 +625,9 @@
mv.visitVarInsn(ALOAD, 2);
Label endif = new Label();
mv.visitJumpInsn(IFNULL, endif);
- Iterator it = m_fields.iterator();
+ Iterator<String> it = m_fields.iterator();
while (it.hasNext()) {
- String field = (String) it.next();
+ String field = it.next();
mv.visitVarInsn(ALOAD, 2);
mv.visitLdcInsn(field);
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "contains", "(Ljava/lang/Object;)Z");
@@ -651,7 +650,7 @@
mv.visitJumpInsn(IFNULL, endif2);
for (int i = 0; i < m_methods.size(); i++) {
- String methodId = (String) m_methods.get(i);
+ String methodId = m_methods.get(i);
if (!methodId.equals("<init>")) {
mv.visitVarInsn(ALOAD, 2);
mv.visitLdcInsn(methodId);
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodDescriptor.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodDescriptor.java
index 6876f06..c715010 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodDescriptor.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodDescriptor.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -48,23 +48,23 @@
* Argument types.
*/
private String[] m_arguments;
-
+
/**
* The descriptor of the method.
*/
private String m_desc;
-
-
+
+
/**
* The list of {@link AnnotationDescriptor} attached to this
- * method.
+ * method.
*/
- private List m_annotations;
-
+ private List<AnnotationDescriptor> m_annotations;
+
/**
- * The association argument (number) - {@link AnnotationDescriptor}.
+ * The association argument (number) - {@link AnnotationDescriptor}.
*/
- private Map/*<Integer, List<AnnotationDescriptor>>*/ m_parameterAnnotations = new HashMap/*<Integer, List<AnnotationDescriptor>>*/();
+ private Map<Integer, List<AnnotationDescriptor>> m_parameterAnnotations = new HashMap<Integer, List<AnnotationDescriptor>>();
/**
* Constructor.
@@ -83,39 +83,39 @@
m_arguments[i] = getType(args[i]);
}
}
-
+
/**
* Add an annotation to the current method.
* @param ann annotation to add
*/
public void addAnnotation(AnnotationDescriptor ann) {
if (m_annotations == null) {
- m_annotations = new ArrayList();
+ m_annotations = new ArrayList<AnnotationDescriptor>();
}
m_annotations.add(ann);
}
-
+
/**
* Add an annotation to the current method.
* @param ann annotation to add
*/
public void addParameterAnnotation(int id, AnnotationDescriptor ann) {
- List list = (List) m_parameterAnnotations.get(new Integer(id));
+ List<AnnotationDescriptor> list = m_parameterAnnotations.get(new Integer(id));
if (list == null) {
- list = new ArrayList();
+ list = new ArrayList<AnnotationDescriptor>();
m_parameterAnnotations.put(new Integer(id), list);
}
list.add(ann);
}
-
- public List getAnnotations() {
+
+ public List<AnnotationDescriptor> getAnnotations() {
return m_annotations;
}
-
- public Map getParameterAnnotations() {
+
+ public Map<Integer, List<AnnotationDescriptor>> getParameterAnnotations() {
return m_parameterAnnotations;
}
-
+
public String getDescriptor() {
return m_desc;
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
index 6527355..9b6bb94 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
@@ -74,14 +74,14 @@
* Map of [element ids, element].
* This map is used to easily get an already created element.
*/
- private Map m_ids = new HashMap();
+ private Map<String, Element> m_ids = new HashMap<String, Element>();
/**
* Map of [element, referto].
* This map is used to recreate the element hierarchy.
* Stored element are added under referred element.
*/
- private Map m_elements = new HashMap();
+ private Map<Element, String> m_elements = new HashMap<Element, String>();
/**
* Instance declaration.
@@ -126,8 +126,8 @@
* @see org.objectweb.asm.ClassAdapter#visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
*/
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
- m_ids = new HashMap();
- m_elements = new HashMap();
+ m_ids = new HashMap<String, Element>();
+ m_elements = new HashMap<Element, String>();
m_className = name;
}
@@ -225,16 +225,16 @@
}
if (! m_containsComponentAnnotation) {
- m_ignoredBecauseOfMissingComponent = true;
+ m_ignoredBecauseOfMissingComponent = true;
return;
}
// Recompute the tree
- Set elems = getElements().keySet();
- Iterator it = elems.iterator();
+ Set<Element> elems = getElements().keySet();
+ Iterator<Element> it = elems.iterator();
while (it.hasNext()) {
- Element current = (Element) it.next();
- String reference = (String) getElements().get(current);
+ Element current = it.next();
+ String reference = getElements().get(current);
if (reference == null) {
m_elem.addElement(current);
} else {
@@ -249,11 +249,11 @@
}
}
- protected Map getIds() {
+ protected Map<String, Element> getIds() {
return m_ids;
}
- protected Map getElements() {
+ protected Map<Element, String> getElements() {
return m_elements;
}
@@ -317,13 +317,13 @@
if (arg0.equals("specifications")) {
return new InterfaceArrayVisitor();
} else if (arg0.equals("properties")) {
- // Create a new simple visitor to visit the nested ServiceProperty annotations
- // Collected properties are collected in m_prov
- return new EmptyVisitor() {
- public AnnotationVisitor visitAnnotation(String ignored, String desc) {
- return new PropertyAnnotationParser(m_prov);
- }
- };
+ // Create a new simple visitor to visit the nested ServiceProperty annotations
+ // Collected properties are collected in m_prov
+ return new EmptyVisitor() {
+ public AnnotationVisitor visitAnnotation(String ignored, String desc) {
+ return new PropertyAnnotationParser(m_prov);
+ }
+ };
} else {
return null;
}
@@ -469,7 +469,7 @@
*/
public void visit(String arg0, Object arg1) {
if (arg0.equals("public_factory") || arg0.equals("publicFactory")) {
- // public_factory is deprecated, but must sill be supported
+ // public_factory is deprecated, but must sill be supported
m_factory = arg1.toString();
return;
}
@@ -494,7 +494,7 @@
return;
}
if (arg0.equals("factory_method") || arg0.equals("factoryMethod")) {
- // factory_method is deprecated, but must still be supported.
+ // factory_method is deprecated, but must still be supported.
m_method = arg1.toString();
return;
}
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
index 13ced4c..e7f18cd 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
@@ -18,8 +18,6 @@
*/
package org.apache.felix.ipojo.manipulation.annotations;
-import java.awt.image.renderable.ParameterBlock;
-
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
import org.objectweb.asm.AnnotationVisitor;
@@ -63,9 +61,9 @@
* @see org.objectweb.asm.commons.EmptyVisitor#visitParameterAnnotation(int, java.lang.String, boolean)
*/
public AnnotationVisitor visitParameterAnnotation(int index, String annotation,
- boolean visible) {
- if (m_name.equals("<init>")) {
- if (annotation.equals("Lorg/apache/felix/ipojo/annotations/Property;")) {
+ boolean visible) {
+ if (m_name.equals("<init>")) {
+ if (annotation.equals("Lorg/apache/felix/ipojo/annotations/Property;")) {
return processProperty(true, index);
}
if (annotation.equals("Lorg/apache/felix/ipojo/annotations/Requires;")) {
@@ -77,13 +75,13 @@
elem.addAttribute(new Attribute("index", "" + index));
return new CustomAnnotationVisitor(elem, m_collector, true, false, index, m_descriptor);
}
- }
- return super.visitParameterAnnotation(index, annotation, visible);
- }
+ }
+ return super.visitParameterAnnotation(index, annotation, visible);
+ }
- /**
+ /**
* Visit method annotations.
* @param arg0 : annotation name.
* @param arg1 : is the annotation visible at runtime.
@@ -302,7 +300,7 @@
}
private BindAnnotationParser(int index) {
- m_index = index;
+ m_index = index;
}
/**
@@ -360,10 +358,10 @@
} else if (m_name != null && m_name.startsWith("unbind")) {
m_id = m_name.substring("unbind".length());
} else if (m_name != null && m_name.startsWith("modified")) {
- m_id = m_name.substring("modified".length());
+ m_id = m_name.substring("modified".length());
} else if (m_index != -1) {
- m_id = "" + m_index;
- } else {
+ m_id = "" + m_index;
+ } else {
System.err.println("Cannot determine the id of the " + m_type + " method : " + m_name);
return;
}
@@ -471,12 +469,12 @@
}
if (m_name != null) {
- Element method = new Element("callback", "");
- method.addAttribute(new Attribute("method", m_name));
- method.addAttribute(new Attribute("type", m_type));
- req.addElement(method);
+ Element method = new Element("callback", "");
+ method.addAttribute(new Attribute("method", m_name));
+ method.addAttribute(new Attribute("type", m_type));
+ req.addElement(method);
} else {
- req.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_index)));
+ req.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_index)));
}
m_collector.getIds().put(m_id, req);
@@ -572,15 +570,15 @@
* @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
*/
public void visitEnd() {
- // If neither name not id, try to extract the name
+ // If neither name not id, try to extract the name
if (m_name == null && m_id == null && m_method.startsWith("set")) {
m_name = m_method.substring("set".length());
m_id = m_name;
// Else align the two values
} else if (m_name != null && m_id == null) {
- m_id = m_name;
+ m_id = m_name;
} else if (m_id != null && m_name == null) {
- m_name = m_id;
+ m_name = m_id;
}
Element[] props = m_parent.getElements("Property");
@@ -608,8 +606,8 @@
}
if (m_isParameterAnnotation) {
- String t = Type.getArgumentTypes(m_descriptor)[m_index].getClassName();
- prop.addAttribute(new Attribute("type", t));
+ String t = Type.getArgumentTypes(m_descriptor)[m_index].getClassName();
+ prop.addAttribute(new Attribute("type", t));
prop.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_index)));
} else {
prop.addAttribute(new Attribute("method", m_method));
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java
index 0048a13..68deec4 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java
@@ -20,9 +20,7 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.apache.felix.ipojo.manipulation.InnerClassManipulator;
import org.apache.felix.ipojo.manipulation.Manipulator;
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java
index 3fb4aa5..120f541 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java
@@ -18,9 +18,6 @@
*/
package org.apache.felix.ipojo.manipulator;
-import java.util.List;
-import java.util.Set;
-
import org.apache.felix.ipojo.manipulator.util.Strings;
import org.apache.felix.ipojo.metadata.Element;
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
index 6c0171b..a9a3cae 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
@@ -98,7 +98,7 @@
/**
* @return all the errors (fatal) reported by the manipulation process.
*/
- public List getErrors() {
+ public List<String> getErrors() {
// Simple delegation for backward compatibility
return m_reporter.getErrors();
}
@@ -106,7 +106,7 @@
/**
* @return all the warnings (non fatal) reported by the manipulation process.
*/
- public List getWarnings() {
+ public List<String> getWarnings() {
// Simple delegation for backward compatibility
return m_reporter.getWarnings();
}
@@ -207,7 +207,7 @@
* @param manifestFile the manifest file. <code>null</code> to use directory/META-INF/MANIFEST.mf
*/
public void directoryPojoization(File directory, File metadataFile, File manifestFile) {
- // Get the metadata.xml location if not null
+ // Get the metadata.xml location if not null
MetadataProvider provider = new EmptyMetadataProvider();
if (metadataFile != null) {
FileMetadataProvider fileMetadataProvider = new FileMetadataProvider(metadataFile, m_reporter);
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/QuotedTokenizer.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/QuotedTokenizer.java
index 862604c..f9054c6 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/QuotedTokenizer.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/QuotedTokenizer.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -22,7 +22,7 @@
import java.util.List;
/**
- * Parse on OSGi Manifest clause.
+ * Parse on OSGi Manifest clause.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class QuotedTokenizer {
@@ -45,7 +45,7 @@
* Does the tokenizer returns token.
*/
boolean m_returnTokens;
-
+
/**
* Peek.
*/
@@ -187,8 +187,8 @@
* Get token list.
* @return the list of token.
*/
- public List getTokenSet() {
- List list = new ArrayList();
+ public List<String> getTokenSet() {
+ List<String> list = new ArrayList<String>();
String token = nextToken();
while (token != null) {
list.add(token);
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceStore.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceStore.java
index a3cd1f2..82abde6 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceStore.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceStore.java
@@ -19,10 +19,9 @@
package org.apache.felix.ipojo.manipulator;
-import org.apache.felix.ipojo.metadata.Element;
-
import java.io.IOException;
-import java.util.jar.Manifest;
+
+import org.apache.felix.ipojo.metadata.Element;
/**
* Abstract input/output for the manipulation process.
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStore.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStore.java
index a92e738..f458b1b 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStore.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStore.java
@@ -18,15 +18,6 @@
*/
package org.apache.felix.ipojo.manipulator.store;
-import org.apache.felix.ipojo.manipulator.ResourceStore;
-import org.apache.felix.ipojo.manipulator.ResourceVisitor;
-import org.apache.felix.ipojo.manipulator.store.mapper.FileSystemResourceMapper;
-import org.apache.felix.ipojo.manipulator.store.mapper.IdentityResourceMapper;
-import org.apache.felix.ipojo.manipulator.util.Metadatas;
-import org.apache.felix.ipojo.manipulator.util.Streams;
-import org.apache.felix.ipojo.manipulator.util.Strings;
-import org.apache.felix.ipojo.metadata.Element;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -35,6 +26,14 @@
import java.util.Collections;
import java.util.jar.Manifest;
+import org.apache.felix.ipojo.manipulator.ResourceStore;
+import org.apache.felix.ipojo.manipulator.ResourceVisitor;
+import org.apache.felix.ipojo.manipulator.store.mapper.FileSystemResourceMapper;
+import org.apache.felix.ipojo.manipulator.store.mapper.IdentityResourceMapper;
+import org.apache.felix.ipojo.manipulator.util.Metadatas;
+import org.apache.felix.ipojo.manipulator.util.Streams;
+import org.apache.felix.ipojo.metadata.Element;
+
/**
* A {@link DirectoryResourceStore} knows how to read and write
* resources from (to respectively) a File directory.
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ManifestBuilder.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ManifestBuilder.java
index f33aab5..4e5e081 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ManifestBuilder.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ManifestBuilder.java
@@ -19,11 +19,9 @@
package org.apache.felix.ipojo.manipulator.store;
import java.util.Collection;
-import java.util.List;
import java.util.Set;
import java.util.jar.Manifest;
-import org.apache.felix.ipojo.manipulator.render.MetadataFilter;
import org.apache.felix.ipojo.metadata.Element;
/**
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilder.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilder.java
index c6e7902..4bd08e2 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilder.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilder.java
@@ -102,8 +102,8 @@
* @param att : the manifest attribute list to modify.
*/
private void setImports(Attributes att) {
- Map imports = parseHeader(att.getValue("Import-Package"));
- Map ver = new TreeMap();
+ Map<String, Map<String, String>> imports = parseHeader(att.getValue("Import-Package"));
+ Map<String, String> ver = new TreeMap<String, String>();
ver.put("version", Pojoization.IPOJO_PACKAGE_VERSION);
if (!imports.containsKey("org.apache.felix.ipojo")) {
imports.put("org.apache.felix.ipojo", ver);
@@ -112,12 +112,12 @@
imports.put("org.apache.felix.ipojo.architecture", ver);
}
if (!imports.containsKey("org.osgi.service.cm")) {
- Map verCM = new TreeMap();
+ Map<String, String> verCM = new TreeMap<String, String>();
verCM.put("version", "1.2");
imports.put("org.osgi.service.cm", verCM);
}
if (!imports.containsKey("org.osgi.service.log")) {
- Map verCM = new TreeMap();
+ Map<String, String> verCM = new TreeMap<String, String>();
verCM.put("version", "1.3");
imports.put("org.osgi.service.log", verCM);
}
@@ -175,18 +175,18 @@
* @param value String to parse.
* @return parsed map.
*/
- private Map parseHeader(String value) {
+ private Map<String, Map<String, String>> parseHeader(String value) {
if (value == null || value.trim().length() == 0) {
- return new HashMap();
+ return new HashMap<String, Map<String, String>>();
}
- Map result = new HashMap();
+ Map<String, Map<String, String>> result = new HashMap<String, Map<String, String>>();
QuotedTokenizer qt = new QuotedTokenizer(value, ";=,");
char del;
do {
boolean hadAttribute = false;
- Map clause = new HashMap();
- List aliases = new ArrayList();
+ Map<String, String> clause = new HashMap<String, String>();
+ List<String> aliases = new ArrayList<String>();
aliases.add(qt.nextToken());
del = qt.getSeparator();
while (del == ';') {
@@ -203,7 +203,7 @@
hadAttribute = true;
}
}
- for (Iterator i = aliases.iterator(); i.hasNext();) {
+ for (Iterator<String> i = aliases.iterator(); i.hasNext();) {
result.put(i.next(), clause);
}
} while (del == ',');
@@ -217,7 +217,7 @@
* @param allowedDirectives list of allowed directives.
* @return the clauses
*/
- private String printClauses(Map exports, String allowedDirectives) {
+ private String printClauses(Map<String, Map<String, String>> exports, String allowedDirectives) {
StringBuffer sb = new StringBuffer();
String del = "";
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapper.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapper.java
index a571473..c2a2b02 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapper.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapper.java
@@ -18,11 +18,10 @@
*/
package org.apache.felix.ipojo.manipulator.store.mapper;
-import org.apache.felix.ipojo.manipulator.store.ResourceMapper;
-import org.apache.felix.ipojo.manipulator.util.Strings;
-
import java.io.File;
+import org.apache.felix.ipojo.manipulator.store.ResourceMapper;
+
/**
* ResourceMapper mapping from and to system specific path..
*
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Collections5.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Collections5.java
index fe95631..84f5084 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Collections5.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Collections5.java
@@ -46,6 +46,7 @@
* @throws NullPointerException if <tt>original</tt> is null
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <T> T[] copyOf(T[] original, int newLength) {
return (T[]) copyOf(original, newLength, original.getClass());
}
@@ -73,6 +74,7 @@
* @since 1.6
*/
public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
+ @SuppressWarnings("unchecked")
T[] copy = ((Object) newType == (Object) Object[].class)
? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Metadatas.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Metadatas.java
index 94f1c2e..ce072fc 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Metadatas.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Metadatas.java
@@ -18,18 +18,12 @@
*/
package org.apache.felix.ipojo.manipulator.util;
-import org.apache.felix.ipojo.metadata.Element;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.felix.ipojo.metadata.Element;
+
/**
* {@code Streams} is a utility class that helps to manipulate streams.
*
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Strings.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Strings.java
index 68357de..597903a 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Strings.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Strings.java
@@ -18,7 +18,6 @@
*/
package org.apache.felix.ipojo.manipulator.util;
-import java.io.File;
/**
* {@code Strings} is a utility class that helps to manipulate String.