jericho 01/03/30 07:37:33
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
Log:
- Untabify => Finally, this time works really :(
- Remove ifself from children
Revision Changes Path
1.23 +161 -152
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- WebdavResource.java 2001/03/27 02:25:43 1.22
+++ WebdavResource.java 2001/03/30 15:37:32 1.23
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.22 2001/03/27 02:25:43 remm Exp $
- * $Revision: 1.22 $
- * $Date: 2001/03/27 02:25:43 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.23 2001/03/30 15:37:32 jericho Exp $
+ * $Revision: 1.23 $
+ * $Date: 2001/03/30 15:37:32 $
*
* ====================================================================
*
@@ -98,11 +98,11 @@
// ------------------------------------------------------- Constructors
- /**
- * Default constructor.
- */
- private WebdavResource() {
- }
+ /**
+ * Default constructor.
+ */
+ private WebdavResource() {
+ }
/**
@@ -136,63 +136,63 @@
// -------------------------------------- Constants for WebDAV properties.
- /**
- * The displayname property.
- */
+ /**
+ * The displayname property.
+ */
public static final String DISPLAYNAME = "displayname";
- /**
- * The getcontentlength property.
- */
+ /**
+ * The getcontentlength property.
+ */
public static final String GETCONTENTLENGTH = "getcontentlength";
- /**
- * The getlastmodifed property.
- */
+ /**
+ * The getlastmodifed property.
+ */
public static final String GETLASTMODIFIED = "getlastmodified";
- /**
- * The creationdate property.
- */
+ /**
+ * The creationdate property.
+ */
public static final String CREATIONDATE = "creationdate";
- /**
- * The resourcetype property.
- */
+ /**
+ * The resourcetype property.
+ */
public static final String RESOURCETYPE = "resourcetype";
- /**
- * The getcontenttype property.
- */
+ /**
+ * The getcontenttype property.
+ */
public static final String GETCONTENTTYPE = "getcontenttype";
- /**
- * The getetag property.
- */
+ /**
+ * The getetag property.
+ */
public static final String GETETAG = "getetag";
- /**
- * The ishidden property.
- */
+ /**
+ * The ishidden property.
+ */
public static final String ISHIDDEN = "ishidden";
- /**
- * The iscollection property.
- */
+ /**
+ * The iscollection property.
+ */
public static final String ISCOLLECTION = "iscollection";
- /**
- * The supportedlock property.
- */
+ /**
+ * The supportedlock property.
+ */
public static final String SUPPORTEDLOCK = "supportedlock";
@@ -202,7 +202,7 @@
/**
* The true constant string.
*/
- public static final String TRUE = "1";
+ public static final String TRUE = "1";
/**
@@ -366,7 +366,7 @@
private String supportedLock = "";
- // ----------------------------------------------------- Private Methods
+ // ----------------------------------------------------- Private Methods
/**
@@ -375,7 +375,7 @@
* @return The parsed date.
*/
private Date parseDate(String dateValue) {
- // TODO: move to the common util package related to http.
+ // TODO: move to the common util package related to http.
Date date = null;
for (int i = 0; (date == null) && (i < formats.length); i++) {
try {
@@ -474,10 +474,10 @@
itself = true;
}
- // Get to know each resource.
- WebdavResource workingResource = new WebdavResource();
- String displayName = null;
- // Process the resource's properties
+ // Get to know each resource.
+ WebdavResource workingResource = new WebdavResource();
+ String displayName = null;
+ // Process the resource's properties
Enumeration properties = response.getProperties();
while (properties.hasMoreElements()) {
@@ -488,82 +488,91 @@
if (property.getLocalName().equals(DISPLAYNAME)) {
displayName = property.getPropertyAsString();
if (itself) {
- setDisplayName(displayName);
- displayName = ".";
- } else {
- workingResource.setHttpURL
- (httpURL, displayName, false);
- }
- workingResource.setExistence(true);
- workingResource.setOverwrite(getOverwrite());
- workingResource.setDisplayName(displayName);
+ setDisplayName(displayName);
+ } else {
+ workingResource.setHttpURL
+ (httpURL, displayName, false);
+ workingResource.setExistence(true);
+ workingResource.setOverwrite(getOverwrite());
+ workingResource.setDisplayName(displayName);
+ }
} else
if (property.getLocalName().equals(GETCONTENTLENGTH)) {
String getContentLength = property.getPropertyAsString();
if (itself) {
- setGetContentLength(getContentLength);
+ setGetContentLength(getContentLength);
+ } else {
+ workingResource.setGetContentLength(getContentLength);
}
-
workingResource.setGetContentLength(getContentLength);
} else
if (property.getLocalName().equals(RESOURCETYPE)) {
ResourceTypeProperty resourceType =
(ResourceTypeProperty) property;
if (itself) {
- setResourceType(resourceType);
+ setResourceType(resourceType);
+ } else {
+ workingResource.setResourceType(resourceType);
}
- workingResource.setResourceType(resourceType);
} else
if (property.getLocalName().equals(GETCONTENTTYPE)) {
String getContentType = property.getPropertyAsString();
if (itself) {
- setGetContentType(getContentType);
+ setGetContentType(getContentType);
+ } else {
+ workingResource.setGetContentType(getContentType);
}
-
workingResource.setGetContentType(getContentType);
} else
if (property.getLocalName().equals(GETLASTMODIFIED)) {
String getLastModified = property.getPropertyAsString();
if (itself) {
setGetLastModified(getLastModified);
+ } else {
+ workingResource.setGetLastModified(getLastModified);
}
-
workingResource.setGetLastModified(getLastModified);
} else
if (property.getLocalName().equals(CREATIONDATE)) {
String creationDate = property.getPropertyAsString();
if (itself) {
- setCreationDate(creationDate);
+ setCreationDate(creationDate);
+ } else {
+ workingResource.setCreationDate(creationDate);
}
- workingResource.setCreationDate(creationDate);
} else
if (property.getLocalName().equals(GETETAG)) {
String getEtag = property.getPropertyAsString();
if (itself) {
- setGetEtag(getEtag);
+ setGetEtag(getEtag);
+ } else {
+ workingResource.setGetEtag(getEtag);
}
- workingResource.setGetEtag(getEtag);
} else
if (property.getLocalName().equals(ISHIDDEN)) {
String isHidden = property.getPropertyAsString();
if (itself) {
- setIsHidden(isHidden);
+ setIsHidden(isHidden);
+ } else {
+ workingResource.setIsHidden(isHidden);
}
- workingResource.setIsHidden(isHidden);
} else
if (property.getLocalName().equals(ISCOLLECTION)) {
String isCollection = property.getPropertyAsString();
if (itself) {
- setIsCollection(isCollection);
+ setIsCollection(isCollection);
+ } else {
+ workingResource.setIsCollection(isCollection);
}
- workingResource.setIsCollection(isCollection);
} else
if (property.getLocalName().equals(SUPPORTEDLOCK)) {
String supportedLock = property.getPropertyAsString();
if (itself) {
- setSupportedLock(supportedLock);
+ setSupportedLock(supportedLock);
+ } else {
+ workingResource.setSupportedLock(supportedLock);
}
-
workingResource.setSupportedLock(supportedLock);
}
}
- children.addResource(displayName, workingResource);
+ if (!itself)
+ children.addResource(displayName, workingResource);
}
// The given http URL checked.
@@ -591,8 +600,8 @@
this.httpURL = httpURL;
if (action) {
- setAllProp(httpURL);
- }
+ setAllProp(httpURL);
+ }
}
@@ -600,7 +609,7 @@
* Set the HttpURL for this WebdavResource.
*
* @param httpURL The specified HttpURL.
- * @param path The added relative path.
+ * @param path The added relative path.
* @param action To profind or not.
* @exception WebdavException
* @exception IOException
@@ -610,13 +619,13 @@
* @see #setPath(java.lang.String)
*/
private void setHttpURL
- (HttpURL httpURL, String path, boolean action)
+ (HttpURL httpURL, String path, boolean action)
throws WebdavException, IOException {
- this.httpURL = new HttpURL(httpURL, path);
+ this.httpURL = new HttpURL(httpURL, path);
if (action) {
- setAllProp(this.httpURL);
- }
+ setAllProp(this.httpURL);
+ }
}
@@ -624,7 +633,7 @@
* Set the HttpURL for this WebdavResource.
*
* @param httpURL The specified HttpURL.
- * @param path The added relative path.
+ * @param path The added relative path.
* @exception WebdavException
* @exception IOException
* @see #setHttpURL(java.lang.String)
@@ -681,7 +690,7 @@
* @return httpURL the http URL.
*/
public HttpURL getHttpURL() {
- return httpURL;
+ return httpURL;
}
@@ -691,9 +700,9 @@
* @return httpURL the http URL.
*/
public HttpURL getHttpURLExceptForUserInfo()
- throws MalformedURLException {
+ throws MalformedURLException {
- return httpURL.getHttpURLExceptForUserInfo();
+ return httpURL.getHttpURLExceptForUserInfo();
}
@@ -756,7 +765,7 @@
}
- // ---------------------------------------- WebDAV Property Public Methods
+ // ---------------------------------------- WebDAV Property Public Methods
/**
@@ -795,7 +804,7 @@
* @param getContentLength The getcontentlength value.
*/
public void setGetContentLength(long getContentLength) {
- this.getContentLength = getContentLength;
+ this.getContentLength = getContentLength;
}
@@ -805,7 +814,7 @@
* @param getContentLength The getcontentlength value.
*/
public void setGetContentLength(String getContentLength) {
- this.getContentLength = Long.parseLong(getContentLength);
+ this.getContentLength = Long.parseLong(getContentLength);
}
@@ -826,7 +835,7 @@
* @param resourceType The resourcetype property.
*/
public void setResourceType(ResourceTypeProperty resourceType) {
- this.resourceType = resourceType;
+ this.resourceType = resourceType;
}
@@ -876,7 +885,7 @@
* Set the value of DAV property, getlastmodified.
*
* @param getLastModified The getlastmodified value.
- * @see #setGetLastModified(java.lang.String)
+ * @see #setGetLastModified(java.lang.String)
*/
public void setGetLastModified(long getLastModified) {
this.getLastModified = getLastModified;
@@ -887,7 +896,7 @@
* Set the value of DAV property, getlastmodified.
*
* @param getLastModified The getlastmodified value.
- * @see #setGetLastModified(long)
+ * @see #setGetLastModified(long)
*/
public void setGetLastModified(String getLastModified) {
Date date = parseDate(getLastModified);
@@ -974,7 +983,7 @@
* @return true if it is hidden, otherwise false.
*/
public boolean getIsHidden() {
- return isHidden;
+ return isHidden;
}
@@ -984,7 +993,7 @@
* @param isHidden
*/
public void setIsHidden(boolean isHidden) {
- this.isHidden = isHidden;
+ this.isHidden = isHidden;
}
@@ -994,7 +1003,7 @@
* @param isHidden
*/
public void setIsHidden(String isHidden) {
- this.isHidden = isHidden.equals(TRUE) ? true : false;
+ this.isHidden = isHidden.equals(TRUE) ? true : false;
}
@@ -1005,14 +1014,14 @@
* @see #isCollection()
*/
public boolean getIsCollection() {
- return isCollection;
+ return isCollection;
}
/**
* Set the value of DAV property, iscollection
*
- * @param isCollection
+ * @param isCollection
*/
public void setIsCollection(boolean isCollection) {
this.isCollection = isCollection;
@@ -1022,7 +1031,7 @@
/**
* Set the value of DAV property, iscollection
*
- * @param isCollection
+ * @param isCollection
*/
public void setIsCollection(String isCollection) {
this.isCollection = isCollection.equals(TRUE) ? true : false;
@@ -1056,8 +1065,8 @@
/*
* Get its existence.
- *
- * @return true if it exists.
+ *
+ * @return true if it exists.
*/
public boolean getExistence() {
return exists;
@@ -1203,16 +1212,16 @@
setAllProp(httpURL);
Enumeration hrefs = children.getResourceNames();
- // To be atomic.
- Vector hrefList = new Vector();
- while (hrefs.hasMoreElements()) {
- hrefList.addElement((String) hrefs.nextElement());
- }
- // Calculate the size of the string array.
- int num = hrefList.size();
+ // To be atomic.
+ Vector hrefList = new Vector();
+ while (hrefs.hasMoreElements()) {
+ hrefList.addElement((String) hrefs.nextElement());
+ }
+ // Calculate the size of the string array.
+ int num = hrefList.size();
String[] pathnames = new String[num];
for (int i = 0; i < num; i++) {
- pathnames[i] = (String) hrefList.elementAt(i);
+ pathnames[i] = (String) hrefList.elementAt(i);
}
return pathnames;
@@ -1221,13 +1230,13 @@
/*
* Get an array of pathnames and basic information denoting the WebDAV
- * resources in the denoted by this pathname.
+ * resources in the denoted by this pathname.
+ *
+ * array 0: displayname
+ * array 1: getcontentlength
+ * array 2: iscollection or getcontentype
+ * array 3: getlastmodifieddate
*
- * array 0: displayname
- * array 1: getcontentlength
- * array 2: iscollection or getcontentype
- * array 3: getlastmodifieddate
- *
* @return An array of pathnames and more denoting the resources.
* @exception WebdavException
* @exception IOException
@@ -1244,32 +1253,32 @@
while (hrefs.hasMoreElements()) {
try {
String resourceName = (String) hrefs.nextElement();
- WebdavResource currentResource =
- children.getResource(resourceName);
+ WebdavResource currentResource =
+ children.getResource(resourceName);
String[] longFormat = new String[4];
- // displayname.
- longFormat[0] = currentResource.getDisplayName();
+ // displayname.
+ longFormat[0] = currentResource.getDisplayName();
- long length = currentResource.getGetContentLength();
- // getcontentlength
+ long length = currentResource.getGetContentLength();
+ // getcontentlength
longFormat[1] = new Long(length).toString();
ResourceTypeProperty resourceTypeProperty =
- currentResource.getResourceType();
+ currentResource.getResourceType();
String getContentType =
- currentResource.getGetContentType();
- // iscollection
+ currentResource.getGetContentType();
+ // iscollection
longFormat[2] = resourceTypeProperty.isCollection() ?
"COLLECTION" : getContentType ;
- Date date = new
Date(currentResource.getGetLastModified());
- // getlastmodified
- // Save the dummy what if failed.
+ Date date = new Date(currentResource.getGetLastModified());
+ // getlastmodified
+ // Save the dummy what if failed.
longFormat[3] = (date == null) ? "-- -- ----" :
- // Print the local fancy date format.
- DateFormat.getDateTimeInstance().format(date);
+ // Print the local fancy date format.
+ DateFormat.getDateTimeInstance().format(date);
hrefList.addElement(longFormat);
} catch (Exception e) {
- // FIXME: After if's gotten an exception, any solution?
+ // FIXME: After if's gotten an exception, any solution?
// e.printStackTrace();
}
}
@@ -1299,7 +1308,7 @@
}
- // --------------------------------- WebDAV Request-method Public Methods
+ // --------------------------------- WebDAV Request-method Public Methods
/*
@@ -2283,32 +2292,32 @@
*/
public int compareToWebdavResource(WebdavResource another) {
- try {
- HttpURL anotherUrl = another.getHttpURL();
+ try {
+ HttpURL anotherUrl = another.getHttpURL();
- String thisHost = httpURL.getHost();
- String anotherHost= anotherUrl.getHost();
- if (!thisHost.equalsIgnoreCase(anotherHost))
- return thisHost.compareTo(anotherHost);
-
- int thisPort = httpURL.getPort();
- int anotherPort= anotherUrl.getPort();
- if (thisPort != anotherPort)
- return (thisPort < anotherPort) ? -1 : 1;
-
- boolean thisCollection = isCollection();
- boolean anotherCollection = another.isCollection();
- if (thisCollection && !anotherCollection)
- return -1;
- if (anotherCollection && !thisCollection)
- return 1;
-
- String thisPath = httpURL.getAbsPath();
- String anotherPath= anotherUrl.getAbsPath();
- return thisPath.compareTo(anotherPath);
- } catch (Exception e) {
- // FIXME: not to return 0.
- }
+ String thisHost = httpURL.getHost();
+ String anotherHost= anotherUrl.getHost();
+ if (!thisHost.equalsIgnoreCase(anotherHost))
+ return thisHost.compareTo(anotherHost);
+
+ int thisPort = httpURL.getPort();
+ int anotherPort= anotherUrl.getPort();
+ if (thisPort != anotherPort)
+ return (thisPort < anotherPort) ? -1 : 1;
+
+ boolean thisCollection = isCollection();
+ boolean anotherCollection = another.isCollection();
+ if (thisCollection && !anotherCollection)
+ return -1;
+ if (anotherCollection && !thisCollection)
+ return 1;
+
+ String thisPath = httpURL.getAbsPath();
+ String anotherPath= anotherUrl.getAbsPath();
+ return thisPath.compareTo(anotherPath);
+ } catch (Exception e) {
+ // FIXME: not to return 0.
+ }
return 0;
}