diff options
author | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-24 23:10:57 +0000 |
---|---|---|
committer | eea1 <eea1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-24 23:10:57 +0000 |
commit | 4a1954f1f61b5127e9c2a0f5107e8b3a69216b3a (patch) | |
tree | a2321b9bd2e8458b6bf2de931e90133d55027e1e /java/JACE | |
parent | 42df54149b13d41af52738a391ee4dfa02e2e759 (diff) | |
download | ATCD-4a1954f1f61b5127e9c2a0f5107e8b3a69216b3a.tar.gz |
Updated source files for OS.
Diffstat (limited to 'java/JACE')
-rw-r--r-- | java/JACE/OS/ACE.java | 156 | ||||
-rw-r--r-- | java/JACE/OS/OS.java | 65 | ||||
-rw-r--r-- | java/JACE/OS/package.html | 6 |
3 files changed, 227 insertions, 0 deletions
diff --git a/java/JACE/OS/ACE.java b/java/JACE/OS/ACE.java new file mode 100644 index 00000000000..3979fa6c2d2 --- /dev/null +++ b/java/JACE/OS/ACE.java @@ -0,0 +1,156 @@ +/************************************************* + * + * = PACKAGE + * JACE.OS + * + * = FILENAME + * JACE.java + * + *@author Prashant Jain + * + *************************************************/ +package JACE.OS; + +/** + * Constants, utility "functions", etc. + * <P> + * Defines default constants for ACE. Many of these are used for the + * ACE tests and applications. You may want to change some of these to + * correspond to your environment. Also, routines for error handling, + * debugging and bit manipulation are included. + * <P> + * This class is non-instantiable, and intended only to provide a constrained + * namespace. + */ +public abstract class ACE +{ + /** + * Default port on which a server listens for connections. + */ + public static final int DEFAULT_SERVER_PORT = 10002; + + /** + * Default name to use for a thread group. + */ + public static final String DEFAULT_THREAD_GROUP_NAME = "ace_thread_group"; + + /** + * Disable debugging. Once debugging is disabled, all ACE.DEBUG + * statements would be ignored. + */ + public static final void disableDebugging () + { + ACE.debug_ = false; + } + + /** + * Enable debugging. Once debugging is enabled, all ACE.DEBUG + * statements get printed. + */ + public static final void enableDebugging () + { + ACE.debug_ = true; + } + + /** + * Print the string representation of Java Exception. + *@param e Java exception + */ + public static final void ERROR (Exception e) + { + System.err.println (e); + } + + /** + * Print the string being passed in. + *@param s a Java String + */ + public static final void ERROR (String s) + { + System.err.println (s); + } + + /** + * Print the string being passed in. + *@param s A Java String + *@return Error value passed in + */ + public static final int ERROR_RETURN (String s, int errorVal) + { + System.err.println (s); + return errorVal; + } + + /** + * Print the string being passed in. Note the behavior will vary + * depending upon whether debugging is enabled or disabled. + *@param s a Java String + */ + public static final void DEBUG (String s) + { + if (ACE.debug_) + System.out.println (s); + } + + /** + * Flush out any data that may be buffered. + */ + public static final void FLUSH () + { + System.out.flush (); + } + + /** + * Set the bits of WORD using BITS as the mask. + *@param WORD the bits to be set. + *@param BITS the mask to use. + *@return The value obtained after setting the bits. + */ + public static final long SET_BITS (long WORD, long BITS) + { + return WORD | BITS; + } + + /** + * Clear the bits of WORD using BITS as the mask. + *@param WORD the bits to clear. + *@param BITS the mask to use. + *@return The value obtained after clearing the bits. + */ + public static final long CLR_BITS (long WORD, long BITS) + { + return WORD & ~BITS; + } + + /** + * Check if bits are enabled in WORD. + *@param WORD the bits to check. + *@param BIT the bit to check to see if it is enabled or not. + *@return true if bit is enabled, false otherwise. + */ + public static final boolean BIT_ENABLED (long WORD, long BIT) + { + return (WORD & BIT) != 0; + } + + /** + * Check if bits are disabled in WORD. + *@param WORD the bits to check. + *@param BIT the bit to check to see if it is disabled or not. + *@return true if bit is disabled, false otherwise. + */ + public static final boolean BIT_DISABLED (long WORD, long BIT) + { + return (WORD & BIT) == 0; + } + + // Debug flag (turn debugging on/off) + private static boolean debug_ = false; + + // Default private constructor to avoid instantiation + private ACE () + { + } +} + + diff --git a/java/JACE/OS/OS.java b/java/JACE/OS/OS.java new file mode 100644 index 00000000000..3f15a028cc2 --- /dev/null +++ b/java/JACE/OS/OS.java @@ -0,0 +1,65 @@ +/************************************************* + * + * = PACKAGE + * JACE.OS + * + * = FILENAME + * OS.java + * + *@author Prashant Jain + * + *************************************************/ +package JACE.OS; + +import java.util.StringTokenizer; + +/** + * Methods to extend the capabilities of the Java runtime system. + * <P> + * This non-instantiable class contains little <q>utility functions</q> + * that should have been in Java to begin with :-) + */ +public class OS +{ + /** + * Create an array of Strings from a single String using <delim> as + * the delimiter. + *@param args the String to break up to make an array of Strings + *@param delim the delimeter to use to break the String up + *@return an array containing the original String broken up + */ + public static String [] createStringArray (String args, String delim) + { + // First determine the number of arguments + int count = 0; + StringTokenizer tokens = new StringTokenizer (args, delim); + while (tokens.hasMoreTokens ()) + { + tokens.nextToken (); + count++; + } + if (count == 0) + return null; + + // Create argument array + String [] argArray = new String [count]; + int index = 0; + tokens = new StringTokenizer (args, " "); + while (tokens.hasMoreTokens ()) + { + argArray [index] = tokens.nextToken (); + index++; + } + + // Assert index == count + if (index != count) + return null; + else + return argArray; + } + + // Default private constructor to avoid instantiation + private OS () + { + } +} diff --git a/java/JACE/OS/package.html b/java/JACE/OS/package.html new file mode 100644 index 00000000000..01245ef0b51 --- /dev/null +++ b/java/JACE/OS/package.html @@ -0,0 +1,6 @@ +<!-- $Id$ --> +<HTML> +<BODY> +Extensions to the Java runtime system. +</BODY> +</HTML> |