001    package org.apache.maven.scm.provider.accurev;
002    
003    import java.util.Date;
004    
005    import org.codehaus.plexus.util.StringUtils;
006    
007    /*
008     * Licensed to the Apache Software Foundation (ASF) under one
009     * or more contributor license agreements.  See the NOTICE file
010     * distributed with this work for additional information
011     * regarding copyright ownership.  The ASF licenses this file
012     * to you under the Apache License, Version 2.0 (the
013     * "License"); you may not use this file except in compliance
014     * with the License.  You may obtain a copy of the License at
015     *
016     *    http://www.apache.org/licenses/LICENSE-2.0
017     *
018     * Unless required by applicable law or agreed to in writing,
019     * software distributed under the License is distributed on an
020     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
021     * KIND, either express or implied.  See the License for the
022     * specific language governing permissions and limitations
023     * under the License.
024     */
025    
026    public class AccuRevVersion {
027    
028            private String basisStream;
029    
030            private String timeSpec;
031    
032            public AccuRevVersion(String basisStream, String tran) {
033    
034                    this.basisStream = basisStream;
035                    this.timeSpec = tran;
036            }
037    
038            public String getBasisStream() {
039                    return basisStream;
040            }
041    
042            public String getTimeSpec() {
043                    return timeSpec;
044            }
045    
046            public AccuRevVersion(String basis, Date startDate) {
047                    this(basis, AccuRev.ACCUREV_TIME_SPEC.format(startDate));
048            }
049    
050            public AccuRevVersion(String basis, long transactionId) {
051                    this(basis, Long.toString(transactionId));
052            }
053    
054            public boolean isNow() {
055                    return isNow(this.timeSpec);
056            }
057    
058            @Override
059            public String toString() {
060                    return String.format("AccuRevVersion: stream = %s, transaction= %s",
061                                    basisStream, timeSpec);
062            }
063    
064            public static boolean isNow(String timeSpec) {
065                    return StringUtils.isBlank(timeSpec) || "highest".equalsIgnoreCase(timeSpec)
066                                    || "now".equalsIgnoreCase(timeSpec);
067            }
068    }