Index: AbstractJava2UMLConverter.java
===================================================================
RCS file: /cvsroot/java2uml/plugins/org.topcased.java.reverse/src/org/topcased/java/reverse/AbstractJava2UMLConverter.java,v
retrieving revision 1.1
diff -u -r1.1 AbstractJava2UMLConverter.java
--- AbstractJava2UMLConverter.java	28 Aug 2008 13:52:08 -0000	1.1
+++ AbstractJava2UMLConverter.java	6 Mar 2009 17:44:53 -0000
@@ -15,6 +15,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
+import java.util.regex.Matcher;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
@@ -38,13 +39,18 @@
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jdt.core.Signature;
 import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.BehavioralFeature;
 import org.eclipse.uml2.uml.Class;
 import org.eclipse.uml2.uml.Classifier;
 import org.eclipse.uml2.uml.ClassifierTemplateParameter;
 import org.eclipse.uml2.uml.DataType;
 import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.Feature;
 import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.LiteralBoolean;
+import org.eclipse.uml2.uml.LiteralInteger;
+import org.eclipse.uml2.uml.LiteralString;
 import org.eclipse.uml2.uml.Model;
 import org.eclipse.uml2.uml.NamedElement;
 import org.eclipse.uml2.uml.Namespace;
@@ -54,15 +60,19 @@
 import org.eclipse.uml2.uml.Parameter;
 import org.eclipse.uml2.uml.ParameterableElement;
 import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.RedefinableTemplateSignature;
 import org.eclipse.uml2.uml.StructuredClassifier;
 import org.eclipse.uml2.uml.TemplateParameter;
 import org.eclipse.uml2.uml.TemplateSignature;
 import org.eclipse.uml2.uml.Type;
 import org.eclipse.uml2.uml.UMLFactory;
 import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.ValueSpecification;
 import org.eclipse.uml2.uml.VisibilityKind;
 import org.topcased.java.reverse.internal.ReversePlugin;
 
+import sun.misc.Regexp;
+
 /**
  * the basic converter class defines a basic converting flow and provides support methods
  */
@@ -106,7 +116,7 @@
         {
             throwCoreException("The resource can't be null.");
         }
-        
+
         switch (javaElement.getElementType())
         {
             case IJavaElement.JAVA_PROJECT:
@@ -306,6 +316,17 @@
     }
 
     /**
+     * Checks for quallified name.
+     * 
+     * @param name
+     * @return
+     */
+    protected boolean isQuallifiedName(String name)
+    {
+        return name.indexOf(".") != -1;
+    }
+
+    /**
      * Find a type in a package, checks the package, in all other packages, in all imported packages. Finally test if it
      * is a generic type.
      * 
@@ -318,6 +339,11 @@
         Type type = null;
         if (typeName != null)
         {
+            if (isQuallifiedName(typeName))
+            {
+                typeName = quallifiedNametoSimpelTypeName(typeName);
+            }
+
             NamedElement element = packageObject.getMember(typeName);
             if (element instanceof Type)
             {
@@ -334,7 +360,7 @@
             {
                 return null;
             }
-            
+
             if (type == null)
             {
                 type = findType(model, typeName, true);
@@ -352,6 +378,19 @@
         return type;
     }
 
+    private String quallifiedNametoSimpelTypeName(String typeName)
+    {
+        String name = "";
+        String fullName = typeName;
+        int dotIndex = fullName.lastIndexOf('.');
+        if (dotIndex > 0)
+        {
+            name = fullName.substring(dotIndex + 1);
+        }
+
+        return name;
+    }
+
     /**
      * A lookup for the root package.
      * 
@@ -371,7 +410,7 @@
         {
             parentPackage = (Package) parentPackage.getOwner();
         }
-            
+
         return parentPackage;
     }
 
@@ -797,7 +836,7 @@
     }
 
     /**
-     * Update the visiblilty.
+     * Update the visiblilty. Set the visibility of
      * 
      * @param element
      * @param flags
@@ -805,7 +844,35 @@
      */
     protected void update(NamedElement element, int flags) throws JavaModelException
     {
-        // TODO : the java spec stated that interfaces methods has the same visiblity as the interface if not specified
+        if (Flags.isAbstract(flags))
+        {
+            if (element instanceof Classifier)
+            {
+                Classifier cl = (Classifier) element;
+                cl.setIsAbstract(true);
+            }
+            else if (element instanceof BehavioralFeature)
+            {
+                BehavioralFeature bf = (BehavioralFeature) element;
+                bf.setIsAbstract(true);
+            }
+        }
+
+        if (Flags.isStatic(flags))
+        {
+            if (element instanceof BehavioralFeature)
+            {
+                BehavioralFeature bf = (BehavioralFeature) element;
+                bf.setIsStatic(true);
+            }
+            else if (element instanceof Feature)
+            {
+                Feature feature = (Feature) element;
+                feature.setIsStatic(true);
+            }
+
+        }
+
         if (Flags.isPrivate(flags))
         {
             element.setVisibility(VisibilityKind.PRIVATE_LITERAL);
@@ -820,7 +887,26 @@
         }
         else if (Flags.isPackageDefault(flags))
         {
-            element.setVisibility(VisibilityKind.PACKAGE_LITERAL);
+            if (element instanceof Property)
+            {
+                Property property = (Property) element;
+                if (property.getOwner() instanceof Interface)
+                {
+                    Interface i = (Interface) property.getOwner();
+                    property.setVisibility(i.getVisibility());
+                }
+            }
+            else if (element instanceof Operation)
+            {
+                Operation op = (Operation) element;
+                if (op.getOwner() instanceof Interface)
+                {
+                    Interface i = (Interface) op.getOwner();
+                    op.setVisibility(i.getVisibility());
+                }
+            }
+            else
+                element.setVisibility(VisibilityKind.PACKAGE_LITERAL);
         }
     }
 
