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