donaldp 01/12/16 04:10:29
Modified: proposal/myrmidon/src/java/org/apache/myrmidon/framework
Resources.properties
Added: proposal/myrmidon/src/java/org/apache/myrmidon/framework
Os.java
Log:
Start testign integration of the framework across.
Revision Changes Path
1.3 +2 -0
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Resources.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Resources.properties 2001/11/19 12:37:27 1.2
+++ Resources.properties 2001/12/16 12:10:29 1.3
@@ -14,3 +14,5 @@
type.no-factory.error=Unable to retrieve DataType factory from TypeManager.
type.no-create.error=Unable to create datatype.
type.no-id.error=Id must be specified.
+
+unknown-family=Don't know how to detect os family "{0}"
\ No newline at end of file
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Os.java
Index: Os.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.myrmidon.framework;
import java.util.Locale;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.myrmidon.api.TaskException;
/**
* Class to help determining the OS.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class Os
{
private static final Resources REZ =
ResourceManager.getPackageResources( Os.class );
private final static String m_osName =
System.getProperty( "os.name" ).toLowerCase( Locale.US );
private final static String m_osArch =
System.getProperty( "os.arch" ).toLowerCase( Locale.US );
private final static String m_osVersion =
System.getProperty( "os.version" ).toLowerCase( Locale.US );
private final static String m_pathSep =
System.getProperty( "path.separator" );
private String m_arch;
private String m_family;
private String m_name;
private String m_version;
public Os()
{
}
public Os( final String family )
{
setFamily( family );
}
/**
* Determines if the OS on which Ant is executing matches the given OS
* architecture.
*
* @param arch Description of Parameter
* @return The Arch value
*/
public static boolean isArch( final String arch )
{
return isOs( null, null, arch, null );
}
/**
* Determines if the OS on which Ant is executing matches the given OS
* family.
*
* @param family Description of Parameter
* @return The Family value
* @since 1.5
*/
public static boolean isFamily( final String family )
{
return isOs( family, null, null, null );
}
/**
* Determines if the OS on which Ant is executing matches the given OS
name.
*
* @param name Description of Parameter
* @return The Name value
* @since 1.7
*/
public static boolean isName( final String name )
{
return isOs( null, name, null, null );
}
/**
* Determines if the OS on which Ant is executing matches the given OS
* family, name, architecture and version
*
* @param family The OS family
* @param name The OS name
* @param arch The OS architecture
* @param version The OS version
* @return The Os value
*/
private static boolean isOs( final String family,
final String name,
final String arch,
final String version )
{
boolean retValue = false;
if( family != null || name != null || arch != null || version != null
)
{
boolean isFamily = true;
boolean isName = true;
boolean isArch = true;
boolean isVersion = true;
if( family != null )
{
if( family.equals( "windows" ) )
{
isFamily = m_osName.indexOf( "windows" ) > -1;
}
else if( family.equals( "os/2" ) )
{
isFamily = m_osName.indexOf( "os/2" ) > -1;
}
else if( family.equals( "netware" ) )
{
isFamily = m_osName.indexOf( "netware" ) > -1;
}
else if( family.equals( "dos" ) )
{
isFamily = m_pathSep.equals( ";" ) && !isFamily(
"netware" );
}
else if( family.equals( "mac" ) )
{
isFamily = m_osName.indexOf( "mac" ) > -1;
}
else if( family.equals( "unix" ) )
{
isFamily = m_pathSep.equals( ":" ) &&
( !isFamily( "mac" ) || m_osName.endsWith( "x" ) );
}
else
{
final String message = REZ.getString(
"unknown-os-family", family );
throw new IllegalArgumentException( message );
}
}
if( name != null )
{
isName = name.equals( m_osName );
}
if( arch != null )
{
isArch = arch.equals( m_osArch );
}
if( version != null )
{
isVersion = version.equals( m_osVersion );
}
retValue = isFamily && isName && isArch && isVersion;
}
return retValue;
}
/**
* Determines if the OS on which Ant is executing matches the given OS
* version.
*/
public static boolean isVersion( final String version )
{
return isOs( null, null, null, version );
}
/**
* Sets the desired OS architecture
*
* @param arch The OS architecture
*/
public void setArch( final String arch )
{
m_arch = arch.toLowerCase( Locale.US );
}
/**
* Sets the desired OS family type
*
* @param f The OS family type desired<br />
* Possible values:<br />
*
* <ul>
* <li> dos</li>
* <li> mac</li>
* <li> netware</li>
* <li> os/2</li>
* <li> unix</li>
* <li> windows</li>
* </ul>
*/
public void setFamily( String f )
{
m_family = f.toLowerCase( Locale.US );
}
/**
* Sets the desired OS name
*
* @param name The OS name
*/
public void setName( String name )
{
m_name = name.toLowerCase( Locale.US );
}
/**
* Sets the desired OS version
*
* @param version The OS version
*/
public void setVersion( String version )
{
m_version = version.toLowerCase( Locale.US );
}
/**
* Determines if the OS on which Ant is executing matches the type of that
* set in setFamily.
*
* @see Os#setFamily(String)
*/
public boolean eval()
throws TaskException
{
return isOs( m_family, m_name, m_arch, m_version );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>