KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > xml > content > CmsXmlContentValidationVisitor


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/xml/content/CmsXmlContentValidationVisitor.java,v $
3  * Date : $Date: 2006/03/27 14:52:36 $
4  * Version: $Revision: 1.11 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.xml.content;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.main.CmsLog;
36 import org.opencms.xml.types.I_CmsXmlContentValue;
37
38 import org.apache.commons.logging.Log;
39
40 /**
41  * Visitor implementation that provides validation for all visited values.<p>
42  *
43  * This class is used when {@link org.opencms.xml.content.CmsXmlContent#validate(CmsObject)}
44  * is called validate a XML content object.<p>
45  *
46  * @author Alexander Kandzior
47  *
48  * @version $Revision: 1.11 $
49  *
50  * @since 6.0.0
51  */

52 class CmsXmlContentValidationVisitor implements I_CmsXmlContentValueVisitor {
53
54     /** Static reference to the log. */
55     private static final Log LOG = CmsLog.getLog(CmsXmlContentValidationVisitor.class);
56
57     /** The initialized OpenCms user context (required for VFS access). */
58     CmsObject m_cms;
59
60     /** The error handler instance that stores the errors and warnings found. */
61     CmsXmlContentErrorHandler m_errorHandler;
62
63     /**
64      * Creates a new validation node visitor.<p>
65      *
66      * @param cms the initialized OpenCms user context (required for VFS access)
67      */

68     public CmsXmlContentValidationVisitor(CmsObject cms) {
69
70         // start with a new instance of the error handler
71
m_errorHandler = new CmsXmlContentErrorHandler();
72         // store reference to the provided CmsObject
73
m_cms = cms;
74     }
75
76     /**
77      * Returns the error handler instance that stores the errors and warnings found.<p>
78      *
79      * @return the error handler instance that stores the errors and warnings found
80      */

81     public CmsXmlContentErrorHandler getErrorHandler() {
82
83         return m_errorHandler;
84     }
85
86     /**
87      * @see org.opencms.xml.content.I_CmsXmlContentValueVisitor#visit(org.opencms.xml.types.I_CmsXmlContentValue)
88      */

89     public void visit(I_CmsXmlContentValue value) {
90
91         if (LOG.isDebugEnabled()) {
92             LOG.debug(Messages.get().getBundle().key(Messages.LOG_XMLCONTENT_VISIT_1, value.getPath()));
93         }
94
95         m_errorHandler = value.getContentDefinition().getContentHandler().resolveValidation(
96             m_cms,
97             value,
98             m_errorHandler);
99     }
100 }
Popular Tags