1 27 28 package org.objectweb.speedo.metadata; 29 30 import org.objectweb.speedo.api.SpeedoException; 31 import org.objectweb.speedo.generation.lib.NamingRules; 32 import org.objectweb.util.monolog.api.Logger; 33 34 import java.util.ArrayList ; 35 import java.util.Collections ; 36 import java.util.Enumeration ; 37 import java.util.HashMap ; 38 import java.util.HashSet ; 39 import java.util.Iterator ; 40 import java.util.List ; 41 import java.util.Map ; 42 import java.util.Set ; 43 44 48 public class SpeedoXMLDescriptor { 49 52 public Map jdoPackage = new HashMap (); 53 54 public SpeedoMetaInfo smi; 55 56 public String xmlFile = null; 57 58 public boolean requireEnhancement = true; 59 60 63 public Set mos = new HashSet (); 64 65 public SpeedoXMLDescriptor(SpeedoMetaInfo smi) { 66 this.smi = smi; 67 } 68 69 73 public String toString() { 74 Enumeration e = Collections.enumeration(jdoPackage.values()); 75 String s = "descriptor "; 76 while (e.hasMoreElements()) { 77 s = s + " " + e.nextElement().toString(); 78 } 79 return s; 80 } 81 82 91 public void add(Object pac, boolean failsOnError, Logger logger) throws SpeedoException { 92 SpeedoPackage p = (SpeedoPackage) pac; 93 if (jdoPackage.containsKey(p.name)) { 95 SpeedoPackage pref = (SpeedoPackage) jdoPackage.get(p.name); 96 Enumeration e = Collections.enumeration(p.jdoClass.values()); 98 while (e.hasMoreElements()) { 99 pref.addClass(e.nextElement(), failsOnError, logger); 100 } 101 e = Collections.enumeration(p.jdoSequence.values()); 103 while (e.hasMoreElements()) { 104 pref.addSequence(e.nextElement()); 105 } 106 } 107 else { 109 p.jdoXMLDescriptor = this; 110 jdoPackage.put(p.name, pac); 111 } 112 } 113 114 public List getSpeedoClasses() { 115 List scs = new ArrayList (); 116 Iterator it = jdoPackage.values().iterator(); 117 while(it.hasNext()) { 118 scs.addAll(((SpeedoPackage) it.next()).jdoClass.values()); 119 } 120 return scs; 121 } 122 123 public List getSpeedoSequences() { 124 List ss = new ArrayList (); 125 Iterator it = jdoPackage.values().iterator(); 126 while(it.hasNext()) { 127 ss.addAll(((SpeedoPackage) it.next()).jdoSequence.values()); 128 } 129 return ss; 130 } 131 132 public SpeedoClass getSpeedoClass(String fqn, boolean other) { 133 SpeedoClass sc = null; 135 if (other) { 136 sc = smi.getSpeedoClass(fqn, this); 137 } 138 if (sc != null) { 139 return sc; 141 } 142 SpeedoPackage sp = (SpeedoPackage) jdoPackage.get(NamingRules.packageName(fqn)); 143 if (sp != null) { 144 sc = (SpeedoClass) sp.jdoClass.get(NamingRules.className(fqn)); 145 } 146 return sc; 148 } 149 } 150 | Popular Tags |