Source Code Cross Referenced for DocElementValidator.java in  » ERP-CRM-Financial » Kuali-Financial-System » mocks » elements » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » mocks.elements 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package mocks.elements;
018:
019:        import org.jdom.Element;
020:
021:        import edu.iu.uis.eden.exception.InvalidXmlException;
022:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
023:
024:        /**
025:         * <p>Title: DocElementValidator </p>
026:         * <p>Description: Used to do simple validation on objects implementing
027:         * IDocElement interface.  To be used as a composite preventing the need
028:         * for repeated validation to be used in a superclass or individual implementations.</p>
029:         * <p>Copyright: Copyright (c) 2002</p>
030:         * <p>Company: Indiana University</p>
031:         * @author Ryan Kirkendall
032:         * @version 1.0
033:         */
034:        public class DocElementValidator {
035:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
036:                    .getLogger(DocElementValidator.class);
037:
038:            /**
039:             * Checks if loadFromXMLContent methods on standard IDocElement implementations
040:             * should return with no work done.  Also throws common exceptions.
041:             *
042:             * @param docElement the doc element to be loaded
043:             * @param element the element with the content containing the object's value(s)
044:             * @param allowBlank flags whether the object should throw an exception or
045:             *      continue running if the element passed in is blank
046:             * @return boolean notifying the calling IDocElement to return with no work done.
047:             *      This would be allowBlanks is true and element is blank (null)
048:             * @throws InvalidXmlException throws if the passed in element is not the correct
049:             *      element the object loads from
050:             * @throws InconsistentDocElementStateException throws if blanks should not be
051:             *      allowed and the element passed in is blank (null)
052:             */
053:            public static boolean returnWithNoWorkDone(IDocElement docElement,
054:                    Element element, boolean allowBlank)
055:                    throws InvalidXmlException,
056:                    InconsistentDocElementStateException {
057:                LOG.debug("returnWithNoWorkDone");
058:
059:                return isElementPresent(docElement.getElementName(), element,
060:                        allowBlank);
061:            }
062:
063:            /**
064:             * Checks if loadFromXMLContent methods on standard IDocElement implementations
065:             * should return with no work done.  Also throws common exceptions.
066:             *
067:             * @param docElement the doc element to be loaded
068:             * @param element the element with the content containing the object's value(s)
069:             * @param allowBlank flags whether the object should throw an exception or
070:             *      continue running if the element passed in is blank
071:             * @param elementName name the element containing the IDocElement values should
072:             *      have
073:             * @return boolean notifying the calling IDocElement to return with no work done.
074:             *      This would be allowBlanks is true and element is blank (null)
075:             * @throws InvalidXmlException throws if the passed in element is not the correct
076:             *      element the object loads from
077:             * @throws InconsistentDocElementStateException throws if blanks should not be
078:             *      allowed and the element passed in is blank (null)
079:             */
080:            public static boolean isElementPresent(String elementName,
081:                    Element element, boolean allowBlank)
082:                    throws InvalidXmlException,
083:                    InconsistentDocElementStateException {
084:                LOG.debug("returnWithNoWorkDone elementName = " + elementName);
085:
086:                if (element == null) {
087:                    LOG.debug("Element is null.");
088:
089:                    if (allowBlank) {
090:                        LOG.debug("Allowing blank returning true.");
091:
092:                        return true;
093:                    } else {
094:                        LOG
095:                                .debug("Not allowing blank throwing InconsistentDocElementStateException");
096:                        throw new InconsistentDocElementStateException(
097:                                "Null Element passed "
098:                                        + "in and allowBlank set false");
099:                    }
100:                }
101:
102:                if (!elementName.equals(element.getName())) {
103:                    LOG
104:                            .debug("Element name and class' element name are inconsistent "
105:                                    + "throwing InvalidXmlException");
106:                    throw new InvalidXmlException(
107:                            "Element is of the wrong type");
108:                }
109:
110:                LOG.debug("everything good, returning false");
111:
112:                return false;
113:            }
114:        }
115:
116:        /*
117:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
118:         *
119:         * This file is part of the EDEN software package.
120:         * For license information, see the LICENSE file in the top level directory
121:         * of the EDEN source distribution.
122:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.