001: /*
002: * Copyright 2005-2007 Noelios Consulting.
003: *
004: * The contents of this file are subject to the terms of the Common Development
005: * and Distribution License (the "License"). You may not use this file except in
006: * compliance with the License.
007: *
008: * You can obtain a copy of the license at
009: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010: * language governing permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL HEADER in each file and
013: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014: * applicable, add the following below this CDDL HEADER, with the fields
015: * enclosed by brackets "[]" replaced with your own identifying information:
016: * Portions Copyright [yyyy] [name of copyright owner]
017: */
018:
019: package org.restlet.data;
020:
021: /**
022: * Description of data contained in a resource representation. "A representation
023: * consists of data, metadata describing the data, and, on occasion, metadata to
024: * describe the metadata (usually for the purpose of verifying message
025: * integrity). Metadata is in the form of name-value pairs, where the name
026: * corresponds to a standard that defines the value's structure and semantics.
027: * Response messages may include both representation metadata and resource
028: * metadata: information about the resource that is not specific to the supplied
029: * representation." Roy T. Fielding
030: *
031: * @see <a
032: * href="http://roy.gbiv.com/pubs/dissertation/rest_arch_style.htm#sec_5_2_1_2">Source
033: * dissertation</a>
034: * @author Jerome Louvel (contact@noelios.com)
035: */
036: public class Metadata {
037: /** The metadata name like "text/html" or "compress" or "iso-8851-1". */
038: private String name;
039:
040: /** The description of this metadata. */
041: private String description;
042:
043: /**
044: * Constructor.
045: *
046: * @param name
047: * The unique name.
048: */
049: public Metadata(String name) {
050: this (name, null);
051: }
052:
053: /**
054: * Constructor.
055: *
056: * @param name
057: * The unique name.
058: * @param description
059: * The description.
060: */
061: public Metadata(String name, String description) {
062: this .name = name;
063: this .description = description;
064: }
065:
066: /** {@inheritDoc} */
067: @Override
068: public boolean equals(Object object) {
069: return (object instanceof Metadata)
070: && ((Metadata) object).getName().equals(getName());
071: }
072:
073: /**
074: * Returns the description.
075: *
076: * @return The description.
077: */
078: public String getDescription() {
079: return this .description;
080: }
081:
082: /**
083: * Returns the name (ex: "text/html" or "compress" or "iso-8851-1").
084: *
085: * @return The name (ex: "text/html" or "compress" or "iso-8851-1").
086: */
087: public String getName() {
088: return this .name;
089: }
090:
091: /** {@inheritDoc} */
092: @Override
093: public int hashCode() {
094: return (getName() == null) ? 0 : getName().hashCode();
095: }
096:
097: /**
098: * Returns the metadata name.
099: *
100: * @return The metadata name.
101: */
102: @Override
103: public String toString() {
104: return getName();
105: }
106: }
|