krysalis-version/src/java/org/apache/depot/version VersionFormat.java,NONE,1.1 VersionFormatException.java,NONE,1.1 Version.java,NONE,1.1 VersionMarker.java,NONE,1.1 VersionRuntimeException.java,NONE,1.1 VersionManager.java,NONE,1.1 VersionSpecification.java,NONE,1.1 VersionConstants.java,NONE,1.1 VersionException.java,NONE,1.1 VersionError.java,NONE,1.1
Nick Chalko <[email protected]>
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-version/src/java/org/apache/depot/version
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2482/src/java/org/apache/depot/version
Added Files:
VersionFormat.java VersionFormatException.java Version.java
VersionMarker.java VersionRuntimeException.java
VersionManager.java VersionSpecification.java
VersionConstants.java VersionException.java VersionError.java
Log Message:
Moved some initial files over nothing compiles yet.
--- NEW FILE: Version.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
import java.util.Comparator;
// :TODO: Based upon thoughts from Anou..
//
// This class is a good start to allow other implementations
// however for a complete "drop in implementation" there is more
// needed. So, either we extend this -- or we keep this simple
// and somehow have a separate VersionImplementation interface/plug-in.
//
// Things that ought be done:
//
// Resolver --- find a Version for an id (string)
// Collecting --- brute force look-ups/extraction
// (Is "collecting" part of resolving?)
// Parse --- could be put into the Version(String ) ctor.
// Others? Dep/Constr? etc.?
//
/**
* This primary Version interface.
*
* This class provides NO restrictions on what and how to
* order and format or display version. How it is created incremented or
* displayed is completly independent.
*
* Given Version objects a and b
* <ul>
* <li>a.equals(b) iff b.equals(a)</li>
* <li>a.compare(b) == 0 iff a.equals(b)</li>
* <li>a.equals(b) --> a.hashCode() == b.hashCode()</li>
* <li>a.equals(b) --> a.isCompatible(b)</li>
* </ul>
* <br/>
* NOTE: Version should be implemented as a Immutable object.
*
* @version $ $
*/
public interface Version extends Comparable {
/**
* May this version be used in place of the specified version.
* @param version the BaseVersion to check with
* @return boolean true iff this Version may be used in place of the specified version.
*/
boolean isCompatible(Version version);
/**
* Create a new VersionObject that is one "level" more.
* Level is implementation specific name, such as "release"or "beta".
* !v.equals(v.increment(X))
* v.compare(v.increment(X))) < 0
* @param level A string decribe the level of the next release
* @return Version a new Version one level higher.
* @throws VersionException
*/
Version increment(String level) throws VersionException;
/**
* Gets version Comparator. Usefull for sorting.
* The Comparator will throw a IllegalArgument of the two objects do not
* have exactly the same id.
* @return Comparator
*
*/
Comparator getComparator();
}
--- NEW FILE: VersionRuntimeException.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
/**
* @author ajack
*/
public class VersionRuntimeException extends RuntimeException {
/**
*
*/
public VersionRuntimeException() {
super();
// TODO Auto-generated constructor stub
}
/**
* @param message
*/
public VersionRuntimeException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
/**
* @param message
* @param cause
*/
public VersionRuntimeException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
/**
* @param cause
*/
public VersionRuntimeException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
--- NEW FILE: VersionException.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
/**
* @author ajack
*/
public class VersionException extends Exception {
/**
*
*/
public VersionException() {
super();
}
/**
* @param message
*/
public VersionException(String message) {
super(message);
}
/**
* @param message
* @param cause
*/
public VersionException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param cause
*/
public VersionException(Throwable cause) {
super(cause);
}
}
--- NEW FILE: VersionSpecification.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
import java.util.Map;
/**
* Describes a specific version specifcation.
* TODO: this should probably move to the top level package.
*
* @author ajack
*/
public interface VersionSpecification {
/**
* The globally unique id of the specification
* @return the specification id as a String
*/
String getId();
/**
* The description of this specification
* @return the description as a String
*/
String getDescription();
// Data Contents
int getElementMask();
/**
* The version formater for this specification.
* @return the VersionFormat used by this specification.
*/
VersionFormat getVersionFormat();
}
--- NEW FILE: VersionMarker.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
import java.util.List;
import java.util.Map;
// :TODO: Based upon thoughts from Anou..
//
// This class is a good start to allow other implementations
// however for a complete "drop in implementation" there is more
// needed. So, either we extend this -- or we keep this simple
// and somehow have a separate VersionImplementation interface/plug-in.
//
// Things that ought be done:
//
// Resolver --- find a Version for an id (string)
// Collecting --- brute force look-ups/extraction
// (Is "collecting" part of resolving?)
// Parse --- could be put into the Version(String ) ctor.
// Others? Dep/Constr? etc.?
//
/**
* WHAT IS THIS INTERFACCE FOR.
* Version is just a "number" a VersionMarker. Is associated with a ID and therefer a program ?
* What is the differnce between Attributes and Annontations
*
* NOTE: VersionMarker should be implemented as a Immutable object.
*
* @author $Author: chalko $
* @version $Revision: 1.1 $
*/
public interface VersionMarker extends Comparable {
/**
* Get the globaly unique id for the Product. (org.apache.version)
* This should be a SAFE name without special chars of spaces.
* @return String
*/
String getId();
/**
* Version (1.2.7)
* @return Version
*/
Version getVersion();
/**
* Short Version (1.2)
* @return String
*/
String getShortVersion();
/**
* Long Version 1.2.7 (fred) built June 7,1981
* @return String
*/
String getLongVersion(); // TODO: Rename as asLongFormat
/**
* Default Version 1.2.7 (fred) built June 7,1981
* @return String
*/
String getDefaultVersion(); // TODO: Rename as asLongFormat
/**
* Get any associated attributes, or null if none.
*/
Map getAttributes();
/**
* Get any associated annotations, or null if none.
*/
List getAnnotations();
/**
* The specifiaction used for this version.
* @return VersionSpecification
*/
VersionSpecification getSpecification();
}
--- NEW FILE: VersionFormat.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
/**
*
*
* Implements field -> method
*
* Get from :
*
* public static final {Class} {METHOD_NAME}
*
* Set to:
*
* public set{MethodName}({Class})
*
*
* @author ajack
*/
public interface VersionFormat {
public final String LONG = "LONG";
public final String SHORT = "SHORT";
public final String DEFUALT = "DEFAULT";
String getFormatId();
/**
* Parse a version creating a VersionData object for it.
*
* @param version
* The version string to be parsed
* @return a Version representing the Version specified by the string.
*
* @throws VersionFormatException
*
*/
public Version parseVersion(String version) throws VersionFormatException;
}
--- NEW FILE: VersionConstants.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
/**
* @author ajack
*/
public class VersionConstants {
public static final String BASE = "org.krysalis.version";
// Version Attributes
public static final String DESCRIPTION = BASE + ".description";
public static final String LOCATION_URL = BASE + ".location.url";
private static final String BUILD_BASE = BASE + ".build";
public static final String BUILD_JVM = BUILD_BASE + ".jvm";
public static final String BUILD_DATETIME = BUILD_BASE + ".datetime";
public static final String BUILD_ANT = BUILD_BASE + ".ant";
public static final String BUILD_HOST = BUILD_BASE + ".host";
public static final String BUILD_USER = BUILD_BASE + ".user";
public static final String BUILD_TAG = BUILD_BASE + ".tag";
}
--- NEW FILE: VersionFormatException.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
import org.apache.depot.version.VersionException;
/**
* @author ajack
*/
public class VersionFormatException extends VersionException {
private VersionFormat m_format = null;
/**
* Constructor for FormatException.
*/
public VersionFormatException(VersionFormat format) {
super();
m_format = format;
}
/**
* Constructor for FormatException.
* @param message
*/
public VersionFormatException(VersionFormat format, String message) {
super(message);
m_format = format;
}
/**
* Constructor for FormatException.
* @param message
* @param cause
*/
public VersionFormatException(
VersionFormat format,
String message,
Throwable cause) {
super(message, cause);
m_format = format;
}
/**
* Constructor for FormatException.
* @param cause
*/
public VersionFormatException(VersionFormat format, Throwable cause) {
super(cause);
m_format = format;
}
/**
* Returns the format.
* @return VersionFormat
*/
public VersionFormat getFormat() {
return m_format;
}
/**
* @see java.lang.Throwable#getMessage()
*/
public String getMessage() {
return super.getMessage() + ", format: " + m_format;
}
}
--- NEW FILE: VersionManager.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
import java.util.Map;
/**
* @author [email protected]
*/
public class VersionManager {
public static final VersionManager getManager() {
return new VersionManager();
}
/**
* Create a version marker from and ID and a version string.
*
* @param id
* The id of the versioned artifact
* @param version
* as a String
* @return a VersinMarker object.
* @throws VersionException
*/
public final VersionMarker createVersionMarker(String id, String version)
throws VersionException {
return new ApacheVersionMarker(id, version);
}
/**
* Create a VersionMarker from an arbitrary object. Usually a generated
* version stamp.
*
* @param stamp
* A instance if a version stamp.
* @return VersionMarker of the correct spec with all values filled in.
*/
public VersionMarker createVersionMarker(Object stamp) {
try {
String specId = getSpecificationId(stamp);
String versionString = getVersionString(stamp);
VersionIdentifier id = VersionIdentifier
.extractVersionIdentifier(stamp);
Map properties = getProperties(stamp);
VersionSpecification spec = VersionSpecificationFactory
.createVersionSpecificationFromId(specId);
final VersionMarker marker = spec.createVersionMarker(
new VersionIdentifier(id), versionString, properties);
return marker;
} catch (VersionException e) {
return VersionMarker.UNKNOWN;
}
}
/**
* @param stamp
* @return
*/
private Map getProperties(Object stamp) {
// TODO Auto-generated method stub
return null;
}
/**
* @param stamp
* @return
*/
private String getStampId(Object stamp) {
// TODO Auto-generated method stub
return null;
}
/**
* @param stamp
* @return
*/
private String getVersionString(Object stamp) {
// TODO Auto-generated method stub
return null;
}
/**
* @param stamp
* @return
*/
private String getSpecificationId(Object stamp) {
// TODO Auto-generated method stub
return null;
}
/**
* Create a Version object from the given string.
*
* @param versionString
* @return @throws
* VersionFormatException
*/
public Version createVersion(String versionString)
throws VersionFormatException {
VersionSpecification spec = VersionSpecificationFactory
.createDefaultVersionSpecification();
return createVersion(spec, versionString);
}
/**
* @param spec
* @param versionString
* @return Version
* @throws VersionFormatException
*/
public Version createVersion(VersionSpecification spec, String versionString) throws VersionFormatException {
return spec.getVersionFormat().parseVersion(versionString);
}
// :TODO:
// Stamp a version for ...
// Generate code for ...
// Increment ...
}
--- NEW FILE: VersionError.java ---
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.depot.version;
/**
* @author ajack
*/
public class VersionError extends Error{
/**
*
*/
public VersionError() {
super();
}
/**
* @param message
*/
public VersionError(String message) {
super(message);
}
/**
* @param message
* @param cause
*/
public VersionError(String message, Throwable cause) {
super(message, cause);
}
/**
* @param cause
*/
public VersionError(Throwable cause) {
super(cause);
}
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click