KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > validation > impl > DefaultValidationHandler


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.validation.impl;
17
18 import org.apache.cocoon.components.validation.ValidationHandler;
19 import org.apache.excalibur.source.SourceValidity;
20 import org.apache.excalibur.xml.sax.NOPContentHandler;
21 import org.apache.excalibur.xml.sax.NOPLexicalHandler;
22 import org.apache.excalibur.xml.sax.XMLConsumerProxy;
23 import org.xml.sax.ContentHandler JavaDoc;
24 import org.xml.sax.ext.LexicalHandler JavaDoc;
25
26 /**
27  * <p>The default implementation of the {@link ValidationHandler} interface.</p>
28  *
29  * @author <a HREF="mailto:pier@betaversion.org">Pier Fumagalli</a>
30  */

31 public class DefaultValidationHandler extends XMLConsumerProxy
32 implements ValidationHandler {
33
34     /** <p>The {@link SourceValidity} associated with the schema.</p> */
35     private final SourceValidity validity;
36
37     /**
38      * <p>Create a new {@link DefaultValidationHandler} instance.</p>
39      */

40     public DefaultValidationHandler(SourceValidity validity,
41                                     ContentHandler handler) {
42         this(validity, handler, null);
43     }
44
45     /**
46      * <p>Create a new {@link DefaultValidationHandler} instance.</p>
47      */

48     public DefaultValidationHandler(SourceValidity validity,
49                                     ContentHandler contentHandler,
50                                     LexicalHandler lexicalHandler) {
51         super(contentHandler == null? new NOPContentHandler(): contentHandler,
52               lexicalHandler == null? new NOPLexicalHandler(): lexicalHandler);
53         this.validity = validity;
54     }
55
56     /**
57      * <p>Return a {@link SourceValidity} instance associated with the original
58      * resources of the schema describing the validation instructions.</p>
59      *
60      * <p>As the handler might be tied to one (or more) resources from where the
61      * original schema was read from, the {@link #getValidity()} method provides a
62      * way to verify whether the validation instruction are still valid or not.</p>
63      */

64     public SourceValidity getValidity() {
65         return this.validity;
66     }
67 }
68
Popular Tags