1 package org.sapia.util.xml.idefix; 2 3 import org.sapia.util.xml.Namespace; 4 5 import java.lang.reflect.Method ; 6 7 import java.util.Iterator ; 8 import java.util.LinkedList ; 9 10 11 35 public class CompositeNamespaceFactory implements NamespaceFactoryIF { 36 37 private LinkedList _theDelegates; 38 39 42 public CompositeNamespaceFactory() { 43 _theDelegates = new LinkedList (); 44 } 45 46 51 public void registerNamespaceFactory(NamespaceFactoryIF aFactory) { 52 _theDelegates.addLast(aFactory); 53 } 54 55 63 public Namespace getNamespaceFor(Class aClass) { 64 Namespace aNamespace = null; 65 66 for (Iterator it = _theDelegates.iterator(); 67 it.hasNext() && (aNamespace == null);) { 68 NamespaceFactoryIF aFactory = (NamespaceFactoryIF) it.next(); 69 aNamespace = aFactory.getNamespaceFor(aClass); 70 } 71 72 return aNamespace; 73 } 74 75 83 public Namespace getNamespaceFor(Method aMethod) { 84 Namespace aNamespace = null; 85 86 for (Iterator it = _theDelegates.iterator(); 87 it.hasNext() && (aNamespace == null);) { 88 NamespaceFactoryIF aFactory = (NamespaceFactoryIF) it.next(); 89 aNamespace = aFactory.getNamespaceFor(aMethod); 90 } 91 92 return aNamespace; 93 } 94 } 95 | Popular Tags |