001/*
002 * Copyright 2010-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
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.unboundidds.extensions;
022
023
024
025import com.unboundid.asn1.ASN1Element;
026import com.unboundid.asn1.ASN1OctetString;
027import com.unboundid.util.Base64;
028import com.unboundid.util.NotMutable;
029import com.unboundid.util.ThreadSafety;
030import com.unboundid.util.ThreadSafetyLevel;
031import com.unboundid.util.Validator;
032
033
034
035/**
036 * This class provides an implementation of a changelog batch starting point
037 * which may be used to start a batch of changes at a point where a previous
038 * batch ended.  The first change of the batch will be the change immediately
039 * after the change associated with the provided token.
040 * <BR>
041 * <BLOCKQUOTE>
042 *   <B>NOTE:</B>  This class, and other classes within the
043 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
044 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
045 *   server products.  These classes provide support for proprietary
046 *   functionality or for external specifications that are not considered stable
047 *   or mature enough to be guaranteed to work in an interoperable way with
048 *   other types of LDAP servers.
049 * </BLOCKQUOTE>
050 */
051@NotMutable()
052@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
053public final class ResumeWithTokenStartingPoint
054       extends ChangelogBatchStartingPoint
055{
056  /**
057   * The BER type to use for the ASN.1 element used to encode this starting
058   * point.
059   */
060  static final byte TYPE = (byte) 0x80;
061
062
063
064  /**
065   * The serial version UID for this serializable class.
066   */
067  private static final long serialVersionUID = -101217605840282165L;
068
069
070
071  // The content of the token to use when resuming a batch.
072  private final ASN1OctetString resumeToken;
073
074
075
076  /**
077   * Creates a new instance of this changelog batch starting point using the
078   * provided resume token.
079   *
080   * @param  resumeToken  The token which may be used to resume changelog access
081   *                      at the point where it previously ended.  It must not
082   *                      be {@code null}.
083   */
084  public ResumeWithTokenStartingPoint(final ASN1OctetString resumeToken)
085  {
086    Validator.ensureNotNull(resumeToken);
087
088    this.resumeToken = resumeToken;
089  }
090
091
092
093  /**
094   * Retrieves the token which may be used to resume changelog access at the
095   * point where it previously ended.
096   *
097   * @return  The token which may be used to resume changelog access at the
098   *          point where it previously ended.
099   */
100  public ASN1OctetString getResumeToken()
101  {
102    return resumeToken;
103  }
104
105
106
107  /**
108   * {@inheritDoc}
109   */
110  @Override()
111  public ASN1Element encode()
112  {
113    return new ASN1OctetString(TYPE, resumeToken.getValue());
114  }
115
116
117
118  /**
119   * {@inheritDoc}
120   */
121  @Override()
122  public void toString(final StringBuilder buffer)
123  {
124    buffer.append("ResumeWithTokenStartingPoint(token='");
125    Base64.encode(resumeToken.getValue(), buffer);
126    buffer.append("')");
127  }
128}