001/*
002 * Copyright 2009-2017 UnboundID Corp.
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2009-2017 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.migrate.ldapjdk;
022
023
024
025import com.unboundid.asn1.ASN1OctetString;
026import com.unboundid.ldap.sdk.ExtendedResult;
027import com.unboundid.util.Extensible;
028import com.unboundid.util.NotMutable;
029import com.unboundid.util.ThreadSafety;
030import com.unboundid.util.ThreadSafetyLevel;
031
032
033
034/**
035 * This class provides a data structure which represents an LDAP extended
036 * response.
037 * <BR><BR>
038 * This class is primarily intended to be used in the process of updating
039 * applications which use the Netscape Directory SDK for Java to switch to or
040 * coexist with the UnboundID LDAP SDK for Java.  For applications not written
041 * using the Netscape Directory SDK for Java, the {@link ExtendedResult} class
042 * should be used instead.
043 */
044@Extensible()
045@NotMutable()
046@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
047public class LDAPExtendedResponse
048       extends LDAPResponse
049{
050  /**
051   * The serial version UID for this serializable class.
052   */
053  private static final long serialVersionUID = 7956345950545720834L;
054
055
056
057  // The extended result for this LDAP extended response.
058  private final ExtendedResult extendedResult;
059
060
061
062  /**
063   * Creates a new LDAP extended response from the provided
064   * {@link ExtendedResult} object.
065   *
066   * @param  extendedResult  The {@code ExtendedResult} to use to create this
067   *                         LDAP extended response.
068   */
069  public LDAPExtendedResponse(final ExtendedResult extendedResult)
070  {
071    super(extendedResult);
072
073    this.extendedResult = extendedResult;
074  }
075
076
077
078  /**
079   * Retrieves the OID for this LDAP extended response, if any.
080   *
081   * @return  The OID for this LDAP extended response, or {@code null} if there
082   *          is none.
083   */
084  public String getID()
085  {
086    return extendedResult.getOID();
087  }
088
089
090
091  /**
092   * Retrieves the value for this LDAP extended response, if any.
093   *
094   * @return  The value for this LDAP extended response, or {@code null} if
095   *          there is none.
096   */
097  public byte[] getValue()
098  {
099    final ASN1OctetString value = extendedResult.getValue();
100    if (value == null)
101    {
102      return null;
103    }
104    else
105    {
106      return value.getValue();
107    }
108  }
109
110
111
112  /**
113   * Retrieves an {@link ExtendedResult} object that is the equivalent of this
114   * LDAP extended response.
115   *
116   * @return  An {@code ExtendedResult} object that is the equivalent of this
117   *          LDAP extended response.
118   */
119  public final ExtendedResult toExtendedResult()
120  {
121    return extendedResult;
122  }
123
124
125
126  /**
127   * Retrieves a string representation of this LDAP extended response.
128   *
129   * @return  A string representation of this LDAP extended response.
130   */
131  @Override()
132  public String toString()
133  {
134    return extendedResult.toString();
135  }
136}