/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Attributes implementation.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.1.2.1 $
*/
// -------------------------------------------------------------- Constants
// Default attribute names
/**
* Creation date.
*/
/**
* Creation date.
*/
/**
* Last modification date.
*/
/**
* Last modification date.
*/
/**
* Name.
*/
/**
* Type.
*/
/**
* Type.
*/
/**
* Source.
*/
/**
* MIME type of the content.
*/
/**
* Content language.
*/
/**
* Content length.
*/
/**
* Content length.
*/
/**
* ETag.
*/
/**
* ETag.
*/
/**
* Collection type.
*/
/**
* HTTP date format.
*/
new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
SimpleDateFormat f =
f.setTimeZone(gmtZone);
return f;
}
};
/**
* Date formats using for Date parsing.
*/
new ThreadLocal() {
protected Object initialValue() {
return f;
}
};
// ----------------------------------------------------------- Constructors
/**
* Default constructor.
*/
public ResourceAttributes() {
}
/**
* Merges with another attribute set.
*/
this.attributes = attributes;
}
// ----------------------------------------------------- Instance Variables
/**
* Collection flag.
*/
protected boolean collection = false;
/**
* Content length.
*/
/**
* Creation time.
*/
/**
* Creation date.
*/
/**
* Last modified time.
*/
/**
* Last modified date.
*/
/**
* Last modified date in HTTP format.
*/
/**
* MIME type.
*/
/**
* Name.
*/
/**
* Weak ETag.
*/
/**
* Strong ETag.
*/
/**
* External attributes.
*/
// ------------------------------------------------------------- Properties
/**
* Is collection.
*/
public boolean isCollection() {
if (attributes != null) {
} else {
return (collection);
}
}
/**
* Set collection flag.
*/
this.collection = collection;
if (attributes != null) {
if (collection)
}
}
/**
* Get content length.
*
* @return content length value
*/
public long getContentLength() {
if (contentLength != -1L)
return contentLength;
if (attributes != null) {
try {
} else {
try {
} catch (NumberFormatException e) {
// Ignore
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return contentLength;
}
/**
* Set content length.
*
* @param contentLength New content length value
*/
this.contentLength = contentLength;
if (attributes != null)
}
/**
* Get creation time.
*
* @return creation time value
*/
public long getCreation() {
if (creation != -1L)
return creation;
if (creationDate != null)
return creationDate.getTime();
if (attributes != null) {
try {
} else {
// Parsing the HTTP Date
try {
} catch (ParseException e) {
// Ignore
}
}
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return creation;
}
/**
* Set creation.
*
* @param creation New creation value
*/
this.creationDate = null;
if (attributes != null)
}
/**
* Get creation date.
*
* @return Creation date value
*/
if (creationDate != null)
return creationDate;
if (creation != -1L) {
return creationDate;
}
if (attributes != null) {
try {
} else {
// Parsing the HTTP Date
try {
} catch (ParseException e) {
// Ignore
}
}
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return creationDate;
}
/**
* Creation date mutator.
*
* @param creationDate New creation date
*/
this.creationDate = creationDate;
if (attributes != null)
}
/**
* Get last modified time.
*
* @return lastModified time value
*/
public long getLastModified() {
if (lastModified != -1L)
return lastModified;
if (lastModifiedDate != null)
return lastModifiedDate.getTime();
if (attributes != null) {
try {
} else {
// Parsing the HTTP Date
try {
result =
} catch (ParseException e) {
// Ignore
}
}
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return lastModified;
}
/**
* Set last modified.
*
* @param lastModified New last modified value
*/
this.lastModified = lastModified;
this.lastModifiedDate = null;
if (attributes != null)
}
/**
* Set last modified date.
*
* @param lastModified New last modified date value
* @deprecated
*/
}
/**
* Get lastModified date.
*
* @return LastModified date value
*/
if (lastModifiedDate != null)
return lastModifiedDate;
if (lastModified != -1L) {
return lastModifiedDate;
}
if (attributes != null) {
try {
} else {
// Parsing the HTTP Date
try {
result =
} catch (ParseException e) {
// Ignore
}
}
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return lastModifiedDate;
}
/**
* Last modified date mutator.
*
* @param lastModifiedDate New last modified date
*/
this.lastModifiedDate = lastModifiedDate;
if (attributes != null)
}
/**
* @return Returns the lastModifiedHttp.
*/
if (lastModifiedHttp != null)
return lastModifiedHttp;
if (modifiedDate == null) {
}
if (modifiedDate == null) {
modifiedDate = new Date();
}
return lastModifiedHttp;
}
/**
* @return the creation or lastModified date
*/
if (modifiedDate == null) {
}
if (modifiedDate == null) {
modifiedDate = new Date();
}
return modifiedDate;
}
/**
* @param lastModifiedHttp The lastModifiedHttp to set.
*/
this.lastModifiedHttp = lastModifiedHttp;
}
/**
* @return Returns the mimeType.
*/
return mimeType;
}
/**
* @param mimeType The mimeType to set.
*/
}
/**
* Get name.
*
* @return Name value
*/
return name;
if (attributes != null) {
try {
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return name;
}
/**
* Set name.
*
* @param name New name value
*/
if (attributes != null)
}
/**
* Get resource type.
*
* @return String resource type
*/
if (attributes != null) {
try {
} catch (NamingException e) {
; // No value for the attribute
}
}
}
if (collection)
else
}
return result;
}
/**
* Type mutator.
*
* @param resourceType New resource type
*/
if (attributes != null)
}
/**
* Get ETag.
*
* @return strong ETag if available, else weak ETag
*/
if (attributes != null) {
try {
} catch (NamingException e) {
; // No value for the attribute
}
}
}
if (strongETag != null) {
// The strong ETag must always be calculated by the resources
result = strongETag;
} else {
// The weakETag is contentLength + lastModified
long contentLength = getContentLength();
long lastModified = getLastModified();
lastModified + "\"";
}
}
}
}
return result;
}
/**
* Get ETag.
*
* @param strong Ignored
* @return strong ETag if available, else weak ETag.
* @deprecated
*/
return getETag();
}
/**
* Set strong ETag.
*/
this.strongETag = eTag;
if (attributes != null)
}
/**
* Return the canonical path of the resource, to possibly be used for
* direct file serving. Implementations which support this should override
* it to return the file path.
*
* @return The canonical path of the resource
*/
return null;
}
// ----------------------------------------------------- Attributes Methods
/**
* Get attribute.
*/
if (attributes == null) {
long contentLength = getContentLength();
long contentLength = getContentLength();
}
} else {
}
return null;
}
/**
* Put attribute.
*/
if (attributes == null) {
try {
} catch (NamingException e) {
return null;
}
} else {
}
}
/**
* Put attribute.
*/
if (attributes == null) {
return null; // No reason to implement this
} else {
}
}
/**
* Remove attribute.
*/
if (attributes == null) {
return null; // No reason to implement this
} else {
}
}
/**
* Get all attributes.
*/
if (attributes == null) {
if (creationDate != null) {
}
if (lastModifiedDate != null) {
}
}
if (resourceType != null) {
}
long contentLength = getContentLength();
if (contentLength >= 0) {
}
}
} else {
return attributes.getAll();
}
}
/**
* Get all attribute IDs.
*/
if (attributes == null) {
if (creationDate != null) {
}
if (lastModifiedDate != null) {
}
}
if (resourceType != null) {
}
long contentLength = getContentLength();
if (contentLength >= 0) {
}
}
} else {
return attributes.getIDs();
}
}
/**
* Retrieves the number of attributes in the attribute set.
*/
public int size() {
if (attributes == null) {
int size = 0;
return size;
} else {
return attributes.size();
}
}
/**
* Clone the attributes object
*/
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
/**
* Case sensitivity.
*/
public boolean isCaseIgnored() {
return false;
}
}