org.restlet.data

## Class Method

- java.lang.Object
- - org.restlet.data.Method

All Implemented Interfaces:
  java.lang.Comparable<Method>

    public final class Method
    extends java.lang.Object
    implements java.lang.Comparable<Method>

Method to execute when handling a call.

Author:
  Jerome Louvel

### Field Summary

Fields
`static Method` `ALL` Pseudo-method use to match all methods.
`static Method` `CONNECT` Used with a proxy that can dynamically switch to being a tunnel.
`static Method` `COPY` Creates a duplicate of the source resource, identified by the Request-URI, in the destination resource, identified by the URI in the Destination header.
`static Method` `DELETE` Requests that the origin server deletes the resource identified by the request URI.
`static Method` `GET` Retrieves whatever information (in the form of an entity) that is identified by the request URI.
`static Method` `HEAD` Identical to GET except that the server must not return a message body in the response but only the message header.
`static Method` `LOCK` Used to take out a lock of any access type on the resource identified by the request URI.
`static Method` `MKCOL` MKCOL creates a new collection resource at the location specified by the Request URI.
`static Method` `MOVE` Logical equivalent of a copy, followed by consistency maintenance processing, followed by a delete of the source where all three actions are performed atomically.
`static Method` `OPTIONS` Requests for information about the communication options available on the request/response chain identified by the URI.
`static Method` `POST` Requests that the origin server accepts the entity enclosed in the request as a new subordinate of the resource identified by the request URI.
`static Method` `PROPFIND` Retrieves properties defined on the resource identified by the request URI.
`static Method` `PROPPATCH` Processes instructions specified in the request body to set and/or remove properties defined on the resource identified by the request URI.
`static Method` `PUT` Requests that the enclosed entity be stored under the supplied request URI.
`static Method` `TRACE` Used to invoke a remote, application-layer loop-back of the request message.
`static Method` `UNLOCK` Removes the lock identified by the lock token from the request URI, and all other resources included in the lock.

### Constructor Summary

Constructors
Constructor and Description
`Method(java.lang.String name)` Constructor for unsafe and non idempotent methods.
`Method(java.lang.String name, java.lang.String description)` Constructor for unsafe and non idempotent methods.
`Method(java.lang.String name, java.lang.String description, java.lang.String uri)` Constructor for unsafe and non idempotent methods.
`Method(java.lang.String name, java.lang.String description, java.lang.String uri, boolean safe, boolean idempotent)` Constructor for methods that reply to requests with responses.
`Method(java.lang.String name, java.lang.String description, java.lang.String uri, boolean safe, boolean idempotent, boolean replying)` Constructor.

### Method Summary

Methods
`int` `compareTo(Method o)` Compares this method to another.
`boolean` `equals(java.lang.Object object)`
`java.lang.String` `getDescription()` Returns the description.
`java.lang.String` `getName()` Returns the name.
`java.lang.String` `getUri()` Returns the URI of the specification describing the method.
`int` `hashCode()`
`boolean` `isIdempotent()` Indicates if the side-effects of several requests is the same as a single request.
`boolean` `isReplying()` Indicates if the method replies with a response.
`boolean` `isSafe()` Indicates if it should have the significance of taking an action other than retrieval.
`static void` `register(Method method)` Adds a new Method to the list of registered methods.
`void` `setUri(java.lang.String uri)` Deprecated. Method instances are shared by all Restlet applications and shouldn't be modifiable.
`static void` `sort(java.util.List<Method> methods)` Sorts the given list of methods by name.
`java.lang.String` `toString()` Returns the name.
`static Method` `valueOf(java.lang.String name)` Returns the method associated to a given method name.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### ALL

    public static final Method ALL

Pseudo-method use to match all methods.

#### CONNECT

    public static final Method CONNECT

Used with a proxy that can dynamically switch to being a tunnel.

See Also:
  HTTP RFC - 9.9 CONNECT

#### COPY

    public static final Method COPY

Creates a duplicate of the source resource, identified by the Request-URI, in the destination resource, identified by the URI in the Destination header.

See Also:
  WEBDAV RFC - 8.8 COPY Method

#### DELETE

    public static final Method DELETE

Requests that the origin server deletes the resource identified by the request URI.

See Also:
  HTTP RFC - 9.7 DELETE

#### GET

    public static final Method GET

Retrieves whatever information (in the form of an entity) that is identified by the request URI.

See Also:
  HTTP RFC - 9.3 GET

#### HEAD

    public static final Method HEAD

Identical to GET except that the server must not return a message body in the response but only the message header.

See Also:
  HTTP RFC - 9.4 HEAD

#### LOCK

    public static final Method LOCK

Used to take out a lock of any access type on the resource identified by the request URI.

See Also:
  WEBDAV RFC - 8.10 LOCK Method

#### MKCOL

    public static final Method MKCOL

MKCOL creates a new collection resource at the location specified by the Request URI.

See Also:
  WEBDAV RFC - 8.3 MKCOL Method

#### MOVE

    public static final Method MOVE

