1
/*------------------------------------------------------------------------
2
| Zystem is a native interface for message reporting in java.
3
| Copyright 2003-2004 by Trent Jarvi taj@www.linux.org.uk.
5
| This library is free software; you can redistribute it and/or
6
| modify it under the terms of the GNU Library General Public
7
| License as published by the Free Software Foundation; either
8
| version 2 of the License, or (at your option) any later version.
10
| This library is distributed in the hope that it will be useful,
11
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
| Library General Public License for more details.
15
| You should have received a copy of the GNU Library General Public
16
| License along with this library; if not, write to the Free
17
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
--------------------------------------------------------------------------*/
21
import java.io.RandomAccessFile;
25
public static final int SILENT_MODE = 0;
26
public static final int FILE_MODE = 1;
27
public static final int NET_MODE = 2;
28
public static final int MEX_MODE = 3;
29
public static final int PRINT_MODE = 4;
30
public static final int J2EE_MSG_MODE = 5;
37
The rxtxZystem library uses Python code and is not
38
included with RXTX. A seperate library will be released
39
to avoid potential license conflicts.
41
Trent Jarvi taj@www.linux.org.uk
44
//System.loadLibrary( "rxtxZystem" );
48
private static String target;
50
public Zystem( int m ) throws UnSupportedLoggerException
53
startLogger( "asdf" );
57
public void startLogger( ) throws UnSupportedLoggerException
59
if ( mode == SILENT_MODE || mode == PRINT_MODE )
64
throw new UnSupportedLoggerException( "Target Not Allowed" );
67
/* accept the host or file to log to. */
69
public void startLogger( String t ) throws UnSupportedLoggerException
73
if ( mode == NET_MODE )
79
throw new UnSupportedLoggerException(
80
"Port initializion failed" );
86
public void finalize()
89
if ( mode == NET_MODE )
99
public void filewrite( String s )
103
new RandomAccessFile( target, "rw" );;
104
w.seek( w.length() );
107
} catch ( Exception e ) {
108
System.out.println("Debug output file write failed");
112
public boolean report( String s)
114
if ( mode == NET_MODE )
116
// return( nativeNetReportln( s ) );
118
else if ( mode == PRINT_MODE )
120
System.out.println( s );
123
else if ( mode == MEX_MODE )
125
// return( nativeMexReport( s ) );
127
else if ( mode == SILENT_MODE )
131
else if ( mode == FILE_MODE )
135
else if ( mode == J2EE_MSG_MODE )
142
public boolean reportln( )
145
if ( mode == NET_MODE )
147
// b= nativeNetReportln( "\n" );
150
else if ( mode == PRINT_MODE )
152
System.out.println( );
155
else if ( mode == MEX_MODE )
157
// b = nativeMexReportln( "\n" );
160
else if ( mode == SILENT_MODE )
164
else if ( mode == FILE_MODE )
168
else if ( mode == J2EE_MSG_MODE )
175
public boolean reportln( String s)
178
if ( mode == NET_MODE )
180
// b= nativeNetReportln( s + "\n" );
183
else if ( mode == PRINT_MODE )
185
System.out.println( s );
188
else if ( mode == MEX_MODE )
190
// b = nativeMexReportln( s + "\n" );
193
else if ( mode == SILENT_MODE )
197
else if ( mode == FILE_MODE )
199
filewrite( s + "\n" );
201
else if ( mode == J2EE_MSG_MODE )
209
private native boolean nativeInit( );
210
private native void nativeFinalize();
213
/* open and close the socket */
215
private native boolean nativeNetInit( );
216
private native void nativeNetFinalize();
219
/* dumping to a remote machine */
221
public native boolean nativeNetReport( String s );
222
public native boolean nativeNetReportln( String s );
225
/* specific to Matlab */
227
public native boolean nativeMexReport( String s );
228
public native boolean nativeMexReportln( String s );