Source Code Cross Referenced for PropertyValue.java in  » Content-Management-System » harmonise » com » ibm » webdav » 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 » Content Management System » harmonise » com.ibm.webdav 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ibm.webdav;
002:
003:        /*
004:         * (C) Copyright IBM Corp. 2000  All rights reserved.
005:         *
006:         * The program is provided "AS IS" without any warranty express or
007:         * implied, including the warranty of non-infringement and the implied
008:         * warranties of merchantibility and fitness for a particular purpose.
009:         * IBM will not be liable for any damages suffered by you as a result
010:         * of using the Program. In no event will IBM be liable for any
011:         * special, indirect or consequential damages or lost profits even if
012:         * IBM has been advised of the possibility of their occurrence. IBM
013:         * will not be liable for any third party claims against you.
014:         * 
015:         * Portions Copyright (C) Simulacra Media Ltd, 2004.
016:         */
017:        import org.w3c.dom.*;
018:        import java.io.*;
019:        import javax.xml.parsers.*;
020:
021:        /** A PropertyValue represents the value of a property of a resource and
022:         * it's status.
023:         *
024:         * @author Jim Amsden <jamsden@us.ibm.com>
025:         */
026:        public class PropertyValue extends Object implements 
027:                java.io.Serializable {
028:            /** the value of the property as an XML element
029:             */
030:            public Element value = null;
031:
032:            /** the status of the property as returned from a Resource.getProperty()
033:             * method.
034:             */
035:            public int status = WebDAVStatus.SC_OK;
036:
037:            /** Create a PropertyValue
038:             *
039:             * @param value an XML DOM Element representing the value of the property
040:             * @param status WebDAV the status code of the property as returned from one of the many
041:             * Resource.getProperty() methods.
042:             */
043:            public PropertyValue(Element value, int status) {
044:                this .value = value;
045:                this .status = status;
046:            }
047:
048:            /** The status of the property as returned from a Resource.getProperty()
049:             * method.
050:             * @return the HTTP or WebDAV status code for a property
051:             */
052:            public int getStatus() {
053:                return status;
054:            }
055:
056:            /** The value of the property as an XML element
057:             * @return the value of a property
058:             */
059:            public Element getValue() {
060:                return value;
061:            }
062:
063:            /** Format a PropertyValue as a string of the form: value(status)
064:             * @return a string representation of a PropertyValue
065:             */
066:            static public String nodeToString(Element el) {
067:
068:                return XMLUtility.printNode(el);
069:            }
070:
071:            /** De-serialize a PropertyValue from a stream.
072:             * @param in the stream to read from
073:             * @exception IOException
074:             * @exception ClassNotFoundException
075:             */
076:            private void readObject(java.io.ObjectInputStream in)
077:                    throws IOException, ClassNotFoundException {
078:                status = in.readInt();
079:                int size = in.readInt();
080:                byte[] buffer = new byte[size];
081:                in.readFully(buffer);
082:                ByteArrayInputStream is = new ByteArrayInputStream(buffer);
083:                Document contents = null;
084:
085:                try {
086:                    DocumentBuilderFactory factory = DocumentBuilderFactory
087:                            .newInstance();
088:                    factory.setNamespaceAware(true);
089:                    DocumentBuilder docbuilder = factory.newDocumentBuilder();
090:                    contents = docbuilder
091:                            .parse(new org.xml.sax.InputSource(is));
092:                } catch (Exception e) {
093:                    throw new IOException(e.getMessage());
094:                }
095:
096:                value = contents.getDocumentElement();
097:            }
098:
099:            /** Format a PropertyValue as a string.  This
100:             * usually returns the content of the protocol tag.
101:             * @return a string representation of a PropertyValue
102:             */
103:            public String toContentString() {
104:                Element el = (Element) value;
105:                NodeList children = el.getChildNodes();
106:                //java.util.Enumeration children = el.elements();
107:                String retval = "";
108:
109:                for (int i = 0; i < children.getLength(); i++) {
110:                    Node child = (Node) children.item(i);
111:                    retval += XMLUtility.printNode(child);
112:                }
113:                return retval;
114:            }
115:
116:            /** Format a PropertyValue as a string of the form: value(status)
117:             * @return a string representation of a PropertyValue
118:             */
119:            public String toString() {
120:                StringWriter s = new StringWriter();
121:                PrintWriter pout = new PrintWriter(s);
122:                try {
123:                    pout.print(XMLUtility.printNode(value));
124:                    //((Element) value).print(pout);
125:                    pout.flush();
126:                    s.write(" (" + status + ")");
127:                    s.close();
128:                } catch (IOException exc) {
129:                }
130:                return s.toString();
131:            }
132:
133:            /** Serialize a PropertyValue to a stream.
134:             * @param in the stream to write to
135:             * @exception IOException
136:             */
137:            private void writeObject(java.io.ObjectOutputStream out)
138:                    throws IOException {
139:                Document document = null;
140:
141:                try {
142:                    document = DocumentBuilderFactory.newInstance()
143:                            .newDocumentBuilder().newDocument();
144:                } catch (Exception e) {
145:                    throw new IOException(e.getMessage());
146:                }
147:                //document.setVersion(Resource.XMLVersion);
148:                //document.setEncoding(Resource.defaultXMLEncoding);
149:                document.appendChild(value);
150:                ByteArrayOutputStream os = new ByteArrayOutputStream();
151:                PrintWriter pw = new PrintWriter(os, false);
152:                //document.print(pw);
153:                pw.print(XMLUtility.printNode(document.getDocumentElement()));
154:                out.writeInt(status);
155:                out.writeInt(os.size());
156:                out.write(os.toByteArray());
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.