1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/*************************************************
*
* = PACKAGE
* JACE.OS
*
* = FILENAME
* JACE.java
*
*@author Prashant Jain
*
*************************************************/
package JACE.OS;
/**
* <hr>
* <h2>SYNOPSIS</h2>
* <blockquote>Constants, utility "functions", etc.</blockquote>
*
* <h2>DESCRIPTION</h2>
*<blockquote>
* 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.
*</blockquote>
*
* <h2>NOTES</h2>
*<blockquote>
* This class is non-instantiable, and intended only to provide a constrained
* namespace.
*</blockquote>
*/
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_ = true;
// Default private constructor to avoid instantiation
private ACE ()
{
}
}
|