001: /*
002: * $Id: DAVProperty.java,v 1.12 2001/06/05 16:30:20 smulloni Exp $
003: * Time-stamp: <01/06/05 12:25:39 smulloni>
004: *
005: * Copyright (c) 2000-2001, Jacob Smullyan.
006: *
007: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
008: * for the latest version.
009: *
010: * SkunkDAV is free software; you can redistribute it and/or
011: * modify it under the terms of the GNU General Public License as published
012: * by the Free Software Foundation; either version 2, or (at your option)
013: * any later version.
014: *
015: * SkunkDAV is distributed in the hope that it will be useful,
016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: * General Public License for more details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with SkunkDAV; see the file COPYING. If not, write to the Free
022: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
023: * 02111-1307, USA.
024: */
025:
026: package org.skunk.dav.client;
027:
028: import org.skunk.minixml.XMLElement;
029: import org.skunk.trace.Debug;
030:
031: /**
032: * DAVProperty.java
033: * convenience for adding named properties to a propfind
034: *
035: * Created: Mon Sep 18 13:51:18 2000
036: *
037: * @author <a href="mailto:jacob.smullyan@smullyan.org"</a>
038: * @version $Revision: 1.12 $
039: */
040:
041: public class DAVProperty extends XMLElement {
042: public static final DAVProperty LOCKDISCOVERY = getCanonicalProperty(DAVConstants.LOCKDISCOVERY_PROP);
043: public static final DAVProperty CREATIONDATE = getCanonicalProperty(DAVConstants.CREATIONDATE_PROP);
044: public static final DAVProperty DISPLAYNAME = getCanonicalProperty(DAVConstants.DISPLAYNAME_PROP);
045: public static final DAVProperty GETCONTENTLANGUAGE = getCanonicalProperty(DAVConstants.GETCONTENTLANGUAGE_PROP);
046: public static final DAVProperty GETCONTENTLENGTH = getCanonicalProperty(DAVConstants.GETCONTENTLENGTH_PROP);
047: public static final DAVProperty GETCONTENTTYPE = getCanonicalProperty(DAVConstants.GETCONTENTTYPE_PROP);
048: public static final DAVProperty GETETAG = getCanonicalProperty(DAVConstants.GETETAG_PROP);
049: public static final DAVProperty GETLASTMODIFIED = getCanonicalProperty(DAVConstants.GETLASTMODIFIED_PROP);
050: public static final DAVProperty RESOURCETYPE = getCanonicalProperty(DAVConstants.RESOURCETYPE_PROP);
051: public static final DAVProperty SOURCE = getCanonicalProperty(DAVConstants.SOURCE_PROP);
052: public static final DAVProperty SUPPORTEDLOCK = getCanonicalProperty(DAVConstants.SUPPORTEDLOCK_PROP);
053: public static final DAVProperty EXECUTABLE = new DAVProperty(
054: DAVConstants.EXECUTABLE_PROP, "apache",
055: DAVConstants.APACHE_DAV_NAMESPACE);
056:
057: public static final DAVProperty[] BASIC_PROPERTIES = {
058: LOCKDISCOVERY, CREATIONDATE, DISPLAYNAME,
059: //GETCONTENTLANGUAGE,
060: GETCONTENTLENGTH, GETCONTENTTYPE,
061: //GETETAG,
062: GETLASTMODIFIED, RESOURCETYPE,
063: //SOURCE,
064: //SUPPORTEDLOCK
065: };
066:
067: public DAVProperty(String propertyName) {
068: super (propertyName);
069: }
070:
071: public DAVProperty(String propertyName, String namespaceCode,
072: String namespace) {
073: super (propertyName, namespaceCode, namespace);
074: }
075:
076: /**
077: *
078: */
079: public DAVProperty(XMLElement elem) {
080: super (elem.getElementName(), elem.getElementNamespaceCode(),
081: elem.getNamespace(elem.getElementNamespaceCode()));
082: }
083:
084: public static DAVProperty getCanonicalProperty(String canonicalName) {
085: return new DAVProperty(canonicalName, "skunk",
086: DAVConstants.DAV_NAMESPACE);
087: }
088:
089: public boolean equals(Object otherObject) {
090: Debug.trace(this , Debug.DP6, "comparing {0} and {1}",
091: new Object[] { this , otherObject });
092:
093: if (otherObject instanceof DAVProperty) {
094: DAVProperty otherProperty = (DAVProperty) otherObject;
095: String namespace = getNamespace();
096: String otherNamespace = otherProperty.getNamespace();
097: String elementName = getElementName();
098: String otherElementName = otherProperty.getElementName();
099:
100: // fix for possible NullPointerException if namespace is null, pointed out
101: // by Mustafa Cakar (Mustafa.Cakar@germany.sun.com), from whose patch
102: // this code is derived. This differs from his patch in that I don't currently
103: // prevent a NullPointerException if the element name is null.
104:
105: if (elementName.equals(otherElementName)) {
106: if (namespace == null && otherNamespace == null) {
107: return true;
108: } else if (namespace != null) {
109: return namespace.equals(otherNamespace);
110: }
111: }
112: }
113: return false;
114: }
115:
116: public int hashCode() {
117: return (getElementName() + getNamespace()).hashCode();
118: }
119:
120: }
121:
122: /* $Log: DAVProperty.java,v $
123: /* Revision 1.12 2001/06/05 16:30:20 smulloni
124: /* incorporated fix from Mustafa Cakar for NullPointerException in
125: /* DAVProperty.equals().
126: /*
127: /* Revision 1.11 2001/01/05 08:01:12 smulloni
128: /* changes to the connection gui for the Explorer; added depth configurability to
129: /* propfind in the jpython test script; added an experimental "allprop" system
130: /* property which affects the propfind query type
131: /*
132: /* Revision 1.10 2000/12/19 22:06:15 smulloni
133: /* adding documentation.
134: /*
135: /* Revision 1.9 2000/12/03 23:53:25 smulloni
136: /* added license and copyright preamble to java files.
137: /*
138: /* Revision 1.8 2000/11/14 23:18:31 smullyan
139: /* fix for responsedescription property in multistatus
140: /*
141: /* Revision 1.7 2000/11/13 23:28:29 smullyan
142: /* first pass at a gui for proppatch, added to the propertiese dialog. Highly
143: /* problematic still, needs substantial work.
144: /*
145: /* Revision 1.6 2000/11/09 23:34:51 smullyan
146: /* log added to every Java file, with the help of python. Lock stealing
147: /* implemented, and treatment of locks made more robust.
148: /* */
|