001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2015 ForgeRock AS.
016 */
017package org.opends.server.types;
018
019import org.forgerock.i18n.LocalizableMessage;
020import org.forgerock.opendj.ldap.ResultCode;
021
022
023/**
024 * This enumeration defines the set of possible outcomes that can
025 * result from processing a cancel request.  This is based on the
026 * specification contained in RFC 3909.
027 */
028@org.opends.server.types.PublicAPI(
029     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
030     mayInstantiate=false,
031     mayExtend=false,
032     mayInvoke=true)
033public class CancelResult
034{
035  /** The result code associated with this cancel result. */
036  private final ResultCode resultCode;
037
038  /**
039   * A human-readable response that the server
040   * provided for the result of the cancellation.
041   */
042  private final LocalizableMessage responseMessage;
043
044  /**
045   * Creates a new cancel result with the provided result code.
046   *
047   * @param  resultCode  The result code associated with this cancel
048   *                     result.
049   *
050   * @param  responseMessage A human-readable response that the
051   *                         server provided for the result
052   *                         of the cancellation.
053   */
054  public CancelResult(ResultCode resultCode, LocalizableMessage responseMessage)
055  {
056    this.resultCode = resultCode;
057    this.responseMessage = responseMessage;
058  }
059
060
061
062  /**
063   * Retrieves the result code associated with this cancel result.
064   *
065   * @return  The result code associated with this cancel result.
066   */
067  public final ResultCode getResultCode()
068  {
069    return resultCode;
070  }
071
072  /**
073   * Retrieves the human-readable response that the server provided
074   * for the result of the cancellation.  The caller may alter the
075   * contents of this buffer.
076   *
077   * @return  The buffer that is used to hold a human-readable
078   *          response that the server provided for the result of this
079   *          cancellation.
080   */
081  public LocalizableMessage getResponseMessage()
082  {
083    return responseMessage;
084  }
085
086  /**
087   * Retrieves a string representation of this cancel result.
088   *
089   * @return  A string representation of this cancel result.
090   */
091  @Override
092  public final String toString()
093  {
094    return String.valueOf(resultCode);
095  }
096}
097