Source Code Cross Referenced for DAVBody.java in  » Web-Server » Jigsaw » org » w3c » www » webdav » xml » 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 » Web Server » Jigsaw » org.w3c.www.webdav.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // DAVBody.java
002:        // $Id: DAVBody.java,v 1.7 2000/10/13 13:45:06 bmahe Exp $
003:        // (c) COPYRIGHT MIT, INRIA and Keio, 2000.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:        package org.w3c.www.webdav.xml;
006:
007:        import java.io.InputStream;
008:        import java.io.IOException;
009:
010:        import org.w3c.dom.DOMException;
011:        import org.w3c.dom.DOMImplementation;
012:        import org.w3c.dom.Document;
013:        import org.w3c.dom.Element;
014:        import org.w3c.dom.Node;
015:
016:        import org.xml.sax.ErrorHandler;
017:        import org.xml.sax.InputSource;
018:        import org.xml.sax.SAXException;
019:        import org.xml.sax.SAXParseException;
020:        import org.xml.sax.SAXNotRecognizedException;
021:        import org.xml.sax.SAXNotSupportedException;
022:
023:        import org.apache.xerces.parsers.DOMParser;
024:        import org.apache.xerces.dom.DocumentImpl;
025:
026:        import org.w3c.www.webdav.WEBDAV;
027:
028:        /**
029:         * @version $Revision: 1.7 $
030:         * @author  Benoît Mahé (bmahe@w3.org)
031:         */
032:        public class DAVBody implements  ErrorHandler {
033:
034:            protected static DOMParser parser = null;
035:
036:            protected static DOMImplementation domimpl = null;
037:
038:            private static boolean setValidation = false; //defaults
039:            private static boolean setNameSpaces = true;
040:            private static boolean setSchemaSupport = true;
041:            private static boolean setDeferredDOM = true;
042:
043:            static {
044:                parser = new DOMParser();
045:                domimpl = (new DocumentImpl()).getImplementation();
046:                try {
047:                    parser
048:                            .setFeature(
049:                                    "http://apache.org/xml/features/dom/defer-node-expansion",
050:                                    setDeferredDOM);
051:                    parser.setFeature("http://xml.org/sax/features/validation",
052:                            setValidation);
053:                    parser.setFeature("http://xml.org/sax/features/namespaces",
054:                            setNameSpaces);
055:                    parser.setFeature(
056:                            "http://apache.org/xml/features/validation/schema",
057:                            setSchemaSupport);
058:                } catch (Exception ex) {
059:                    ex.printStackTrace(System.err);
060:                }
061:            }
062:
063:            protected Document document = null;
064:
065:            public static synchronized Document getDocument(InputStream in,
066:                    ErrorHandler handler) throws IOException, SAXException {
067:                parser.setErrorHandler(handler);
068:                InputSource source = new InputSource(in);
069:                parser.parse(source);
070:                return parser.getDocument();
071:            }
072:
073:            //
074:            // XML part
075:            //
076:
077:            public DAVMultiStatus getMultiStatus() {
078:                Node n = DAVNode.getDAVNode(document, DAVNode.MULTISTATUS_NODE);
079:                if (n != null) {
080:                    return new DAVMultiStatus((Element) n);
081:                }
082:                return null;
083:            }
084:
085:            public DAVPropertyBehavior getPropertyBehavior() {
086:                Node n = DAVNode.getDAVNode(document,
087:                        DAVNode.PROPERTYBEHAVIOR_NODE);
088:                if (n != null) {
089:                    return new DAVPropertyBehavior((Element) n);
090:                }
091:                return null;
092:            }
093:
094:            public DAVPropertyUpdate getPropertyUpdate() {
095:                Node n = DAVNode.getDAVNode(document,
096:                        DAVNode.PROPERTYUPDATE_NODE);
097:                if (n != null) {
098:                    return new DAVPropertyUpdate((Element) n);
099:                }
100:                return null;
101:            }
102:
103:            public DAVPropFind getPropFind() {
104:                Node n = DAVNode.getDAVNode(document, DAVNode.PROPFIND_NODE);
105:                if (n != null) {
106:                    return new DAVPropFind((Element) n);
107:                }
108:                return null;
109:            }
110:
111:            public DAVActiveLock getActiveLock() {
112:                Node n = DAVNode.getDAVNode(document, DAVNode.ACTIVELOCK_NODE);
113:                if (n != null) {
114:                    return new DAVActiveLock((Element) n);
115:                }
116:                return null;
117:            }
118:
119:            public DAVLockInfo getLockInfo() {
120:                Node n = DAVNode.getDAVNode(document, DAVNode.LOCKINFO_NODE);
121:                if (n != null) {
122:                    return new DAVLockInfo((Element) n);
123:                }
124:                return null;
125:            }
126:
127:            //
128:            // creation
129:            //
130:
131:            public static Document createDocument(String root) {
132:                Document newdoc = domimpl.createDocument(WEBDAV.NAMESPACE_URI,
133:                        WEBDAV.NAMESPACE_PREFIX + ":" + root, null);
134:                Element rootel = newdoc.getDocumentElement();
135:                try {
136:                    rootel.setAttribute("xmlns:" + WEBDAV.NAMESPACE_PREFIX,
137:                            WEBDAV.NAMESPACE_URI);
138:                } catch (DOMException ex) {
139:                    ex.printStackTrace();
140:                }
141:                return newdoc;
142:            }
143:
144:            public static Document createDocumentNS(String root, String ns,
145:                    String prefix) {
146:                Document newdoc = createDocument(root);
147:                Element rootel = newdoc.getDocumentElement();
148:                try {
149:                    rootel.setAttribute("xmlns:" + prefix, ns);
150:                } catch (DOMException ex) {
151:                    ex.printStackTrace();
152:                }
153:                return newdoc;
154:            }
155:
156:            // Error Handler
157:
158:            /**
159:             * Warning
160:             */
161:            public void warning(SAXParseException ex) {
162:                System.err.println("[Warning] " + getLocationString(ex) + ": "
163:                        + ex.getMessage());
164:            }
165:
166:            /**
167:             * Error. 
168:             */
169:            public void error(SAXParseException ex) {
170:                System.err.println("[Error] " + getLocationString(ex) + ": "
171:                        + ex.getMessage());
172:            }
173:
174:            /** 
175:             * Fatal error. 
176:             */
177:            public void fatalError(SAXParseException ex) throws SAXException {
178:                System.err.println("[Fatal Error] " + getLocationString(ex)
179:                        + ": " + ex.getMessage());
180:                throw ex;
181:            }
182:
183:            //
184:            // Private methods
185:            //
186:
187:            /** 
188:             * Returns a string of the location. 
189:             */
190:            private String getLocationString(SAXParseException ex) {
191:                StringBuffer str = new StringBuffer();
192:
193:                String systemId = ex.getSystemId();
194:                if (systemId != null) {
195:                    int index = systemId.lastIndexOf('/');
196:                    if (index != -1)
197:                        systemId = systemId.substring(index + 1);
198:                    str.append(systemId);
199:                }
200:                str.append(':');
201:                str.append(ex.getLineNumber());
202:                str.append(':');
203:                str.append(ex.getColumnNumber());
204:
205:                return str.toString();
206:
207:            }
208:
209:            /**
210:             * Constructor
211:             */
212:            public DAVBody(InputStream in) throws IOException, SAXException {
213:                this.document = getDocument(in, this);
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.