-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inclusion of croftsoft source code
- Loading branch information
1 parent
caec0fa
commit ae754de
Showing
97 changed files
with
9,582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.croftsoft.core.applet; | ||
|
||
import java.applet.*; | ||
import java.io.*; | ||
|
||
import com.croftsoft.core.io.SerializableLib; | ||
import com.croftsoft.core.lang.NullArgumentException; | ||
|
||
/********************************************************************* | ||
* Static library methods for manipulating Applets. | ||
* | ||
* @version | ||
* $Id: AppletLib.java,v 1.3 2008/09/28 21:50:42 croft Exp $ | ||
* @since | ||
* 2002-12-22 | ||
* @author | ||
* <a href="http://www.CroftSoft.com/">David Wallace Croft</a> | ||
*********************************************************************/ | ||
|
||
public final class AppletLib | ||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
|
||
/********************************************************************* | ||
* Loads GZIP compressed data. | ||
*********************************************************************/ | ||
public static Serializable loadSerializableUsingAppletPersistence ( | ||
Applet applet, | ||
String key ) | ||
throws ClassNotFoundException, IOException, | ||
UnsupportedOperationException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
NullArgumentException.check ( applet, "null applet" ); | ||
|
||
NullArgumentException.check ( key, "null key" ); | ||
|
||
AppletContext appletContext = null; | ||
|
||
try | ||
{ | ||
appletContext = applet.getAppletContext ( ); | ||
} | ||
catch ( NullPointerException ex ) | ||
{ | ||
// ignore | ||
} | ||
|
||
if ( appletContext == null ) | ||
{ | ||
throw new UnsupportedOperationException ( "null AppletContext" ); | ||
} | ||
|
||
InputStream inputStream = appletContext.getStream ( key ); | ||
|
||
if ( inputStream == null ) | ||
{ | ||
return null; | ||
} | ||
|
||
return SerializableLib.load ( inputStream ); | ||
} | ||
|
||
/********************************************************************* | ||
* Saves data using GZIP compression. | ||
*********************************************************************/ | ||
public static void saveSerializableUsingAppletPersistence ( | ||
Applet applet, | ||
String key, | ||
Serializable serializable ) | ||
throws IOException, UnsupportedOperationException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
NullArgumentException.check ( applet, "null applet" ); | ||
|
||
NullArgumentException.check ( key, "null key" ); | ||
|
||
NullArgumentException.check ( serializable, "null serializable" ); | ||
|
||
AppletContext appletContext = null; | ||
|
||
try | ||
{ | ||
appletContext = applet.getAppletContext ( ); | ||
} | ||
catch ( NullPointerException ex ) | ||
{ | ||
// ignore | ||
} | ||
|
||
if ( appletContext == null ) | ||
{ | ||
throw new UnsupportedOperationException ( "null AppletContext" ); | ||
} | ||
|
||
InputStream inputStream = new ByteArrayInputStream ( | ||
SerializableLib.compress ( serializable ) ); | ||
|
||
appletContext.setStream ( key, inputStream ); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
private AppletLib ( ) { /* empty */ } | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
Applet manipulation code. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package com.croftsoft.core.io; | ||
|
||
import java.io.*; | ||
|
||
import com.croftsoft.core.lang.NullArgumentException; | ||
|
||
/********************************************************************* | ||
* A FilterReader that echoes characters read to a Writer. | ||
* | ||
* <p /> | ||
* | ||
* @version | ||
* 2002-09-19 | ||
* @since | ||
* 2002-09-19 | ||
* @author | ||
* <a href="http://www.CroftSoft.com/">David Wallace Croft</a> | ||
*********************************************************************/ | ||
|
||
public final class EchoReader | ||
extends FilterReader | ||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
|
||
private final Writer echoWriter; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
/********************************************************************* | ||
* Main constructor. | ||
*********************************************************************/ | ||
public EchoReader ( | ||
Reader in, | ||
Writer echoWriter ) | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
super ( in ); | ||
|
||
NullArgumentException.check ( this.echoWriter = echoWriter ); | ||
} | ||
|
||
/********************************************************************* | ||
* Echoes to the standard output. | ||
* <code><pre>this ( in, new PrintWriter ( System.out ) );</pre></code> | ||
*********************************************************************/ | ||
public EchoReader ( Reader in ) | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
this ( in, new PrintWriter ( System.out ) ); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
public int read ( ) | ||
throws IOException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
int ch = super.read ( ); | ||
|
||
if ( ch > -1 ) | ||
{ | ||
echoWriter.write ( ch ); | ||
} | ||
|
||
return ch; | ||
} | ||
|
||
public int read ( | ||
char [ ] cbuf, | ||
int off, | ||
int len ) | ||
throws IOException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
int count = super.read ( cbuf, off, len ); | ||
|
||
if ( count > -1 ) | ||
{ | ||
echoWriter.write ( cbuf, off, count ); | ||
} | ||
|
||
return count; | ||
} | ||
|
||
public int read ( char [ ] cbuf ) | ||
throws IOException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
int count = super.read ( cbuf ); | ||
|
||
if ( count > -1 ) | ||
{ | ||
echoWriter.write ( cbuf, 0, count ); | ||
} | ||
|
||
return count; | ||
} | ||
|
||
/********************************************************************* | ||
* Flushes the echoWriter in addition to closing the input. | ||
*********************************************************************/ | ||
public void close ( ) | ||
throws IOException | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
super.close ( ); | ||
|
||
echoWriter.flush ( ); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.croftsoft.core.io; | ||
|
||
import java.io.*; | ||
|
||
/********************************************************************* | ||
* A generic interface for Object encoders. | ||
* | ||
* @see | ||
* Parser | ||
* @version | ||
* 2003-05-13 | ||
* @since | ||
* 2000-03-23 | ||
* @author | ||
* <a href="http://www.CroftSoft.com/">David Wallace Croft</a> | ||
*********************************************************************/ | ||
|
||
public interface Encoder | ||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
|
||
public byte [ ] encode ( Object object ) | ||
throws IOException; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////// | ||
} |
Oops, something went wrong.