com.unboundid.ldap.sdk.unboundidds.extensions.ChangelogBatchChangeSelectionCriteria Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of unboundid-ldapsdk-commercial-edition Show documentation
                Show all versions of unboundid-ldapsdk-commercial-edition Show documentation
      The UnboundID LDAP SDK for Java is a fast, comprehensive, and easy-to-use
      Java API for communicating with LDAP directory servers and performing
      related tasks like reading and writing LDIF, encoding and decoding data
      using base64 and ASN.1 BER, and performing secure communication.  This
      package contains the Commercial Edition of the LDAP SDK, which includes
      all of the general-purpose functionality contained in the Standard
      Edition, plus additional functionality specific to UnboundID server
      products.
    
                
            /*
 * Copyright 2011-2016 UnboundID Corp.
 * All Rights Reserved.
 */
/*
 * Copyright (C) 2015-2016 UnboundID Corp.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (GPLv2 only)
 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see .
 */
package com.unboundid.ldap.sdk.unboundidds.extensions;
import com.unboundid.asn1.ASN1Element;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.ResultCode;
import com.unboundid.util.Debug;
import com.unboundid.util.NotExtensible;
import com.unboundid.util.StaticUtils;
import com.unboundid.util.ThreadSafety;
import com.unboundid.util.ThreadSafetyLevel;
import com.unboundid.util.Validator;
import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
/**
 * 
 *   NOTE:  This class is part of the Commercial Edition of the UnboundID
 *   LDAP SDK for Java.  It is not available for use in applications that
 *   include only the Standard Edition of the LDAP SDK, and is not supported for
 *   use in conjunction with non-UnboundID products.
 * 
 * This class defines an API that should be implemented by classes which may
 * represent a way to pare down the changelog entries that should be returned
 * (e.g., so that they only include changes to a particular attribute or set of
 * attributes) when using the {@link GetChangelogBatchExtendedRequest}.
 */
@NotExtensible()
@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
public abstract class ChangelogBatchChangeSelectionCriteria
{
  /**
   * The outer BER type that should be used for encoded elements that represent
   * a get changelog batch selection criteria value.
   */
  static final byte TYPE_SELECTION_CRITERIA = (byte) 0xA7;
  /**
   * Encodes this changelog batch change selection criteria value to an ASN.1
   * element suitable for inclusion in the get changelog batch extended request.
   *
   * @return  An ASN.1 element containing the encoded representation of this
   *          changelog batch change selection criteria value.
   */
  public final ASN1Element encode()
  {
    return new ASN1Element(TYPE_SELECTION_CRITERIA,
         encodeInnerElement().encode());
  }
  /**
   * Encodes the inner element for this changelog batch change selection
   * criteria to an ASN.1 element.
   *
   * @return  The encoded representation of the inner element to include in the
   *          encoded representation of the changelog batch change selection
   *          criteria element.
   */
  protected abstract ASN1Element encodeInnerElement();
  /**
   * Decodes the provided ASN.1 element as a changelog batch change selection
   * criteria value.
   *
   * @param  element  The ASN.1 element to be decoded.  It must not be
   *                  {@code null}.
   *
   * @return  The decoded changelog batch change selection criteria value.
   *
   * @throws  LDAPException  If the provided ASN.1 element cannot be decoded as
   *                         a changelog batch starting point.
   */
  public static ChangelogBatchChangeSelectionCriteria decode(
                     final ASN1Element element)
         throws LDAPException
  {
    Validator.ensureNotNull(element);
    // The value of the element is itself an ASN.1 element, and we need to use
    // its BER type to figure out what type of element it is.
    final ASN1Element innerElement;
    try
    {
      innerElement = ASN1Element.decode(element.getValue());
    }
    catch (final Exception e)
    {
      Debug.debugException(e);
      throw new LDAPException(ResultCode.DECODING_ERROR,
           ERR_CLBATCH_CHANGE_SELECTION_CRITERIA_DECODE_INNER_FAILURE.get(
                StaticUtils.getExceptionMessage(e)),
           e);
    }
    switch (innerElement.getType())
    {
      case AnyAttributesChangeSelectionCriteria.
           TYPE_SELECTION_CRITERIA_ANY_ATTRIBUTES:
        return AnyAttributesChangeSelectionCriteria.decodeInnerElement(
             innerElement);
      case AllAttributesChangeSelectionCriteria.
           TYPE_SELECTION_CRITERIA_ALL_ATTRIBUTES:
        return AllAttributesChangeSelectionCriteria.decodeInnerElement(
             innerElement);
      case IgnoreAttributesChangeSelectionCriteria.
           TYPE_SELECTION_CRITERIA_IGNORE_ATTRIBUTES:
        return IgnoreAttributesChangeSelectionCriteria.decodeInnerElement(
             innerElement);
      case NotificationDestinationChangeSelectionCriteria.
           TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION:
        return NotificationDestinationChangeSelectionCriteria.
             decodeInnerElement(innerElement);
      default:
        throw new LDAPException(ResultCode.DECODING_ERROR,
             ERR_CLBATCH_CHANGE_SELECTION_CRITERIA_UNKNOWN_TYPE.get(
                  StaticUtils.toHex(innerElement.getType())));
    }
  }
  /**
   * Retrieves a string representation of this changelog batch change selection
   * criteria value.
   *
   * @return  A string representation of this changelog batch change selection
   *          criteria value.
   */
  @Override()
  public final String toString()
  {
    final StringBuilder buffer = new StringBuilder();
    toString(buffer);
    return buffer.toString();
  }
  /**
   * Appends a string representation of this changelog batch change selection
   * criteria value to the provided buffer.
   *
   * @param  buffer  The buffer to which the information should be appended.
   */
  public abstract void toString(final StringBuilder buffer);
}
     © 2015 - 2025 Weber Informatics LLC | Privacy Policy