📄 cvsrevision.java
字号:
package org.jutil.junit;import org.jutil.jregex.Pattern;/** * A class of CVS revisions. A revision is created using the string * that CVS uses to save version information in a file. * * <center> * <img src="doc-files/CVSRevision.png"/> * </center> * * @path $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/junit/CVSRevision.java,v $ * @version $Revision: 1.7 $ * @date $Date: 2002/07/21 10:30:35 $ * @state $State: Exp $ * @author Marko van Dooren * @release $Name: $ */public class CVSRevision extends AbstractRevision { /* The revision of this class */ public final static String CVS_REVISION ="$Revision: 1.7 $"; /** * Initialize a new CVSRevision with the given String. * * @param revision * A String representing the CVS revision. This is the string * the CVS itself uses. The format is "$Revision: 1.7 $", where x * is the version number, or just "1.3.234.1.5" or so . * The format is more formally described in the preconditions. */ /*@ @ public behavior @ @ pre revision != null; @ // The revision must either be a revision number, or a CVS revision string. @ // In other words : "x.x.x.x" or "$Revision: 1.7 $". @ pre new Pattern("\\d*(\\.(\\d)*)*").matcher(revision).matches() || @ new Pattern("$Revision: 1.7 $").matcher(revision).matches(); @ @ post (* number i == the i'th x *); @*/ public CVSRevision(String revision) { int index = 0; int nbDots = 0; while(index >= 0) { index = revision.indexOf(".",index+1); if(index >= 0) { nbDots++; } } // number of .'s == number of x's - 1 _numbers = new int[nbDots+1]; index = revision.indexOf(" ") + 1; int prev = index; for(int i=1; i <= nbDots; i++) { index = revision.indexOf(".",index+1); _numbers[i-1] = new Integer(revision.substring(prev,index)).intValue(); prev=index+1; } index = revision.indexOf(" ", index); if(index < 0) { // In this case an ordinary number is supplied. index = revision.length(); } _numbers[nbDots] = new Integer(revision.substring(prev,index)).intValue(); } /** * See superclass. */ public int getNumber(int index) { if(index > length()) { return 0; } return _numbers[index-1]; } /** * See superclass. */ public int length() { return _numbers.length; } /*@ @ private invariant _numbers != null; @ private invariant _numbers.length >= 1; @ private invariant (\forall int i; i>=0 && i<_numbers.length; @ _numbers[i] >= 0); @*/ private int[] _numbers;}/* * <copyright>Copyright (C) 1997-2001. This software is copyrighted by * the people and entities mentioned after the "@author" tags above, on * behalf of the JUTIL.ORG Project. The copyright is dated by the dates * after the "@date" tags above. All rights reserved. * This software is published under the terms of the JUTIL.ORG Software * License version 1.1 or later, a copy of which has been included with * this distribution in the LICENSE file, which can also be found at * http://org-jutil.sourceforge.net/LICENSE. This software is distributed * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the JUTIL.ORG Software License for more details. For more information, * please see http://org-jutil.sourceforge.net/</copyright> */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -