Author: bobtarling
Date: 2010-11-21 18:03:04-0800
New Revision: 18855
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/MetaDataCache.java
Log:
Refactor getClasses to populateClassMaps
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/MetaDataCache.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/MetaDataCache.java?view=diff&pathrev=18855&r1=18854&r2=18855
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/MetaDataCache.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/MetaDataCache.java 2010-11-21 18:03:04-0800
@@ -56,13 +56,10 @@
for (int i = 0; i < nl.getLength(); ++i) {
Node n = nl.item(i);
if (n.getNodeName().equals("classes")) {
- metaTypeByName = getClasses((Element) n);
-
- nameByMetaType = new HashMap<Class<?>, String>(metaTypeByName.size());
- for (Map.Entry<String, Class<?>> s : metaTypeByName.entrySet()) {
- nameByMetaType.put(s.getValue(), s.getKey());
- }
-
+ final int size = n.getChildNodes().getLength();
+ nameByMetaType = new HashMap<Class<?>, String>(size);
+ metaTypeByName = new HashMap<String, Class<?>>(size);
+ populateClassMaps((Element) n, nameByMetaType, metaTypeByName);
} else if (n.getNodeName().equals("panels")) {
cache = getPanels((Element) n);
}
@@ -95,10 +92,10 @@
return db.parse(inputSource);
}
- private HashMap<String, Class<?>> getClasses(Element classesNode) {
- final HashMap<String, Class<?>> map =
- new HashMap<String, Class<?>>(
- classesNode.getChildNodes().getLength());
+ private void populateClassMaps(
+ final Element classesNode,
+ final Map<Class<?>, String> nameByMetaType,
+ final Map<String, Class<?>> metaTypeByName) {
final NodeList nl = classesNode.getElementsByTagName("class");
for (int i = 0; i < nl.getLength(); ++i) {
Node classNode = nl.item(i);
@@ -106,12 +103,13 @@
try {
final String name =
classNode.getAttributes().getNamedItem("name").getNodeValue();
- map.put(name, Class.forName(className));
+ Class<?> clazz = Class.forName(className);
+ metaTypeByName.put(name, clazz);
+ nameByMetaType.put(clazz, name);
} catch (ClassNotFoundException e) {
LOG.error("Class not found " + className, e);
}
}
- return map;
}
private Map<Class<?>, PanelData> getPanels(Element panelsNode) {
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2684161
To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.