KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > validator > Defs


1 package org.sapia.validator;
2
3 import org.sapia.validator.config.Def;
4 import org.sapia.validator.config.VladObjectFactory;
5
6 /**
7  * Provides an object representation of a rule definition file.
8  *
9  * @author Yanick Duchesne
10  * <dl>
11  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
12  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
13  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
14  * </dl>
15  */

16 public class Defs {
17   private VladObjectFactory _factory;
18
19   /**
20    * Constructor for Defs.
21    */

22   public Defs(VladObjectFactory factory) {
23     _factory = factory;
24   }
25
26   /**
27    * Adds the given namespace to this definition.
28    *
29    * @param a <code>Namespace</code>.
30    */

31   public void addNamespace(Namespace ns) {
32     if (ns.getPrefix() == null) {
33       throw new IllegalArgumentException JavaDoc(
34         "Attribute 'prefix' not defined on 'namepsace' element");
35     }
36
37     Def d;
38
39     for (int i = 0; i < ns.getRuleDefs().size(); i++) {
40       d = (Def) ns.getRuleDefs().get(i);
41       _factory.registerDef(ns.getPrefix(), d.getName(), d);
42     }
43   }
44 }
45
Popular Tags