/** * Handles all the assciation dependecies. */ protected void countAssociationDep() { TopicAssocDep topicassocdep = new TopicAssocDep(tm); //HashMap assocTypes; //Print out the result. print("\n\n\n Association Dependencies: \n\n\n"); Iterator it = topicassocdep.getAssociations().iterator(); while (it.hasNext()) { String a = (String)it.next(); StringTokenizer st = new StringTokenizer(a, "$"); String string = st.nextToken(); print("\n\nThe association \"" + string + "\" has roles:\n"); while (st.hasMoreTokens()) { string = st.nextToken(); print("\"" + string+ "\"\n"); } print("and occurs " + topicassocdep.getNumberOfOccurrences(a) + " times\n"); } }//end of countAssociationDep
/** * Gets the assoc types ordered. */ protected String[] getAssociationRoleTypesOrdered() { Collection roletypes = new ArrayList(); Iterator it = association.getRoles().iterator(); while (it.hasNext()) { String name = getName(((AssociationRoleIF)it.next()).getType()); roletypes.add(name); } return sortAlpha(roletypes); }
public TopicAssocDep(TopicMapIF tm) throws NullPointerException { this.tm = tm; associations = new HashMap(); traverse(tm.getAssociations()); }
public void testTopicAssocDep() { TopicAssocDep test = new TopicAssocDep(tm); //Type checking assertTrue("check type (getAssociations()) with 'foo'", test.getAssociations() instanceof Collection); try { test = new TopicAssocDep(null); // test.getAssociationDependencies(); // traverse() is now executed in constructor fail("Should raise a NullPointerException"); } catch (NullPointerException e) { //Test succesfull } }
private void traverse(Collection assocs) { Iterator it = assocs.iterator(); while (it.hasNext()) { AssociationIF temp = (AssociationIF)it.next(); String key = createKey(temp); InternalAssociation assoc; if (associations.containsKey(key)) { assoc = (InternalAssociation)associations.get(key); assoc.increment(); } else { assoc = new InternalAssociation(temp); associations.put(key, assoc); } assoc.addAssociation(temp); } }