View Javadoc

1   package org.apache.maven.scm.provider.accurev;
2   
3   import java.util.Date;
4   
5   import org.codehaus.plexus.util.StringUtils;
6   
7   /*
8    * Licensed to the Apache Software Foundation (ASF) under one
9    * or more contributor license agreements.  See the NOTICE file
10   * distributed with this work for additional information
11   * regarding copyright ownership.  The ASF licenses this file
12   * to you under the Apache License, Version 2.0 (the
13   * "License"); you may not use this file except in compliance
14   * with the License.  You may obtain a copy of the License at
15   *
16   *    http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing,
19   * software distributed under the License is distributed on an
20   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21   * KIND, either express or implied.  See the License for the
22   * specific language governing permissions and limitations
23   * under the License.
24   */
25  
26  public class AccuRevVersion {
27  
28  	private String basisStream;
29  
30  	private String timeSpec;
31  
32  	public AccuRevVersion(String basisStream, String tran) {
33  
34  		this.basisStream = basisStream;
35  		this.timeSpec = tran;
36  	}
37  
38  	public String getBasisStream() {
39  		return basisStream;
40  	}
41  
42  	public String getTimeSpec() {
43  		return timeSpec;
44  	}
45  
46  	public AccuRevVersion(String basis, Date startDate) {
47  		this(basis, AccuRev.ACCUREV_TIME_SPEC.format(startDate));
48  	}
49  
50  	public AccuRevVersion(String basis, long transactionId) {
51  		this(basis, Long.toString(transactionId));
52  	}
53  
54  	public boolean isNow() {
55  		return isNow(this.timeSpec);
56  	}
57  
58  	@Override
59  	public String toString() {
60  		return String.format("AccuRevVersion: stream = %s, transaction= %s",
61  				basisStream, timeSpec);
62  	}
63  
64  	public static boolean isNow(String timeSpec) {
65  		return StringUtils.isBlank(timeSpec) || "highest".equalsIgnoreCase(timeSpec)
66  				|| "now".equalsIgnoreCase(timeSpec);
67  	}
68  }