X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finspector%2Fjava%2Fstructure%2FClassDescriptor.java;h=2247a77e476d408b1425c19f04f12083c7381fd8;hb=033fa99bac62adc18414cb4cb97c4be02abcb7e2;hp=a424897ea65d788e385b9883efcf0b7538e168db;hpb=d140a5c445361927abe4fe3a90e6ce95cd6530c3;p=javainspect.git diff --git a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java old mode 100644 new mode 100755 index a424897..2247a77 --- a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java +++ b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassDescriptor.java @@ -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 null 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 + * true 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; }