diff options
author | aclement <aclement> | 2008-09-17 21:17:26 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-09-17 21:17:26 +0000 |
commit | 07a4fd7d8f4a91888172ddfb505eb69ea2dcd83e (patch) | |
tree | 601254c412e3582f295ef6865ff1eb1f17b05454 /asm | |
parent | 5bdbd842fe24d1aa8ebd17a833f461936b8c231e (diff) | |
download | aspectj-07a4fd7d8f4a91888172ddfb505eb69ea2dcd83e.tar.gz aspectj-07a4fd7d8f4a91888172ddfb505eb69ea2dcd83e.zip |
formatter chewed
Diffstat (limited to 'asm')
-rw-r--r-- | asm/src/org/aspectj/asm/internal/RelationshipMap.java | 121 |
1 files changed, 68 insertions, 53 deletions
diff --git a/asm/src/org/aspectj/asm/internal/RelationshipMap.java b/asm/src/org/aspectj/asm/internal/RelationshipMap.java index 9ac44d0d9..0f496c5b5 100644 --- a/asm/src/org/aspectj/asm/internal/RelationshipMap.java +++ b/asm/src/org/aspectj/asm/internal/RelationshipMap.java @@ -12,9 +12,16 @@ package org.aspectj.asm.internal; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Set; -import org.aspectj.asm.*; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; +import org.aspectj.asm.IRelationshipMap; import org.aspectj.asm.IRelationship.Kind; /** @@ -24,60 +31,62 @@ import org.aspectj.asm.IRelationship.Kind; * */ public class RelationshipMap extends HashMap implements IRelationshipMap { - + private static final long serialVersionUID = 496638323566589643L; -// // As this gets serialized, make the hierarchy transient and -// // settable -// private transient IHierarchy hierarchy; - - public RelationshipMap() { } - + // // As this gets serialized, make the hierarchy transient and + // // settable + // private transient IHierarchy hierarchy; + + public RelationshipMap() { + } + public RelationshipMap(IHierarchy hierarchy) { -// this.hierarchy = hierarchy; + // this.hierarchy = hierarchy; } public void setHierarchy(IHierarchy hierarchy) { // commented out as field never read ! -// this.hierarchy = hierarchy; + // this.hierarchy = hierarchy; } - + public List get(String handle) { - List relationships = (List)super.get(handle); + List relationships = (List) super.get(handle); if (relationships == null) { return null; } else { return relationships; } } - + public List get(IProgramElement source) { return get(source.getHandleIdentifier()); } - public IRelationship get(String source, IRelationship.Kind kind, - String relationshipName,boolean runtimeTest,boolean createIfMissing) { + public IRelationship get(String source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest, + boolean createIfMissing) { List relationships = get(source); if (relationships == null) { - if (!createIfMissing) return null; + if (!createIfMissing) + return null; relationships = new ArrayList(); - IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(),runtimeTest); + IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(), runtimeTest); relationships.add(rel); + System.out.println("Storing rel1 " + source + " to " + relationships); + super.put(source, relationships); return rel; } else { - for (Iterator it = relationships.iterator(); it.hasNext(); ) { - IRelationship curr = (IRelationship)it.next(); - if (curr.getKind() == kind && - curr.getName().equals(relationshipName) && - curr.hasRuntimeTest() == runtimeTest) { + for (Iterator it = relationships.iterator(); it.hasNext();) { + IRelationship curr = (IRelationship) it.next(); + if (curr.getKind() == kind && curr.getName().equals(relationshipName) && curr.hasRuntimeTest() == runtimeTest) { return curr; } } if (createIfMissing) { // At this point we did find some relationships for 'source' but not one that looks like what we are // after (either the kind or the name or the dynamictests setting don't match) - IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(),runtimeTest); + IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList(), runtimeTest); relationships.add(rel); return rel; } @@ -85,53 +94,58 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { return null; } - public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest,boolean createIfMissing) { - return get(source.getHandleIdentifier(), kind, relationshipName,runtimeTest,createIfMissing); + public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName, boolean runtimeTest, + boolean createIfMissing) { + return get(source.getHandleIdentifier(), kind, relationshipName, runtimeTest, createIfMissing); } - + public IRelationship get(IProgramElement source, Kind kind, String relationshipName) { - return get(source,kind,relationshipName,false,true); + return get(source, kind, relationshipName, false, true); } - + public boolean remove(String source, IRelationship relationship) { - List list = (List)super.get(source); + List list = (List) super.get(source); if (list != null) { return list.remove(relationship); -// boolean matched = false; -// for (Iterator it = list.iterator(); it.hasNext(); ) { -// IRelationship curr = (IRelationship)it.next(); -// if (curr.getName().equals(relationship.getName())) { -// curr.getTargets().addAll(relationship.getTargets()); -// matched = true; -// } -// } -// if (!matched) list.remove(relationship); - } + // boolean matched = false; + // for (Iterator it = list.iterator(); it.hasNext(); ) { + // IRelationship curr = (IRelationship)it.next(); + // if (curr.getName().equals(relationship.getName())) { + // curr.getTargets().addAll(relationship.getTargets()); + // matched = true; + // } + // } + // if (!matched) list.remove(relationship); + } return false; } public void removeAll(String source) { - super.remove(source); + super.remove(source); } - + public Object put(Object o, Object p) { - return super.put(o,p); + System.out.println("Storing rel2 " + o + " to " + p); + + return super.put(o, p); } + public void put(String source, IRelationship relationship) { - - //System.err.println(">> for: " + source + ", put::" + relationship); - - List list = (List)super.get(source); + + // System.err.println(">> for: " + source + ", put::" + relationship); + + List list = (List) super.get(source); if (list == null) { list = new ArrayList(); list.add(relationship); + System.out.println("Storing rel3 " + source + " to " + list); + super.put(source, list); } else { boolean matched = false; - for (Iterator it = list.iterator(); it.hasNext(); ) { - IRelationship curr = (IRelationship)it.next(); - if (curr.getName().equals(relationship.getName()) - && curr.getKind() == relationship.getKind()) { + for (Iterator it = list.iterator(); it.hasNext();) { + IRelationship curr = (IRelationship) it.next(); + if (curr.getName().equals(relationship.getName()) && curr.getKind() == relationship.getKind()) { curr.getTargets().addAll(relationship.getTargets()); matched = true; } @@ -140,11 +154,13 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { // bug? System.err.println("matched = true"); } - if (matched) list.add(relationship); // Is this a bug, will it give us double entries? + if (matched) + list.add(relationship); // Is this a bug, will it give us double entries? } } public void put(IProgramElement source, IRelationship relationship) { + System.out.println("Storing rel " + source.getHandleIdentifier() + " to " + relationship); put(source.getHandleIdentifier(), relationship); } @@ -156,5 +172,4 @@ public class RelationshipMap extends HashMap implements IRelationshipMap { return keySet(); } - } |