| 1 |
|
package uk.co.badgersinfoil.asxsd; |
| 2 |
|
|
| 3 |
|
import java.util.ArrayList; |
| 4 |
|
import java.util.Iterator; |
| 5 |
|
import java.util.List; |
| 6 |
|
import org.eclipse.xsd.XSDConcreteComponent; |
| 7 |
|
|
| 8 |
|
|
| 9 |
17 |
public class MappingRegistry { |
| 10 |
17 |
private List components = new ArrayList(); |
| 11 |
|
|
| 12 |
|
public void register(MappingComponent component) { |
| 13 |
452 |
components.add(component); |
| 14 |
452 |
} |
| 15 |
|
|
| 16 |
|
public MappingComponent mappingComponentFor(XSDConcreteComponent component) { |
| 17 |
2635 |
for (Iterator i=components.iterator(); i.hasNext(); ) { |
| 18 |
39699 |
MappingComponent candidate = (MappingComponent)i.next(); |
| 19 |
39699 |
if (candidate.willAccept(component)) { |
| 20 |
2634 |
return candidate; |
| 21 |
|
} |
| 22 |
37065 |
} |
| 23 |
1 |
throw new IllegalArgumentException("No MappingComponent registred will handle "+component+" at "+XSDUtils.path(component)); |
| 24 |
|
} |
| 25 |
|
} |