Changed license to LGPLv3.
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / structure / ClassDescriptor.java
old mode 100644 (file)
new mode 100755 (executable)
index a424897..2247a77
@@ -1,10 +1,10 @@
 /*
  * JavaInspect - Utility to visualize java software
- * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2013-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
  * 
  * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
  */
 
 package eu.svjatoslav.inspector.java.structure;
@@ -308,6 +308,19 @@ public class ClassDescriptor implements GraphElement {
                return null;
        }
 
+       /**
+        * Returns field with given name (case is ignored). Or <code>null</code> if
+        * field is not found.
+        */
+       public FieldDescriptor getFieldIgnoreCase(final String fieldToSearch) {
+
+               for (final String fieldName : nameToFieldMap.keySet())
+                       if (fieldToSearch.equalsIgnoreCase(fieldName))
+                               return nameToFieldMap.get(fieldName);
+
+               return null;
+       }
+
        @Override
        public String getGraphId() {
                final String result = "class_"
@@ -347,16 +360,6 @@ public class ClassDescriptor implements GraphElement {
                return result;
        }
 
-       public String getPackageName() {
-
-               final int i = fullyQualifiedName.lastIndexOf('.');
-
-               if (i == -1)
-                       return "";
-
-               return fullyQualifiedName.substring(0, i).replace("[L", "");
-       }
-
        // public String getReadableName() {
        //
        // // do not print full class name for well known system classes
@@ -371,6 +374,16 @@ public class ClassDescriptor implements GraphElement {
        // return fullyQualifiedName;
        // }
 
+       public String getPackageName() {
+
+               final int i = fullyQualifiedName.lastIndexOf('.');
+
+               if (i == -1)
+                       return "";
+
+               return fullyQualifiedName.substring(0, i).replace("[L", "");
+       }
+
        public String getParentClassesName() {
                int i = fullyQualifiedName.lastIndexOf('.');
                final String fullClassName = fullyQualifiedName.substring(i + 1);
@@ -389,6 +402,19 @@ public class ClassDescriptor implements GraphElement {
                return superClassColor;
        }
 
+       /**
+        * Checks if class has field with given name (case is ignored). Returns
+        * <code>true</code> if such field is found.
+        */
+       public boolean hasFieldIgnoreCase(final String fieldToSearch) {
+
+               for (final String fieldName : nameToFieldMap.keySet())
+                       if (fieldToSearch.equalsIgnoreCase(fieldName))
+                               return true;
+
+               return false;
+       }
+
        public void hide() {
                isShown = false;
        }