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