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 java.util.Date; 026 027import com.unboundid.asn1.ASN1Element; 028import com.unboundid.asn1.ASN1OctetString; 029import com.unboundid.util.NotMutable; 030import com.unboundid.util.ThreadSafety; 031import com.unboundid.util.ThreadSafetyLevel; 032import com.unboundid.util.StaticUtils; 033 034 035 036/** 037 * This class provides an implementation of a changelog batch starting point 038 * which may be used to start a batch of changes at a specified time. The first 039 * change of the batch will be the first change on any server with a change time 040 * greater than or equal to the specified time. 041 * <BR> 042 * <BLOCKQUOTE> 043 * <B>NOTE:</B> This class, and other classes within the 044 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 045 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 046 * server products. These classes provide support for proprietary 047 * functionality or for external specifications that are not considered stable 048 * or mature enough to be guaranteed to work in an interoperable way with 049 * other types of LDAP servers. 050 * </BLOCKQUOTE> 051 */ 052@NotMutable() 053@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 054public final class ChangeTimeStartingPoint 055 extends ChangelogBatchStartingPoint 056{ 057 /** 058 * The BER type to use for the ASN.1 element used to encode this starting 059 * point. 060 */ 061 static final byte TYPE = (byte) 0x84; 062 063 064 065 /** 066 * The serial version UID for this serializable class. 067 */ 068 private static final long serialVersionUID = 920153185766534528L; 069 070 071 072 // The time that defines the starting point for the changelog batch request. 073 private final long changeTime; 074 075 // The string representation of the start time, using the generalized time 076 // syntax. 077 private final String changeTimeString; 078 079 080 081 /** 082 * Creates a new instance of this changelog starting point using the provided 083 * start time. 084 * 085 * @param changeTime The time of the oldest change which may be used as the 086 * starting point for the batch of changes. 087 */ 088 public ChangeTimeStartingPoint(final long changeTime) 089 { 090 this.changeTime = changeTime; 091 092 changeTimeString = StaticUtils.encodeGeneralizedTime(new Date(changeTime)); 093 } 094 095 096 097 /** 098 * Retrieves the time of the oldest change which may be used as the starting 099 * point for the batch of changes. 100 * 101 * @return The time of the oldest change which may be used as the starting 102 * point for the batch of changes. 103 */ 104 public long getChangeTime() 105 { 106 return changeTime; 107 } 108 109 110 111 /** 112 * {@inheritDoc} 113 */ 114 @Override() 115 public ASN1Element encode() 116 { 117 return new ASN1OctetString(TYPE, changeTimeString); 118 } 119 120 121 122 /** 123 * {@inheritDoc} 124 */ 125 @Override() 126 public void toString(final StringBuilder buffer) 127 { 128 buffer.append("ChangeTimeStartingPoint(time='"); 129 buffer.append(changeTimeString); 130 buffer.append("')"); 131 } 132}