Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/formatting/format
In directory sc8-pr-cvs1:/tmp/cvs-serv19735/src/java/org/krysalis/version/formatting/format
Modified Files:
KrysalisVersionFormat.java VersionFormatImpl.java
Added Files:
GenericVersionFormat.java EclipseVersionFormat.java
Log Message:
Starting to expand the capabilities beyond the basic format & data elements
Lots more to do to complete this...
--- NEW FILE: GenericVersionFormat.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis(http : //www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name, without
prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in respect
of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.formatting.format;
import org.krysalis.version.internal.InternalVersionConstants;
import org.krysalis.version.internal.data.VersionDataElementSet;
/**
* @author ajack
*/
public class GenericVersionFormat extends KrysalisVersionFormat {
//:TODO: Make it sensetive to elements...
private VersionDataElementSet m_elements = null;
public GenericVersionFormat(int elementMask) {
m_elements = new VersionDataElementSet(elementMask);
}
public String getFormatId() {
return InternalVersionConstants.VERSION_PACKAGE+".generic";
}
public String getVersionFormatMask() {
return null; //:TODO:
}
// :TODO: Check these w/ some JDK1.4 only regexp code
public String getVersionFormatRegularExpression() {
return ""; //:TODO:
}
public String getVersionFormatDescription() {
return "http://metamorphosis.krysalis.org/cgi-bin/mmorphosiswiki.pl?Version";
}
}
--- NEW FILE: EclipseVersionFormat.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01
Copyright (c) 2002-2003 Nicola Ken Barozzi. All rights reserved.
This Licence is compatible with the BSD licence as described and
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The end-user documentation included with the redistribution,
if any, must include the following acknowledgment:
"This product includes software developed for project
Krysalis(http : //www.krysalis.org/)."
Alternately, this acknowledgment may appear in the software itself,
if and wherever such third-party acknowledgments normally appear.
4. The names "Krysalis" and "Nicola Ken Barozzi" and
"Krysalis Centipede" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [email protected].
5. Products derived from this software may not be called "Krysalis",
"Krysalis Centipede", nor may "Krysalis" appear in their name, without
prior written permission of Nicola Ken Barozzi.
6. This software may contain voluntary contributions made by many
individuals, who decided to donate the code to this project in respect
of this licence.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.formatting.format;
import java.util.StringTokenizer;
import org.krysalis.version.formatting.exception.VersionFormatException;
import org.krysalis.version.internal.data.ReleaseLevel;
import org.krysalis.version.internal.data.VersionData;
import org.krysalis.version.internal.data.VersionDataElement;
import org.krysalis.version.internal.data.VersionDataElementSet;
/**
* @author ajack
*/
public class EclipseVersionFormat extends VersionFormatImpl {
public EclipseVersionFormat() {
}
public String getFormatId() {
return "org.eclipse";
}
public String getVersionFormatVersion() {
return "1.1.1";
}
public String getVersionFormatMask() {
return "{MAJOR}.{MINOR}.{POINT}.{RELEASE_LEVEL}";
}
// :TODO: Check these w/ some JDK1.4 only regexp code
public String getVersionFormatRegularExpression() {
return "([0-9]*)\\.([0-9]*)\\.([0-9]*)";
}
public String getVersionFormatDescription() {
return "http://eclipse.org";
}
public VersionData parseVersion(String versionString)
throws VersionFormatException {
VersionData data = null;
StringTokenizer tokens = new StringTokenizer(versionString, "._-");
//:TODO: get stuff after _ or after - ... i.e. "-rc"
int elements =
VersionDataElement.ELEMENT_MAJOR | VersionDataElement.ELEMENT_MINOR;
int major =
parseInt(
versionString,
VersionDataElement.MAJOR,
tokens.nextToken());
int minor =
parseInt(
versionString,
VersionDataElement.MINOR,
tokens.nextToken());
int point = VersionDataElement.DEFAULT_POINT;
ReleaseLevel releaseLevel = VersionDataElement.DEFAULT_RELEASE_LEVEL;
int releaseQualifier = VersionDataElement.DEFAULT_RELEASE_QUALIFIER;
int buildNumber = VersionDataElement.DEFAULT_BUILD_NUMBER;
if (tokens.hasMoreTokens()) {
elements |= VersionDataElement.ELEMENT_POINT;
point =
parseInt(
versionString,
VersionDataElement.POINT,
tokens.nextToken());
}
data =
new VersionData(
new VersionDataElementSet(elements),
major,
minor,
releaseLevel,
releaseQualifier,
point,
buildNumber);
return data;
}
public String toVersionString(VersionData data) {
StringBuffer output = new StringBuffer();
output.append(Integer.toString(data.getMajor()));
output.append(".");
output.append(Integer.toString(data.getMinor()));
if (0 != data.getPoint()) {
output.append(".");
output.append(Integer.toString(data.getPoint()));
}
if (ReleaseLevel.RELEASE.equals(data.getReleaseLevel())) {
output.append("Final");
}
return output.toString();
}
}
Index: KrysalisVersionFormat.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/formatting/format/KrysalisVersionFormat.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** KrysalisVersionFormat.java 7 Feb 2003 20:11:45 -0000 1.9
--- KrysalisVersionFormat.java 7 Mar 2003 20:01:36 -0000 1.10
***************
*** 63,66 ****
--- 63,67 ----
import org.krysalis.version.internal.data.VersionData;
import org.krysalis.version.internal.data.VersionDataElement;
+ import org.krysalis.version.internal.data.VersionDataElementSet;
/**
***************
*** 68,75 ****
*/
public class KrysalisVersionFormat extends VersionFormatImpl {
!
public KrysalisVersionFormat() {
}
!
public String getFormatId() {
return InternalVersionConstants.VERSION_PACKAGE;
--- 69,76 ----
*/
public class KrysalisVersionFormat extends VersionFormatImpl {
!
public KrysalisVersionFormat() {
}
!
public String getFormatId() {
return InternalVersionConstants.VERSION_PACKAGE;
***************
*** 98,101 ****
--- 99,103 ----
public VersionData parseVersion(String versionString)
throws VersionFormatException {
+ int elementMask = 0;
VersionData data = null;
***************
*** 105,108 ****
--- 107,111 ----
StringTokenizer tokens = new StringTokenizer(versionString, ". ");
+ elementMask |= VersionDataElement.ELEMENT_MAJOR;
int major =
parseInt(
***************
*** 120,123 ****
--- 123,127 ----
minorToken = minorToken.substring(0, dashPos);
}
+ elementMask |= VersionDataElement.ELEMENT_MINOR;
minor =
parseInt(versionString, VersionDataElement.MINOR, minorToken);
***************
*** 147,150 ****
--- 151,155 ----
try {
+ elementMask |= VersionDataElement.ELEMENT_POINT;
point =
parseInt(
***************
*** 162,169 ****
if (remainder.length() > 0)
try {
releaseLevel =
parseReleaseLevel(versionString, remainder);
! if (tokens2.hasMoreTokens())
buildNumber =
parseInt(
--- 167,177 ----
if (remainder.length() > 0)
try {
+ elementMask |= VersionDataElement.ELEMENT_RELEASE_LEVEL;
releaseLevel =
parseReleaseLevel(versionString, remainder);
! if (tokens2.hasMoreTokens()) {
! elementMask
! |= VersionDataElement.ELEMENT_BUILD_NUMBER;
buildNumber =
parseInt(
***************
*** 171,176 ****
--- 179,186 ----
VersionDataElement.BUILD_NUMBER,
tokens2.nextToken());
+ }
}
catch (VersionFormatException vfe) {
+ elementMask |= VersionDataElement.ELEMENT_BUILD_NUMBER;
buildNumber =
parseInt(
***************
*** 183,186 ****
--- 193,197 ----
return new VersionData(
+ new VersionDataElementSet(elementMask),
major,
minor,
***************
*** 197,201 ****
output.append(".");
output.append(Integer.toString(data.getMinor()));
!
int point = data.getPoint();
if (point > VersionDataElement.UNSET_POINT) {
--- 208,212 ----
output.append(".");
output.append(Integer.toString(data.getMinor()));
!
int point = data.getPoint();
if (point > VersionDataElement.UNSET_POINT) {
Index: VersionFormatImpl.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/formatting/format/VersionFormatImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** VersionFormatImpl.java 5 Mar 2003 19:57:40 -0000 1.3
--- VersionFormatImpl.java 7 Mar 2003 20:01:37 -0000 1.4
***************
*** 56,60 ****
package org.krysalis.version.formatting.format;
- import java.io.PrintStream;
import java.io.PrintWriter;
--- 56,59 ----
***************
*** 131,146 ****
return releaseLevel;
}
!
! public void dump(PrintStream out) {
! dump((new PrintWriter(out, true)));
! }
!
! public void dump(PrintWriter out) {
out.println("Format Name:" + getName());
out.println("Format Mask:" + getVersionFormatMask());
out.println("Description:" + getVersionFormatDescription());
//:TODO: More?
-
}
}
--- 130,150 ----
return releaseLevel;
}
!
! public void dump(PrintWriter out, int depth) {
! final String indent = DebugUtils.getIndent(depth);
!
! out.print(indent);
out.println("Format Name:" + getName());
+
+ out.print(indent);
+ out.println("Format Id:" + getFormatId());
+
+ out.print(indent);
out.println("Format Mask:" + getVersionFormatMask());
+
+ out.print(indent);
out.println("Description:" + getVersionFormatDescription());
//:TODO: More?
}
}
-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.