diff options
author | Matthew Davis | 2010-08-18 22:53:50 +0000 |
---|---|---|
committer | Matthew Davis | 2010-08-18 22:53:50 +0000 |
commit | 356bcdf15dc57bf186b43c1eb9f5d5e1c4b6b309 (patch) | |
tree | 2c7e6c9d2473e4d15038132e89ff1e012b2f6d8d | |
parent | f30ce213fc37ee4017317c17491a1b4145847838 (diff) | |
download | org.eclipse.stem-356bcdf15dc57bf186b43c1eb9f5d5e1c4b6b309.tar.gz org.eclipse.stem-356bcdf15dc57bf186b43c1eb9f5d5e1c4b6b309.tar.xz org.eclipse.stem-356bcdf15dc57bf186b43c1eb9f5d5e1c4b6b309.zip |
FindBugs: Adding null check
git-svn-id: http://dev.eclipse.org/svnroot/technology/org.eclipse.stem/trunk@941 92a21009-5b66-0410-b83a-dc787c41c6e9
-rw-r--r-- | org.eclipse.stem.definitions/src/org/eclipse/stem/definitions/LocationUtility.java | 113 |
1 files changed, 59 insertions, 54 deletions
diff --git a/org.eclipse.stem.definitions/src/org/eclipse/stem/definitions/LocationUtility.java b/org.eclipse.stem.definitions/src/org/eclipse/stem/definitions/LocationUtility.java index f67705f12..4f714c348 100644 --- a/org.eclipse.stem.definitions/src/org/eclipse/stem/definitions/LocationUtility.java +++ b/org.eclipse.stem.definitions/src/org/eclipse/stem/definitions/LocationUtility.java @@ -53,20 +53,21 @@ public class LocationUtility { } catch(Exception e) { e.printStackTrace(); } - for(IResource r:models) { - // ignore system files - if(r.getName().startsWith(".")) continue; - - try { - URI uri = URI.createURI(r.getLocationURI().toString()); - Identifiable id = Utility.getIdentifiable(uri); - if(id instanceof Model) processModel((Model)id); - - } catch(Exception e) { - // Skip bad file + if (models != null) { + for(IResource r:models) { + // ignore system files + if(r.getName().startsWith(".")) continue; + + try { + URI uri = URI.createURI(r.getLocationURI().toString()); + Identifiable id = Utility.getIdentifiable(uri); + if(id instanceof Model) processModel((Model)id); + + } catch(Exception e) { + // Skip bad file + } } - - } + } IContainer graphsFolder = project.getFolder("graphs"); IResource[] graphs = null; @@ -75,20 +76,22 @@ public class LocationUtility { } catch(Exception e) { e.printStackTrace(); } - for(IResource r:graphs) { - // ignore system files - if(r.getName().startsWith(".")) continue; - - try { - URI uri = URI.createURI(r.getLocationURI().toString()); - Identifiable id = Utility.getIdentifiable(uri); - if(id instanceof Graph) processGraph((Graph)id); - - } catch(Exception e) { - // Skip bad file - } - - } + if (graphs != null) { + for(IResource r:graphs) { + // ignore system files + if(r.getName().startsWith(".")) continue; + + try { + URI uri = URI.createURI(r.getLocationURI().toString()); + Identifiable id = Utility.getIdentifiable(uri); + if(id instanceof Graph) processGraph((Graph)id); + + } catch(Exception e) { + // Skip bad file + } + + } + } loaded = true; } @@ -175,21 +178,22 @@ public class LocationUtility { } catch(Exception e) { e.printStackTrace(); } - for(IResource r:models) { - // ignore system files - if(r.getName().startsWith(".")) continue; - - try { - URI uri = URI.createURI(r.getLocationURI().toString()); - Identifiable id = Utility.getIdentifiable(uri); - Graph g = ((Model)id).getCanonicalGraph(STEMURI.createURI(""), null, null); - if(id instanceof Model) cbEdges.putAll(getGraphCommonBorderEdges(g, location)); - - } catch(Exception e) { - // Skip bad file + if (models != null) { + for(IResource r:models) { + // ignore system files + if(r.getName().startsWith(".")) continue; + + try { + URI uri = URI.createURI(r.getLocationURI().toString()); + Identifiable id = Utility.getIdentifiable(uri); + Graph g = ((Model)id).getCanonicalGraph(STEMURI.createURI(""), null, null); + if(id instanceof Model) cbEdges.putAll(getGraphCommonBorderEdges(g, location)); + + } catch(Exception e) { + // Skip bad file + } } - - } + } // Only do the edges in the graphs folder if the user hasn't specified a // location, since we need to resolve the URI's to support locations @@ -201,20 +205,21 @@ public class LocationUtility { } catch(Exception e) { e.printStackTrace(); } - for(IResource r:graphs) { - // ignore system files - if(r.getName().startsWith(".")) continue; - - try { - URI uri = URI.createURI(r.getLocationURI().toString()); - Identifiable id = Utility.getIdentifiable(uri); - if(id instanceof Graph) cbEdges.putAll(getGraphCommonBorderEdges((Graph)id, location)); - - } catch(Exception e) { - // Skip bad file + if (graphs != null) { + for(IResource r:graphs) { + // ignore system files + if(r.getName().startsWith(".")) continue; + + try { + URI uri = URI.createURI(r.getLocationURI().toString()); + Identifiable id = Utility.getIdentifiable(uri); + if(id instanceof Graph) cbEdges.putAll(getGraphCommonBorderEdges((Graph)id, location)); + + } catch(Exception e) { + // Skip bad file + } } - - } + } } Set<Edge> retVal = new HashSet<Edge>(); retVal.addAll(cbEdges.values()); |