001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.core.changelog;
021
022
023 import java.util.Date;
024
025
026 /**
027 * A tag on a revision representing a snapshot of the directory server's
028 * state.
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $Rev$, $Date$
032 */
033 public class Tag
034 {
035
036 private final long revision;
037 private final String description;
038
039 /** the date on which this tag was created*/
040 private Date tagDate;
041
042 /** the date of revision that was tagged*/
043 private Date revisionDate;
044
045
046 public Tag( long revision, String description )
047 {
048 this.revision = revision;
049 this.description = description;
050 this.tagDate = new Date();
051 }
052
053
054 public Tag( long revision, String description, Date tagDate, Date revisionDate )
055 {
056 this.revision = revision;
057 this.description = description;
058 this.tagDate = tagDate;
059 this.revisionDate = revisionDate;
060 }
061
062
063 public Tag( long revision, String description, long tagTime, long revisionTime )
064 {
065 this.revision = revision;
066 this.description = description;
067 this.tagDate = new Date( tagTime );
068
069 if( revisionTime > 0 )
070 {
071 this.revisionDate = new Date( revisionTime );
072 }
073 }
074
075
076 /**
077 * @return the revision
078 */
079 public long getRevision()
080 {
081 return revision;
082 }
083
084
085 /**
086 * @return the description
087 */
088 public String getDescription()
089 {
090 return description;
091 }
092
093
094 public Date getTagDate()
095 {
096 return tagDate;
097 }
098
099
100 public Date getRevisionDate()
101 {
102 return revisionDate;
103 }
104
105
106 public boolean equals( Object other )
107 {
108 if ( other instanceof Tag )
109 {
110 Tag ot = ( Tag ) other;
111
112 if ( description != null && ot.getDescription() != null )
113 {
114 return revision == ot.getRevision() && description.equals( ot.getDescription() );
115 }
116 else if ( description == null && ot.getDescription() == null )
117 {
118 return revision == ot.getRevision();
119 }
120 }
121
122 return false;
123 }
124
125
126 @Override
127 public String toString()
128 {
129 StringBuilder sb = new StringBuilder();
130 sb.append( "Tag { " );
131
132 sb.append( "revision = " )
133 .append( revision )
134 .append( ", " );
135
136 sb.append( " tagDate = " )
137 .append( tagDate )
138 .append( ", " );
139
140 sb.append( " revisionDate = " )
141 .append( revisionDate );
142
143 sb.append( " }" );
144
145 return sb.toString();
146 }
147
148
149 }