@@ -1080,6 +1166,11 @@
         }
 
         Property propertyObject = UMLFactory.eINSTANCE.createProperty();
+        if (isGenericType(fieldType))
+        {
+            // TODO : find the explicit type and define a template parameter
+            // extractGenericTypesFromCurrentSignature(fieldTypeSig);
+        }
         propertyObject.setName(fieldName);
         if (fieldType != null)
         {
@@ -1088,9 +1179,57 @@
 
         update(propertyObject, field.getFlags());
 
+        if (field.getConstant() != null)
+        {
+            if (field.getConstant() instanceof String)
+            {
+                LiteralString defaultValue = (LiteralString) propertyObject.createDefaultValue("", propertyObject.getType(), UMLFactory.eINSTANCE.createLiteralString().eClass());
+                defaultValue.setValue((String) field.getConstant());
+            }
+            else if (field.getConstant() instanceof Integer)
+            {
+                LiteralInteger defaultValue = (LiteralInteger) propertyObject.createDefaultValue("", propertyObject.getType(), UMLFactory.eINSTANCE.createLiteralInteger().eClass());
+                defaultValue.setValue((Integer) field.getConstant());
+            }
+            else if (field.getConstant() instanceof Boolean)
+            {
+                LiteralBoolean defaultValue = (LiteralBoolean) propertyObject.createDefaultValue("", propertyObject.getType(), UMLFactory.eINSTANCE.createLiteralBoolean().eClass());
+                defaultValue.setValue((Boolean) field.getConstant());
+            }
+        }
+
         return propertyObject;
     }
 
+    private String[] extractGenericTypesFromCurrentSignature(String fieldTypeSig)
+    {
+        // TODO a regular expressen to extract the template parareters
+        // <\\s*((\\w*)\\s*[,]{0,1})*\\s*>
+        String pattern = "[.]*<(.)*[,]>;";
+        int start = fieldTypeSig.indexOf("<");
+        int end = fieldTypeSig.indexOf(">");
+        if (start == -1 || end == -1)
+            return null;
+
+        String generics = fieldTypeSig.substring(start + 1, end);
+        String[] types = generics.split(";");
+        // TODO : later wrk on, we got the type array now to return
+        return types;
+    }
+
+    private boolean isGenericType(Type type)
+    {
+        EList<Element> ownedElements = type.getOwnedElements();
+        for (Element element : ownedElements)
+        {
+            if (element instanceof RedefinableTemplateSignature)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Creates properties in an interface.
      * 
