KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > ValidateProperty


1 package com.thaiopensource.validate;
2
3 import com.thaiopensource.util.PropertyId;
4 import com.thaiopensource.util.PropertyMap;
5 import com.thaiopensource.util.PropertyMapBuilder;
6 import com.thaiopensource.xml.sax.XMLReaderCreator;
7 import org.xml.sax.ErrorHandler JavaDoc;
8 import org.xml.sax.EntityResolver JavaDoc;
9
10 /**
11  * Provides common properties to control reading schemas and validation.
12  *
13  * @see Schema#createValidator
14  * @see SchemaReader#createSchema
15  * @see PropertyMap
16  * @see PropertyId
17  * @see com.thaiopensource.validate.rng.RngProperty
18  * @see com.thaiopensource.validate.schematron.SchematronProperty
19  */

20 public class ValidateProperty {
21   /**
22    * Property specifying ErrorHandler to be used for reporting errors. The value
23    * to which this PropertyId maps must be an instance of ErrorHandler.
24    *
25    * @see ErrorHandler
26    */

27   public static final ErrorHandlerPropertyId ERROR_HANDLER = new ErrorHandlerPropertyId("ERROR_HANDLER");
28
29   /**
30    * Property specifying EntityResolver to be used for resolving entities. The value
31    * to which this PropertyId maps must be an instance of EntityResolver.
32    *
33    * @see EntityResolver
34    */

35   public static final EntityResolverPropertyId ENTITY_RESOLVER = new EntityResolverPropertyId("ENTITY_RESOLVER");
36
37   /**
38    * Property specifying XMLReaderCreator used to create XMLReader objects needed for
39    * parsing XML documents. The value to which this PropertyId maps must be an
40    * instance of XMLReaderCreator.
41    */

42   public static final XMLReaderCreatorPropertyId XML_READER_CREATOR
43           = new XMLReaderCreatorPropertyId("XML_READER_CREATOR");
44
45   private ValidateProperty() { }
46
47   /**
48    * A PropertyId whose value is constrained to be an instance of
49    * ErrorHandler.
50    *
51    * @see ErrorHandler
52    */

53   public static class ErrorHandlerPropertyId extends PropertyId {
54     public ErrorHandlerPropertyId(String JavaDoc name) {
55       super(name, ErrorHandler JavaDoc.class);
56     }
57
58     /**
59      * Returns the value of the property. This is a typesafe
60      * version of <code>PropertyMap.get</code>.
61      *
62      * @param properties the PropertyMap to be used
63      * @return the ErrorHandler to which the PropertyMap maps this PropertyId,
64      * or <code>null</code> if this PropertyId is not in the PropertyMap
65      * @see PropertyMap#get
66      */

67     public ErrorHandler JavaDoc get(PropertyMap properties) {
68       return (ErrorHandler JavaDoc)properties.get(this);
69     }
70
71     /**
72      * Sets the value of the property. Modifies the PropertyMapBuilder
73      * so that this PropertyId is mapped to the specified value. This
74      * is a typesafe version of PropertyMapBuilder.put.
75      *
76      * @param builder the PropertyMapBuilder to be modified
77      * @param value the ErrorHandler to which this PropertyId is to be mapped
78      * @return the ErrorHandler to which this PropertyId was mapped before,
79      * or <code>null</code> if it was not mapped
80      *
81      * @see PropertyMapBuilder#put
82      */

83     public ErrorHandler JavaDoc put(PropertyMapBuilder builder, ErrorHandler JavaDoc value) {
84       return (ErrorHandler JavaDoc)builder.put(this, value);
85     }
86   }
87
88   /**
89    * A PropertyId whose value is constrained to be an instance of
90    * EntityResolver.
91    *
92    * @see EntityResolver
93    */

94   public static class EntityResolverPropertyId extends PropertyId {
95     public EntityResolverPropertyId(String JavaDoc name) {
96       super(name, EntityResolver JavaDoc.class);
97     }
98
99     /**
100      * Returns the value of the property. This is a typesafe
101      * version of <code>PropertyMap.get</code>.
102      *
103      * @param properties the PropertyMap to be used
104      * @return the EntityResolver to which the PropertyMap maps this PropertyId,
105      * or <code>null</code> if this PropertyId is not in the PropertyMap
106      * @see PropertyMap#get
107      */

108     public EntityResolver JavaDoc get(PropertyMap properties) {
109       return (EntityResolver JavaDoc)properties.get(this);
110     }
111
112     /**
113      * Sets the value of the property. Modifies the PropertyMapBuilder
114      * so that this PropertyId is mapped to the specified value. This
115      * is a typesafe version of PropertyMapBuilder.put.
116      *
117      * @param builder the PropertyMapBuilder to be modified
118      * @param value the EntityResolver to which this PropertyId is to be mapped
119      * @return the EntityResolver to which this PropertyId was mapped before,
120      * or <code>null</code> if it was not mapped
121      *
122      * @see PropertyMapBuilder#put
123      */

124     public EntityResolver JavaDoc put(PropertyMapBuilder builder, EntityResolver JavaDoc value) {
125       return (EntityResolver JavaDoc)builder.put(this, value);
126     }
127   }
128
129   /**
130    * A PropertyId whose value is constrained to be an instance of
131    * XMLReaderCreator.
132    *
133    * @see XMLReaderCreator
134    */

135   public static class XMLReaderCreatorPropertyId extends PropertyId {
136     public XMLReaderCreatorPropertyId(String JavaDoc name) {
137       super(name, XMLReaderCreator.class);
138     }
139
140     /**
141      * Returns the value of the property. This is a typesafe
142      * version of <code>PropertyMap.get</code>.
143      *
144      * @param properties the PropertyMap to be used
145      * @return the XMLReaderCreator to which the PropertyMap maps this PropertyId,
146      * or <code>null</code> if this PropertyId is not in the PropertyMap
147      * @see PropertyMap#get
148      */

149     public XMLReaderCreator get(PropertyMap properties) {
150       return (XMLReaderCreator)properties.get(this);
151     }
152
153     /**
154      * Sets the value of the property. Modifies the PropertyMapBuilder
155      * so that this PropertyId is mapped to the specified value. This
156      * is a typesafe version of PropertyMapBuilder.put.
157      *
158      * @param builder the PropertyMapBuilder to be modified
159      * @param value the XMLReaderCreator to which this PropertyId is to be mapped
160      * @return the XMLReaderCreator to which this PropertyId was mapped before,
161      * or <code>null</code> if it was not mapped
162      *
163      * @see PropertyMapBuilder#put
164      */

165     public XMLReaderCreator put(PropertyMapBuilder builder, XMLReaderCreator value) {
166       return (XMLReaderCreator)builder.put(this, value);
167     }
168   }
169 }
170
Popular Tags