Fields Summary |
---|
public static final String | CREATION_DATECreation date. |
public static final String | ALTERNATE_CREATION_DATECreation date. |
public static final String | LAST_MODIFIEDLast modification date. |
public static final String | ALTERNATE_LAST_MODIFIEDLast modification date. |
public static final String | NAMEName. |
public static final String | TYPEType. |
public static final String | ALTERNATE_TYPEType. |
public static final String | SOURCESource. |
public static final String | CONTENT_TYPEMIME type of the content. |
public static final String | CONTENT_LANGUAGEContent language. |
public static final String | CONTENT_LENGTHContent length. |
public static final String | ALTERNATE_CONTENT_LENGTHContent length. |
public static final String | ETAGETag. |
public static final String | COLLECTION_TYPECollection type. |
protected static final SimpleDateFormat | formatHTTP date format. |
protected static final SimpleDateFormat[] | formatsDate formats using for Date parsing. |
protected static final TimeZone | gmtZone |
protected boolean | collectionCollection flag. |
protected long | contentLengthContent length. |
protected long | creationCreation time. |
protected Date | creationDateCreation date. |
protected long | lastModifiedLast modified time. |
protected Date | lastModifiedDateLast modified date. |
protected String | lastModifiedHttpLast modified date in HTTP format. |
protected String | mimeTypeMIME type. |
protected String | nameName. |
protected String | weakETagWeak ETag. |
protected String | strongETagStrong ETag. |
protected Attributes | attributesExternal attributes. |
Methods Summary |
---|
public java.lang.Object | clone()Clone the attributes object (WARNING: fake cloning).
return this;
|
public javax.naming.directory.Attribute | get(java.lang.String attrID)Get attribute.
if (attributes == null) {
if (attrID.equals(CREATION_DATE)) {
return new BasicAttribute(CREATION_DATE, getCreationDate());
} else if (attrID.equals(ALTERNATE_CREATION_DATE)) {
return new BasicAttribute(ALTERNATE_CREATION_DATE,
getCreationDate());
} else if (attrID.equals(LAST_MODIFIED)) {
return new BasicAttribute(LAST_MODIFIED,
getLastModifiedDate());
} else if (attrID.equals(ALTERNATE_LAST_MODIFIED)) {
return new BasicAttribute(ALTERNATE_LAST_MODIFIED,
getLastModifiedDate());
} else if (attrID.equals(NAME)) {
return new BasicAttribute(NAME, getName());
} else if (attrID.equals(TYPE)) {
return new BasicAttribute(TYPE, getResourceType());
} else if (attrID.equals(ALTERNATE_TYPE)) {
return new BasicAttribute(ALTERNATE_TYPE, getResourceType());
} else if (attrID.equals(CONTENT_LENGTH)) {
return new BasicAttribute(CONTENT_LENGTH,
Long.valueOf(getContentLength()));
} else if (attrID.equals(ALTERNATE_CONTENT_LENGTH)) {
return new BasicAttribute(ALTERNATE_CONTENT_LENGTH,
Long.valueOf(getContentLength()));
}
} else {
return attributes.get(attrID);
}
return null;
|
public javax.naming.NamingEnumeration | getAll()Get all attributes.
if (attributes == null) {
Vector attributes = new Vector();
attributes.addElement(new BasicAttribute
(CREATION_DATE, getCreationDate()));
attributes.addElement(new BasicAttribute
(LAST_MODIFIED, getLastModifiedDate()));
attributes.addElement(new BasicAttribute(NAME, getName()));
attributes.addElement(new BasicAttribute(TYPE, getResourceType()));
attributes.addElement
(new BasicAttribute(CONTENT_LENGTH,
Long.valueOf(getContentLength())));
return new RecyclableNamingEnumeration(attributes);
} else {
return attributes.getAll();
}
|
public long | getContentLength()Get content length.
if (contentLength != -1L)
return contentLength;
if (attributes != null) {
Attribute attribute = attributes.get(CONTENT_LENGTH);
if (attribute != null) {
try {
Object value = attribute.get();
if (value instanceof Long) {
contentLength = ((Long) value).longValue();
} else {
try {
contentLength = Long.parseLong(value.toString());
} catch (NumberFormatException e) {
; // Ignore
}
}
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return contentLength;
|
public long | getCreation()Get creation time.
if (creation != -1L)
return creation;
if (creationDate != null)
return creationDate.getTime();
if (attributes != null) {
Attribute attribute = attributes.get(CREATION_DATE);
if (attribute != null) {
try {
Object value = attribute.get();
if (value instanceof Long) {
creation = ((Long) value).longValue();
} else if (value instanceof Date) {
creation = ((Date) value).getTime();
creationDate = (Date) value;
} else {
String creationDateValue = value.toString();
Date result = null;
// Parsing the HTTP Date
for (int i = 0; (result == null) &&
(i < formats.length); i++) {
try {
result = formats[i].parse(creationDateValue);
} catch (ParseException e) {
;
}
}
if (result != null) {
creation = result.getTime();
creationDate = result;
}
}
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return creation;
|
public java.util.Date | getCreationDate()Get creation date.
if (creationDate != null)
return creationDate;
if (creation != -1L) {
creationDate = new Date(creation);
return creationDate;
}
if (attributes != null) {
Attribute attribute = attributes.get(CREATION_DATE);
if (attribute != null) {
try {
Object value = attribute.get();
if (value instanceof Long) {
creation = ((Long) value).longValue();
creationDate = new Date(creation);
} else if (value instanceof Date) {
creation = ((Date) value).getTime();
creationDate = (Date) value;
} else {
String creationDateValue = value.toString();
Date result = null;
// Parsing the HTTP Date
for (int i = 0; (result == null) &&
(i < formats.length); i++) {
try {
result = formats[i].parse(creationDateValue);
} catch (ParseException e) {
;
}
}
if (result != null) {
creation = result.getTime();
creationDate = result;
}
}
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return creationDate;
|
public java.lang.String | getETag()Get ETag.
return getETag(false);
|
public java.lang.String | getETag(boolean strong)Get ETag.
String result = null;
if (attributes != null) {
Attribute attribute = attributes.get(ETAG);
if (attribute != null) {
try {
result = attribute.get().toString();
} catch (NamingException e) {
; // No value for the attribute
}
}
}
if (strong) {
// The strong ETag must always be calculated by the resources
result = strongETag;
} else {
// The weakETag is contentLenght + lastModified
if (weakETag == null) {
weakETag = "W/\"" + getContentLength() + "-"
+ getLastModified() + "\"";
}
result = weakETag;
}
return result;
|
public javax.naming.NamingEnumeration | getIDs()Get all attribute IDs.
if (attributes == null) {
Vector attributeIDs = new Vector();
attributeIDs.addElement(CREATION_DATE);
attributeIDs.addElement(LAST_MODIFIED);
attributeIDs.addElement(NAME);
attributeIDs.addElement(TYPE);
attributeIDs.addElement(CONTENT_LENGTH);
return new RecyclableNamingEnumeration(attributeIDs);
} else {
return attributes.getIDs();
}
|
public long | getLastModified()Get last modified time.
if (lastModified != -1L)
return lastModified;
if (lastModifiedDate != null)
return lastModifiedDate.getTime();
if (attributes != null) {
Attribute attribute = attributes.get(LAST_MODIFIED);
if (attribute != null) {
try {
Object value = attribute.get();
if (value instanceof Long) {
lastModified = ((Long) value).longValue();
} else if (value instanceof Date) {
lastModified = ((Date) value).getTime();
lastModifiedDate = (Date) value;
} else {
String lastModifiedDateValue = value.toString();
Date result = null;
// Parsing the HTTP Date
for (int i = 0; (result == null) &&
(i < formats.length); i++) {
try {
result =
formats[i].parse(lastModifiedDateValue);
} catch (ParseException e) {
;
}
}
if (result != null) {
lastModified = result.getTime();
lastModifiedDate = result;
}
}
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return lastModified;
|
public java.util.Date | getLastModifiedDate()Get lastModified date.
if (lastModifiedDate != null)
return lastModifiedDate;
if (lastModified != -1L) {
lastModifiedDate = new Date(lastModified);
return lastModifiedDate;
}
if (attributes != null) {
Attribute attribute = attributes.get(LAST_MODIFIED);
if (attribute != null) {
try {
Object value = attribute.get();
if (value instanceof Long) {
lastModified = ((Long) value).longValue();
lastModifiedDate = new Date(lastModified);
} else if (value instanceof Date) {
lastModified = ((Date) value).getTime();
lastModifiedDate = (Date) value;
} else {
String lastModifiedDateValue = value.toString();
Date result = null;
// Parsing the HTTP Date
for (int i = 0; (result == null) &&
(i < formats.length); i++) {
try {
result =
formats[i].parse(lastModifiedDateValue);
} catch (ParseException e) {
;
}
}
if (result != null) {
lastModified = result.getTime();
lastModifiedDate = result;
}
}
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return lastModifiedDate;
|
public java.lang.String | getLastModifiedHttp()
if (lastModifiedHttp != null)
return lastModifiedHttp;
Date modifiedDate = getLastModifiedDate();
if (modifiedDate == null) {
modifiedDate = getCreationDate();
}
if (modifiedDate == null) {
modifiedDate = new Date();
}
synchronized (format) {
lastModifiedHttp = format.format(modifiedDate);
}
return lastModifiedHttp;
|
public java.lang.String | getMimeType()
return mimeType;
|
public java.lang.String | getName()Get name.
if (name != null)
return name;
if (attributes != null) {
Attribute attribute = attributes.get(NAME);
if (attribute != null) {
try {
name = attribute.get().toString();
} catch (NamingException e) {
; // No value for the attribute
}
}
}
return name;
|
public java.lang.String | getResourceType()Get resource type.
String result = null;
if (attributes != null) {
Attribute attribute = attributes.get(TYPE);
if (attribute != null) {
try {
result = attribute.get().toString();
} catch (NamingException e) {
; // No value for the attribute
}
}
}
if (result == null) {
if (collection)
result = COLLECTION_TYPE;
else
result = "";
}
return result;
|
public boolean | isCaseIgnored()Case sensitivity.
return false;
|
public boolean | isCollection()Is collection.
// ------------------------------------------------------------- Properties
if (attributes != null) {
return (getResourceType().equals(COLLECTION_TYPE));
} else {
return (collection);
}
|
public javax.naming.directory.Attribute | put(javax.naming.directory.Attribute attribute)Put attribute.
if (attributes == null) {
try {
return put(attribute.getID(), attribute.get());
} catch (NamingException e) {
return null;
}
} else {
return attributes.put(attribute);
}
|
public javax.naming.directory.Attribute | put(java.lang.String attrID, java.lang.Object val)Put attribute.
if (attributes == null) {
return null; // No reason to implement this
} else {
return attributes.put(attrID, val);
}
|
public javax.naming.directory.Attribute | remove(java.lang.String attrID)Remove attribute.
if (attributes == null) {
return null; // No reason to implement this
} else {
return attributes.remove(attrID);
}
|
public void | setCollection(boolean collection)Set collection flag.
this.collection = collection;
if (attributes != null) {
String value = "";
if (collection)
value = COLLECTION_TYPE;
attributes.put(TYPE, value);
}
|
public void | setContentLength(long contentLength)Set content length.
this.contentLength = contentLength;
if (attributes != null)
attributes.put(CONTENT_LENGTH, Long.valueOf(contentLength));
|
public void | setCreation(long creation)Set creation.
this.creation = creation;
this.creationDate = null;
if (attributes != null)
attributes.put(CREATION_DATE, new Date(creation));
|
public void | setCreationDate(java.util.Date creationDate)Creation date mutator.
this.creation = creationDate.getTime();
this.creationDate = creationDate;
if (attributes != null)
attributes.put(CREATION_DATE, creationDate);
|
public void | setETag(java.lang.String eTag)Set strong ETag.
this.strongETag = eTag;
if (attributes != null)
attributes.put(ETAG, eTag);
|
public void | setLastModified(long lastModified)Set last modified.
this.lastModified = lastModified;
this.lastModifiedDate = null;
if (attributes != null)
attributes.put(LAST_MODIFIED, new Date(lastModified));
|
public void | setLastModified(java.util.Date lastModified)Set last modified date.
setLastModifiedDate(lastModified);
|
public void | setLastModifiedDate(java.util.Date lastModifiedDate)Last modified date mutator.
this.lastModified = lastModifiedDate.getTime();
this.lastModifiedDate = lastModifiedDate;
if (attributes != null)
attributes.put(LAST_MODIFIED, lastModifiedDate);
|
public void | setLastModifiedHttp(java.lang.String lastModifiedHttp)
this.lastModifiedHttp = lastModifiedHttp;
|
public void | setMimeType(java.lang.String mimeType)
this.mimeType = mimeType;
|
public void | setName(java.lang.String name)Set name.
this.name = name;
if (attributes != null)
attributes.put(NAME, name);
|
public void | setResourceType(java.lang.String resourceType)Type mutator.
collection = resourceType.equals(COLLECTION_TYPE);
if (attributes != null)
attributes.put(TYPE, resourceType);
|
public int | size()Retrieves the number of attributes in the attribute set.
if (attributes == null) {
return 5;
} else {
return attributes.size();
}
|