Source Code Cross Referenced for PropertyName.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:
018:        /** This class represents the universal name for a
019:         * property.
020:         * @author Jason Crawford <ccjason@us.ibm.com>
021:         */
022:        public class PropertyName {
023:
024:            protected String ns = null;
025:            protected String local = null;
026:
027:            public static final PropertyName pnResourcetype = createPropertyNameQuietly("DAV:resourcetype");
028:            public static final PropertyName pnCreationdate = createPropertyNameQuietly("DAV:creationdate");
029:            public static final PropertyName pnSupportedlock = createPropertyNameQuietly("DAV:supportedlock");
030:            public static final PropertyName pnContenttype = createPropertyNameQuietly("DAV:getcontenttype");
031:            public static final PropertyName pnGetlastmodified = createPropertyNameQuietly("DAV:getlastmodified");
032:            public static final PropertyName pnGetcontentlength = createPropertyNameQuietly("DAV:getcontentlength");
033:            public static final PropertyName pnLockdiscovery = createPropertyNameQuietly("DAV:lockdiscovery");
034:
035:            /**
036:             * PropertyName constructor.
037:             * @param tag a tag whose name will be used as the property name of
038:             *  constructed PropertyName.
039:             */
040:            public PropertyName(org.w3c.dom.Element tag) {
041:                // (jlc 4/4/99) we dont' check for valid local names
042:                //   because if
043:                //   it was already in a tag, it must be okay.  Perhaps
044:                //   we should declare that we throw a
045:                //   InvalidPropertyNameException as a place holder
046:                //   for possibly having stricter checks down the
047:                //   road?  It's tempting.
048:
049:                local = tag.getLocalName();
050:                ns = tag.getNamespaceURI();
051:
052:            }
053:
054:            /**
055:             * PropertyName constructor.  This constructor will only
056:             * work for property names in the "DAV:" namespace and
057:             * the tag parameter must begin with "DAV:".
058:             * @param tag the property name.  ie. DAV:resourcetype
059:             */
060:            public PropertyName(String tag) throws InvalidPropertyNameException {
061:                if (!tag.startsWith("DAV:")) {
062:                    throw new InvalidPropertyNameException(
063:                            "Invalid tag parameter: " + tag);
064:                } else {
065:                    tag = tag.substring(4);
066:                }
067:                local = tag;
068:                ns = "DAV:";
069:            }
070:
071:            /**
072:             * PropertyName constructor.
073:             * @param tag is the local property name.   ie "resourcetype"
074:             * @param namespace is the namespace string.  ie "DAV:"
075:             */
076:            public PropertyName(String namespace, String tag)
077:                    throws InvalidPropertyNameException {
078:                ns = namespace;
079:                local = tag;
080:                if (local.indexOf(':') >= 0) {
081:                    throw new InvalidPropertyNameException("local part is "
082:                            + tag);
083:                }
084:            }
085:
086:            /**
087:             * Returns a combined namespace+local string.
088:             * @return java.lang.String
089:             */
090:            public String asExpandedString() {
091:                return ns + ":" + local;
092:            }
093:
094:            /**
095:             * This factory takes a propertyname string.  Unlike
096:             *  the constructor with the same argument signature,
097:             *  this method will throw a runtime exception in
098:             *  situations where the contructor would throw
099:             *  an InvalidPropertyNameException.  This is
100:             *  important because runtime exceptions don't have
101:             *  to be declared.  This can be convenient if a
102:             *  caller knows that their provided property name
103:             *  is correct (by the definition of the PropertyName(String)
104:             *  constructor) and don't want to sprinkle exception
105:             *  declarations all over their code... or
106:             *  add try/catch blocks... when they
107:             *  know an InvalidPropertyNameException will never be thrown.
108:             * @return com.ibm.webdav.PropertyName
109:             * @param propname java.lang.String - See the documentation
110:             *    for the PropertyName( String) constructor for info.
111:             */
112:            public static PropertyName createPropertyNameQuietly(String propname) {
113:                PropertyName res;
114:                try {
115:                    res = new PropertyName(propname);
116:                } catch (InvalidPropertyNameException excc) {
117:                    // we catch this so that we don't have to
118:                    //   declare it in the callers.  If it
119:                    //   occurs we have an internal problem.
120:                    throw new RuntimeException("internal error: bad property: "
121:                            + propname);
122:                }
123:                return res;
124:            }
125:
126:            /**
127:             * Compares two objects for equality. Returns a boolean that indicates
128:             * whether this object is equivalent to the specified object. This method
129:             * is used when an object is stored in a hashtable.
130:             * <p>
131:             * In the case of this class, if the contatenated ns+local string names
132:             * are equal, then the PropertyNames are equal.
133:             * <p>
134:             * It should be noted that this method can take a String as a
135:             * parameter and match on it.  That equality relationship is
136:             * not communative though since the String.equals(Object) method
137:             * will never return true if passed a PropertyName.
138:             *
139:             * @param obj the Object to compare with
140:             * @return true if these Objects are equal; false otherwise.
141:             * @see java.util.Hashtable
142:             */
143:            public boolean equals(Object obj) {
144:                String s1 = ns + local;
145:                if (obj instanceof  PropertyName) {
146:                    PropertyName param1 = (PropertyName) obj;
147:                    String s2 = param1.ns + param1.local;
148:                    return s1.equals(s2);
149:                } else if (obj instanceof  String) {
150:                    String param1 = (String) obj;
151:                    return s1.equals(param1);
152:                }
153:                return false;
154:            }
155:
156:            /**
157:             * Returns a the local portion of a property name.  For
158:             * example it would return "resourcetype" if the PropertyName
159:             * was representing a property name for DAV:resourcetype.
160:             * @return a string representation of the local property name
161:             * without any prefix or namespace.
162:             */
163:            public String getLocal() {
164:                return local;
165:            }
166:
167:            /**
168:             * Returns a the namespace of the PropertyName.
169:             * @return a string representation of the namespace of a property name.
170:             * For example "DAV:".
171:             */
172:            public String getNamespace() {
173:                return ns;
174:            }
175:
176:            /**
177:             * Generates a hash code for the receiver.
178:             * This method is supported primarily for
179:             * hash tables, such as those provided in java.util.
180:             * @return an integer hash code for the receiver
181:             * @see java.util.Hashtable
182:             */
183:            public int hashCode() {
184:                // Insert code to generate a hash code for the receiver here.
185:                // This implementation forwards the message to super.  You may replace or supplement this.
186:                // NOTE: if two objects are equal (equals(Object) returns true) they must have the same hash code
187:                String join = ns + local;
188:                return join.hashCode();
189:            }
190:
191:            /**
192:             * Returns a consise human readable string describing the property name.
193:             * @return java.lang.String
194:             */
195:            public String toString() {
196:                return asExpandedString();
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.