Logical equivalent of a copy, followed by consistency maintenance processing, followed by a delete of the source where all three actions are performed atomically.

See Also:
  WEBDAV RFC - 8.3 MKCOL Method

#### OPTIONS

    public static final Method OPTIONS

Requests for information about the communication options available on the request/response chain identified by the URI.

See Also:
  HTTP RFC - 9.2 OPTIONS

#### POST

    public static final Method POST

Requests that the origin server accepts the entity enclosed in the request as a new subordinate of the resource identified by the request URI.

See Also:
  HTTP RFC - 9.5 POST

#### PROPFIND

    public static final Method PROPFIND

Retrieves properties defined on the resource identified by the request URI.

See Also:
  WEBDAV RFC - 8.1 PROPFIND

#### PROPPATCH

    public static final Method PROPPATCH

Processes instructions specified in the request body to set and/or remove properties defined on the resource identified by the request URI.

See Also:
  WEBDAV RFC - 8.2 PROPPATCH

#### PUT

    public static final Method PUT

Requests that the enclosed entity be stored under the supplied request URI.

See Also:

#### TRACE

    public static final Method TRACE

Used to invoke a remote, application-layer loop-back of the request message.

See Also:
  HTTP RFC - 9.8 TRACE

#### UNLOCK

    public static final Method UNLOCK

Removes the lock identified by the lock token from the request URI, and all other resources included in the lock.

See Also:
  WEBDAV RFC - 8.11 UNLOCK Method

### Constructor Detail

#### Method

    public Method(java.lang.String name)

Constructor for unsafe and non idempotent methods.

Parameters:
  `name` - The technical name of the method.
See Also:
  `valueOf(String)`

#### Method

    public Method(java.lang.String name,
          java.lang.String description)

Constructor for unsafe and non idempotent methods.

Parameters:
  `name` - The technical name of the method.
  `description` - The description.
See Also:
  `valueOf(String)`

#### Method

    public Method(java.lang.String name,
          java.lang.String description,
          java.lang.String uri)

Constructor for unsafe and non idempotent methods.

Parameters:
  `name` - The technical name.
  `description` - The description.
  `uri` - The URI of the specification describing the method.
See Also:
  `valueOf(String)`

#### Method

    public Method(java.lang.String name,
          java.lang.String description,
          java.lang.String uri,
          boolean safe,
          boolean idempotent)

Constructor for methods that reply to requests with responses.

Parameters:
  `name` - The technical name.
  `description` - The description.
  `uri` - The URI of the specification describing the method.
  `safe` - Indicates if the method is safe.
  `idempotent` - Indicates if the method is idempotent.
See Also:
  `valueOf(String)`

#### Method

    public Method(java.lang.String name,
          java.lang.String description,
          java.lang.String uri,
          boolean safe,
          boolean idempotent,
          boolean replying)

Constructor.

Parameters:
  `name` - The technical name.
  `description` - The description.
  `uri` - The URI of the specification describing the method.
  `safe` - Indicates if the method is safe.
  `idempotent` - Indicates if the method is idempotent.
  `replying` - Indicates if the method replies with a response.
See Also:
  `valueOf(String)`

### Method Detail

#### register

    public static void register(Method method)

Adds a new Method to the list of registered methods.

Parameters:
  `method` - The method to register.

#### sort

    public static void sort(java.util.List<Method> methods)

Sorts the given list of methods by name.

Parameters:
  `methods` - The methods to sort.

#### valueOf

    public static Method valueOf(java.lang.String name)

Returns the method associated to a given method name. If an existing constant exists then it is returned, otherwise a new instance is created.

Parameters:
  `name` - The method name.
Returns:
  The associated method.

#### compareTo

    public int compareTo(Method o)

Compares this method to another. Based on the method name.

Specified by:
  `compareTo` in interface `java.lang.Comparable<Method>`
Parameters:
  `o` - The other method.

#### equals

    public boolean equals(java.lang.Object object)

Overrides:
  `equals` in class `java.lang.Object`

#### getDescription

    public java.lang.String getDescription()

Returns the description.

Returns:
  The description.

#### getName

    public java.lang.String getName()

Returns the name.

Returns:
  The name.

#### getUri

    public java.lang.String getUri()

Returns the URI of the specification describing the method.

Returns:
  The URI of the specification describing the method.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### isIdempotent

    public boolean isIdempotent()

Indicates if the side-effects of several requests is the same as a single request.

Returns:
  True if the method is idempotent.

#### isReplying

    public boolean isReplying()

Indicates if the method replies with a response.

Returns:
  True if the method replies with a response.

#### isSafe

    public boolean isSafe()

Indicates if it should have the significance of taking an action other than retrieval.

Returns:
  True if the method is safe.

#### setUri

    @Deprecated
    public void setUri(java.lang.String uri)

Deprecated. Method instances are shared by all Restlet applications and shouldn't be modifiable.
Sets the URI of the specification describing the method.

Parameters:
  `uri` - The URI of the specification describing the method.

#### toString

    public java.lang.String toString()

Returns the name.

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  The name.