1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package org.apache.naming.resources;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.Vector;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
/**
* Attributes implementation.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*/
public class ResourceAttributes implements Attributes {
// -------------------------------------------------------------- Constants
private static final long serialVersionUID = 1L;
// Default attribute names
/**
* Creation date.
*/
public static final String CREATION_DATE = "creationdate";
/**
* Creation date.
*/
public static final String ALTERNATE_CREATION_DATE = "creation-date";
/**
* Last modification date.
*/
public static final String LAST_MODIFIED = "getlastmodified";
/**
* Last modification date.
*/
public static final String ALTERNATE_LAST_MODIFIED = "last-modified";
/**
* Name.
*/
public static final String NAME = "displayname";
/**
* Type.
*/
public static final String TYPE = "resourcetype";
/**
* Type.
*/
public static final String ALTERNATE_TYPE = "content-type";
/**
* MIME type of the content.
*/
public static final String CONTENT_TYPE = "getcontenttype";
/**
* Content length.
*/
public static final String CONTENT_LENGTH = "getcontentlength";
/**
* Content length.
*/
public static final String ALTERNATE_CONTENT_LENGTH = "content-length";
/**
* ETag.
*/
public static final String ETAG = "getetag";
/**
* ETag.
*/
public static final String ALTERNATE_ETAG = "etag";
/**
* Collection type.
*/
public static final String COLLECTION_TYPE = "<collection/>";
/**
* HTTP date format.
*/
protected static final SimpleDateFormat format =
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
/**
* Date formats using for Date parsing.
*/
protected static final SimpleDateFormat formats[] = {
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
};
protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT");
/**
* GMT timezone - all HTTP dates are on GMT
*/
static {
format.setTimeZone(gmtZone);
formats[0].setTimeZone(gmtZone);
formats[1].setTimeZone(gmtZone);
formats[2].setTimeZone(gmtZone);
}
// ----------------------------------------------------------- Constructors
/**
* Default constructor.
*/
public ResourceAttributes() {
// NO-OP
}
/**
* Merges with another attribute set.
*/
public ResourceAttributes(Attributes attributes) {
this.attributes = attributes;
}
// ----------------------------------------------------- Instance Variables
/**
* Collection flag.
*/
protected boolean collection = false;
/**
* Content length.
*/
protected long contentLength = -1;
/**
* Creation time.
*/
protected long creation = -1;
/**
* Creation date.
*/
protected Date creationDate = null;
/**
* Last modified time.
*/
protected long lastModified = -1;
/**
* Last modified date.
*/
protected Date lastModifiedDate = null;
/**
* Last modified date in HTTP format.
*/
protected String lastModifiedHttp = null;
/**
* MIME type.
*/
protected String mimeType = null;
/**
* Name.
*/
protected String name = null;
/**
* Weak ETag.
*/
protected String weakETag = null;
/**
* Strong ETag.
*/
protected String strongETag = null;
/**
* External attributes.
*/
protected Attributes attributes = null;
// ------------------------------------------------------------- Properties
/**
* Is collection.
*/
public boolean isCollection() {
if (attributes != null) {
return (COLLECTION_TYPE.equals(getResourceType()));
} else {
return (collection);
}
}
/**
* Set collection flag.
*
* @param collection New flag value
*/
public void setCollection(boolean collection) {
this.collection = collection;
if (attributes != null) {
String value = "";
if (collection)
value = COLLECTION_TYPE;
attributes.put(TYPE, value);
}
}
/**
* Get content length.
*
* @return content length value
*/
public long getContentLength() {
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;
}
/**
* Set content length.
*
* @param contentLength New content length value
*/
public void setContentLength(long contentLength) {
this.contentLength = contentLength;
if (attributes != null)
attributes.put(CONTENT_LENGTH, Long.valueOf(contentLength));
}
/**
* Get creation time.
*
* @return creation time value
*/
public long getCreation() {
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) {
// Ignore
}
}
if (result != null) {
creation = result.getTime();
creationDate = result;
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return creation;
}
/**
* Set creation.
*
* @param creation New creation value
* @deprecated - unused
*/
@Deprecated
public void setCreation(long creation) {
this.creation = creation;
this.creationDate = null;
if (attributes != null)
attributes.put(CREATION_DATE, new Date(creation));
}
/**
* Get creation date.
*
* @return Creation date value
*/
public Date getCreationDate() {
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) {
// Ignore
}
}
if (result != null) {
creation = result.getTime();
creationDate = result;
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return creationDate;
}
/**
* Creation date mutator.
*
* @param creationDate New creation date
*/
public void setCreationDate(Date creationDate) {
this.creation = creationDate.getTime();
this.creationDate = creationDate;
if (attributes != null)
attributes.put(CREATION_DATE, creationDate);
}
/**
* 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) {
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) {
// Ignore
}
}
if (result != null) {
lastModified = result.getTime();
lastModifiedDate = result;
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return lastModified;
}
/**
* Set last modified.
*
* @param lastModified New last modified value
*/
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
this.lastModifiedDate = null;
if (attributes != null)
attributes.put(LAST_MODIFIED, new Date(lastModified));
}
/**
* Get lastModified date.
*
* @return LastModified date value
*/
public Date getLastModifiedDate() {
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) {
// Ignore
}
}
if (result != null) {
lastModified = result.getTime();
lastModifiedDate = result;
}
}
} catch (NamingException e) {
// No value for the attribute
}
}
}
return lastModifiedDate;
}
/**
* Last modified date mutator.
*
* @param lastModifiedDate New last modified date
* @deprecated - unused
*/
@Deprecated
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModified = lastModifiedDate.getTime();
this.lastModifiedDate = lastModifiedDate;
if (attributes != null)
attributes.put(LAST_MODIFIED, lastModifiedDate);
}
/**
* @return Returns the lastModifiedHttp.
*/
public 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;
}
/**
* @param lastModifiedHttp The lastModifiedHttp to set.
* @deprecated - unused
*/
@Deprecated
public void setLastModifiedHttp(String lastModifiedHttp) {
this.lastModifiedHttp = lastModifiedHttp;
}
/**
* @return Returns the mimeType.
*/
public String getMimeType() {
return mimeType;
}
/**
* @param mimeType The mimeType to set.
*/
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
/**
* Get name.
*
* @return Name value
*/
public String getName() {
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;
}
/**
* Set name.
*
* @param name New name value
*/
public void setName(String name) {
this.name = name;
if (attributes != null)
attributes.put(NAME, name);
}
/**
* Get resource type.
*
* @return String resource type
*/
public String getResourceType() {
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;
}
return result;
}
/**
* Type mutator.
*
* @param resourceType New resource type
*/
public void setResourceType(String resourceType) {
collection = resourceType.equals(COLLECTION_TYPE);
if (attributes != null)
attributes.put(TYPE, resourceType);
}
/**
* Get ETag.
*
* @return strong ETag if available, else weak ETag.
*/
public String getETag() {
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 (result == null) {
if (strongETag != null) {
// The strong ETag must always be calculated by the resources
result = strongETag;
} else {
// The weakETag is contentLength + lastModified
if (weakETag == null) {
long contentLength = getContentLength();
long lastModified = getLastModified();
if ((contentLength >= 0) || (lastModified >= 0)) {
weakETag = "W/\"" + contentLength + "-" +
lastModified + "\"";
}
}
result = weakETag;
}
}
return result;
}
/**
* Set strong ETag.
*/
public void setETag(String eTag) {
this.strongETag = eTag;
if (attributes != null)
attributes.put(ETAG, eTag);
}
/**
* 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
*/
public String getCanonicalPath() {
return null;
}
// ----------------------------------------------------- Attributes Methods
/**
* Get attribute.
*/
@Override
public Attribute get(String attrID) {
if (attributes == null) {
if (attrID.equals(CREATION_DATE)) {
Date creationDate = getCreationDate();
if (creationDate == null) return null;
return new BasicAttribute(CREATION_DATE, creationDate);
} else if (attrID.equals(ALTERNATE_CREATION_DATE)) {
Date creationDate = getCreationDate();
if (creationDate == null) return null;
return new BasicAttribute(ALTERNATE_CREATION_DATE, creationDate);
} else if (attrID.equals(LAST_MODIFIED)) {
Date lastModifiedDate = getLastModifiedDate();
if (lastModifiedDate == null) return null;
return new BasicAttribute(LAST_MODIFIED, lastModifiedDate);
} else if (attrID.equals(ALTERNATE_LAST_MODIFIED)) {
Date lastModifiedDate = getLastModifiedDate();
if (lastModifiedDate == null) return null;
return new BasicAttribute(ALTERNATE_LAST_MODIFIED, lastModifiedDate);
} else if (attrID.equals(NAME)) {
String name = getName();
if (name == null) return null;
return new BasicAttribute(NAME, name);
} else if (attrID.equals(TYPE)) {
String resourceType = getResourceType();
if (resourceType == null) return null;
return new BasicAttribute(TYPE, resourceType);
} else if (attrID.equals(ALTERNATE_TYPE)) {
String resourceType = getResourceType();
if (resourceType == null) return null;
return new BasicAttribute(ALTERNATE_TYPE, resourceType);
} else if (attrID.equals(CONTENT_LENGTH)) {
long contentLength = getContentLength();
if (contentLength < 0) return null;
return new BasicAttribute(CONTENT_LENGTH, Long.valueOf(contentLength));
} else if (attrID.equals(ALTERNATE_CONTENT_LENGTH)) {
long contentLength = getContentLength();
if (contentLength < 0) return null;
return new BasicAttribute(ALTERNATE_CONTENT_LENGTH, Long.valueOf(contentLength));
} else if (attrID.equals(ETAG)) {
String etag = getETag();
if (etag == null) return null;
return new BasicAttribute(ETAG, etag);
} else if (attrID.equals(ALTERNATE_ETAG)) {
String etag = getETag();
if (etag == null) return null;
return new BasicAttribute(ALTERNATE_ETAG, etag);
}
} else {
return attributes.get(attrID);
}
return null;
}
/**
* Put attribute.
*/
@Override
public Attribute put(Attribute attribute) {
if (attributes == null) {
try {
return put(attribute.getID(), attribute.get());
} catch (NamingException e) {
return null;
}
} else {
return attributes.put(attribute);
}
}
/**
* Put attribute.
*/
@Override
public Attribute put(String attrID, Object val) {
if (attributes == null) {
return null; // No reason to implement this
} else {
return attributes.put(attrID, val);
}
}
/**
* Remove attribute.
*/
@Override
public Attribute remove(String attrID) {
if (attributes == null) {
return null; // No reason to implement this
} else {
return attributes.remove(attrID);
}
}
/**
* Get all attributes.
*/
@Override
public NamingEnumeration<? extends Attribute> getAll() {
if (attributes == null) {
Vector<BasicAttribute> attributes = new Vector<BasicAttribute>();
Date creationDate = getCreationDate();
if (creationDate != null) {
attributes.addElement(new BasicAttribute
(CREATION_DATE, creationDate));
attributes.addElement(new BasicAttribute
(ALTERNATE_CREATION_DATE, creationDate));
}
Date lastModifiedDate = getLastModifiedDate();
if (lastModifiedDate != null) {
attributes.addElement(new BasicAttribute
(LAST_MODIFIED, lastModifiedDate));
attributes.addElement(new BasicAttribute
(ALTERNATE_LAST_MODIFIED, lastModifiedDate));
}
String name = getName();
if (name != null) {
attributes.addElement(new BasicAttribute(NAME, name));
}
String resourceType = getResourceType();
if (resourceType != null) {
attributes.addElement(new BasicAttribute(TYPE, resourceType));
attributes.addElement(new BasicAttribute(ALTERNATE_TYPE, resourceType));
}
long contentLength = getContentLength();
if (contentLength >= 0) {
Long contentLengthLong = Long.valueOf(contentLength);
attributes.addElement(new BasicAttribute(CONTENT_LENGTH, contentLengthLong));
attributes.addElement(new BasicAttribute(ALTERNATE_CONTENT_LENGTH, contentLengthLong));
}
String etag = getETag();
if (etag != null) {
attributes.addElement(new BasicAttribute(ETAG, etag));
attributes.addElement(new BasicAttribute(ALTERNATE_ETAG, etag));
}
return new RecyclableNamingEnumeration<BasicAttribute>(attributes);
} else {
return attributes.getAll();
}
}
/**
* Get all attribute IDs.
*/
@Override
public NamingEnumeration<String> getIDs() {
if (attributes == null) {
Vector<String> attributeIDs = new Vector<String>();
Date creationDate = getCreationDate();
if (creationDate != null) {
attributeIDs.addElement(CREATION_DATE);
attributeIDs.addElement(ALTERNATE_CREATION_DATE);
}
Date lastModifiedDate = getLastModifiedDate();
if (lastModifiedDate != null) {
attributeIDs.addElement(LAST_MODIFIED);
attributeIDs.addElement(ALTERNATE_LAST_MODIFIED);
}
if (getName() != null) {
attributeIDs.addElement(NAME);
}
String resourceType = getResourceType();
if (resourceType != null) {
attributeIDs.addElement(TYPE);
attributeIDs.addElement(ALTERNATE_TYPE);
}
long contentLength = getContentLength();
if (contentLength >= 0) {
attributeIDs.addElement(CONTENT_LENGTH);
attributeIDs.addElement(ALTERNATE_CONTENT_LENGTH);
}
String etag = getETag();
if (etag != null) {
attributeIDs.addElement(ETAG);
attributeIDs.addElement(ALTERNATE_ETAG);
}
return new RecyclableNamingEnumeration<String>(attributeIDs);
} else {
return attributes.getIDs();
}
}
/**
* Retrieves the number of attributes in the attribute set.
*/
@Override
public int size() {
if (attributes == null) {
int size = 0;
if (getCreationDate() != null) size += 2;
if (getLastModifiedDate() != null) size += 2;
if (getName() != null) size++;
if (getResourceType() != null) size += 2;
if (getContentLength() >= 0) size += 2;
if (getETag() != null) size += 2;
return size;
} else {
return attributes.size();
}
}
/**
* Clone the attributes object (WARNING: fake cloning).
*/
@Override
public Object clone() {
return this;
}
/**
* Case sensitivity.
*/
@Override
public boolean isCaseIgnored() {
return false;
}
}
|