/**
* BaseFile - convenient File object that tracks the Base Directory and can provide relative path values
- * for the file object based on that Base Directory value.
+ * for the file object based on that Base Directory value.
*
* @version $Id$
*/
public BaseFile( URI uri )
{
super( uri ); // only to satisfy java compiler.
- throw new IllegalStateException( "The " + BaseFile.class.getName()
- + " object does not support URI construction." );
+ throw new IllegalStateException(
+ "The " + BaseFile.class.getName() + " object does not support URI construction." );
}
public File getBaseDir()
import java.util.GregorianCalendar;
/**
- * DateUtil - some (not-so) common date utility methods.
+ * DateUtil - some (not-so) common date utility methods.
*
* @version $Id$
*/
{
return getDuration( new Date( 0 ), new Date( duration ) );
}
-
+
public static String getDuration( long ms1, long ms2 )
{
return getDuration( new Date( ms1 ), new Date( ms2 ) );
leftMins += 60;
--leftHours;
}
-
+
if ( leftHours < 0 )
{
leftHours += 24;
import java.net.MalformedURLException;
/**
- * PathUtil - simple utility methods for path manipulation.
+ * PathUtil - simple utility methods for path manipulation.
*
* @version $Id$
*/
/**
* Given a basedir and a child file, return the relative path to the child.
- *
+ *
* @param basedir the basedir.
- * @param file the file to get the relative path for.
+ * @param file the file to get the relative path for.
* @return the relative path to the child. (NOTE: this path will NOT start with a {@link File#separator} character)
*/
public static String getRelative( String basedir, File file )
/**
* Given a basedir and a child file, return the relative path to the child.
- *
+ *
* @param basedir the basedir.
- * @param child the child path (can be a full path)
+ * @param child the child path (can be a full path)
* @return the relative path to the child. (NOTE: this path will NOT start with a {@link File#separator} character)
*/
public static String getRelative( String basedir, String child )
}
// File is not within basedir.
- throw new IllegalStateException( "Unable to obtain relative path of file " + child
- + ", it is not within basedir " + basedir + "." );
+ throw new IllegalStateException(
+ "Unable to obtain relative path of file " + child + ", it is not within basedir " + basedir + "." );
}
}
*
* @version $Id$
*/
-public class Slf4JPlexusLogger implements org.codehaus.plexus.logging.Logger {
+public class Slf4JPlexusLogger
+ implements org.codehaus.plexus.logging.Logger
+{
private Logger log;
- public Slf4JPlexusLogger(Class<?> clazz) {
- log = LoggerFactory.getLogger(clazz);
+ public Slf4JPlexusLogger( Class<?> clazz )
+ {
+ log = LoggerFactory.getLogger( clazz );
}
- public Slf4JPlexusLogger(String name) {
- log = LoggerFactory.getLogger(name);
+ public Slf4JPlexusLogger( String name )
+ {
+ log = LoggerFactory.getLogger( name );
}
- public void debug(String message) {
- log.debug(message);
+ public void debug( String message )
+ {
+ log.debug( message );
}
- public void debug(String message, Throwable throwable) {
- log.debug(message, throwable);
+ public void debug( String message, Throwable throwable )
+ {
+ log.debug( message, throwable );
}
- public void error(String message) {
- log.error(message);
+ public void error( String message )
+ {
+ log.error( message );
}
- public void error(String message, Throwable throwable) {
- log.error(message, throwable);
+ public void error( String message, Throwable throwable )
+ {
+ log.error( message, throwable );
}
- public void fatalError(String message) {
- log.error(message);
+ public void fatalError( String message )
+ {
+ log.error( message );
}
- public void fatalError(String message, Throwable throwable) {
- log.error(message, throwable);
+ public void fatalError( String message, Throwable throwable )
+ {
+ log.error( message, throwable );
}
- public org.codehaus.plexus.logging.Logger getChildLogger(String name) {
- return new Slf4JPlexusLogger(log.getName() + "." + name);
+ public org.codehaus.plexus.logging.Logger getChildLogger( String name )
+ {
+ return new Slf4JPlexusLogger( log.getName() + "." + name );
}
- public String getName() {
+ public String getName()
+ {
return log.getName();
}
- public int getThreshold() {
- if (log.isTraceEnabled()) {
+ public int getThreshold()
+ {
+ if ( log.isTraceEnabled() )
+ {
return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
- } else if (log.isDebugEnabled()) {
+ }
+ else if ( log.isDebugEnabled() )
+ {
return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
- } else if (log.isInfoEnabled()) {
+ }
+ else if ( log.isInfoEnabled() )
+ {
return org.codehaus.plexus.logging.Logger.LEVEL_INFO;
- } else if (log.isWarnEnabled()) {
+ }
+ else if ( log.isWarnEnabled() )
+ {
return org.codehaus.plexus.logging.Logger.LEVEL_WARN;
- } else if (log.isErrorEnabled()) {
+ }
+ else if ( log.isErrorEnabled() )
+ {
return org.codehaus.plexus.logging.Logger.LEVEL_ERROR;
}
return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED;
}
- public void info(String message) {
- log.info(message);
+ public void info( String message )
+ {
+ log.info( message );
}
- public void info(String message, Throwable throwable) {
- log.info(message, throwable);
+ public void info( String message, Throwable throwable )
+ {
+ log.info( message, throwable );
}
- public boolean isDebugEnabled() {
+ public boolean isDebugEnabled()
+ {
return log.isDebugEnabled();
}
- public boolean isErrorEnabled() {
+ public boolean isErrorEnabled()
+ {
return log.isErrorEnabled();
}
- public boolean isFatalErrorEnabled() {
+ public boolean isFatalErrorEnabled()
+ {
return log.isErrorEnabled();
}
- public boolean isInfoEnabled() {
+ public boolean isInfoEnabled()
+ {
return log.isInfoEnabled();
}
- public boolean isWarnEnabled() {
+ public boolean isWarnEnabled()
+ {
return log.isWarnEnabled();
}
- public void setThreshold(int threshold) {
+ public void setThreshold( int threshold )
+ {
/* do nothing */
}
- public void warn(String message) {
- log.warn(message);
+ public void warn( String message )
+ {
+ log.warn( message );
}
- public void warn(String message, Throwable throwable) {
- log.warn(message, throwable);
+ public void warn( String message, Throwable throwable )
+ {
+ log.warn( message, throwable );
}
}
import java.util.regex.Pattern;
/**
- * Version utility methods.
+ * Version utility methods.
*
* @version $Id$
*/
* These are the version patterns found in the filenames of the various artifact's versions IDs.
* These patterns are all tackling lowercase version IDs.
*/
- private static final String versionPatterns[] = new String[] {
- "([0-9][_.0-9a-z]*)",
- "(snapshot)",
- "(g?[_.0-9ab]*(pre|rc|g|m)[_.0-9]*)",
- "(dev[_.0-9]*)",
- "(alpha[_.0-9]*)",
- "(beta[_.0-9]*)",
- "(rc[_.0-9]*)",
+ private static final String versionPatterns[] =
+ new String[]{ "([0-9][_.0-9a-z]*)", "(snapshot)", "(g?[_.0-9ab]*(pre|rc|g|m)[_.0-9]*)", "(dev[_.0-9]*)",
+ "(alpha[_.0-9]*)", "(beta[_.0-9]*)", "(rc[_.0-9]*)",
// "(test[_.0-9]*)", -- omitted for MRM-681, can be reinstated as part of MRM-712
- "(debug[_.0-9]*)",
- "(unofficial[_.0-9]*)",
- "(current)",
- "(latest)",
- "(fcs)",
- "(release[_.0-9]*)",
- "(nightly)",
- "(final)",
- "(incubating)",
- "(incubator)",
- "([ab][_.0-9]+)" };
+ "(debug[_.0-9]*)", "(unofficial[_.0-9]*)", "(current)", "(latest)", "(fcs)", "(release[_.0-9]*)",
+ "(nightly)", "(final)", "(incubating)", "(incubator)", "([ab][_.0-9]+)" };
public static final String SNAPSHOT = "SNAPSHOT";
public static final Pattern GENERIC_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-" + SNAPSHOT );
- private static final Pattern VERSION_MEGA_PATTERN = Pattern.compile( StringUtils.join( versionPatterns, '|' ), Pattern.CASE_INSENSITIVE );
+ private static final Pattern VERSION_MEGA_PATTERN =
+ Pattern.compile( StringUtils.join( versionPatterns, '|' ), Pattern.CASE_INSENSITIVE );
/**
* <p>
* Tests if the unknown string contains elements that identify it as a version string (or not).
* </p>
- *
+ * <p/>
* <p>
* The algorithm tests each part of the string that is delimited by a '-' (dash) character.
* If 75% or more of the sections are identified as 'version' strings, the result is
* determined to be of a high probability to be version identifier string.
* </p>
- *
+ *
* @param unknown the unknown string to test.
* @return true if the unknown string is likely a version string.
*/
* <p>
* Tests if the identifier is a known simple version keyword.
* </p>
- *
+ * <p/>
* <p>
* This method is different from {@link #isVersion(String)} in that it tests the whole input string in
* one go as a simple identifier. (eg "alpha", "1.0", "beta", "debug", "latest", "rc#", etc...)
* </p>
- *
+ *
* @param identifier the identifier to test.
* @return true if the unknown string is likely a version string.
*/
}
else
{
- return isGenericSnapshot(version);
+ return isGenericSnapshot( version );
}
}
return version;
}
}
-
+
/**
* <p>
* Get the release version of the snapshot version.
* </p>
- *
+ * <p/>
* <p>
* If snapshot version is 1.0-SNAPSHOT, then release version would be 1.0
* And if snapshot version is 1.0-20070113.163208-1.jar, then release version would still be 1.0
* </p>
- *
+ *
* @param snapshotVersion
* @return
*/
public static String getReleaseVersion( String snapshotVersion )
{
Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( snapshotVersion );
-
- if( isGenericSnapshot( snapshotVersion ) )
+
+ if ( isGenericSnapshot( snapshotVersion ) )
{
m = GENERIC_SNAPSHOT_PATTERN.matcher( snapshotVersion );
}
-
+
if ( m.matches() )
- {
+ {
return m.group( 1 );
}
else
- {
+ {
return snapshotVersion;
}
}
public static boolean isUniqueSnapshot( String version )
- {
+ {
Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version );
- if( m.matches() )
+ if ( m.matches() )
{
return true;
}
public static boolean isGenericSnapshot( String version )
{
- return version.endsWith( SNAPSHOT );
+ return version.endsWith( SNAPSHOT );
}
}