mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
fix problems with serialization: use types that are serializable, and
init transients correctly.
This commit is contained in:
parent
43fead368c
commit
052725aabc
1 changed files with 26 additions and 14 deletions
|
@ -57,45 +57,49 @@ public class ConnStatusHandler {
|
||||||
private static class SuccessRecord implements java.io.Serializable {
|
private static class SuccessRecord implements java.io.Serializable {
|
||||||
// man strftime for these
|
// man strftime for these
|
||||||
// private static final String TIME_FMT = "%X %x";
|
// private static final String TIME_FMT = "%X %x";
|
||||||
private static final Time s_zero = new Time();
|
public long lastSuccess;
|
||||||
public Time lastSuccess;
|
public long lastFailure;
|
||||||
public Time lastFailure;
|
|
||||||
public boolean successNewer;
|
public boolean successNewer;
|
||||||
|
transient private Time m_time;
|
||||||
|
|
||||||
public SuccessRecord()
|
public SuccessRecord()
|
||||||
{
|
{
|
||||||
lastSuccess = new Time();
|
m_time = new Time();
|
||||||
lastFailure = new Time();
|
lastSuccess = 0;
|
||||||
|
lastFailure = 0;
|
||||||
successNewer = false;
|
successNewer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean haveFailure()
|
public boolean haveFailure()
|
||||||
{
|
{
|
||||||
return lastFailure.after( s_zero );
|
return lastFailure > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean haveSuccess()
|
public boolean haveSuccess()
|
||||||
{
|
{
|
||||||
return lastSuccess.after( s_zero );
|
return lastSuccess > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String newerStr( Context context )
|
public String newerStr( Context context )
|
||||||
{
|
{
|
||||||
Time which = successNewer? lastSuccess : lastFailure;
|
m_time.set( successNewer? lastSuccess : lastFailure );
|
||||||
return format( context, which );
|
return format( context, m_time );
|
||||||
// return which.format( TIME_FMT );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String olderStr( Context context )
|
public String olderStr( Context context )
|
||||||
{
|
{
|
||||||
Time which = successNewer? lastFailure : lastSuccess;
|
m_time.set( successNewer? lastFailure : lastSuccess );
|
||||||
return format( context, which );
|
return format( context, m_time );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update( boolean success )
|
public void update( boolean success )
|
||||||
{
|
{
|
||||||
Time last = success? lastSuccess : lastFailure;
|
long now = System.currentTimeMillis();
|
||||||
last.setToNow();
|
if ( success ) {
|
||||||
|
lastSuccess = now;
|
||||||
|
} else {
|
||||||
|
lastFailure = now;
|
||||||
|
}
|
||||||
successNewer = success;
|
successNewer = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +113,14 @@ public class ConnStatusHandler {
|
||||||
0 );
|
0 );
|
||||||
return seq.toString();
|
return seq.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called during deserialization
|
||||||
|
private void readObject( ObjectInputStream in )
|
||||||
|
throws java.io.IOException, java.lang.ClassNotFoundException
|
||||||
|
{
|
||||||
|
in.defaultReadObject();
|
||||||
|
m_time = new Time();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<CommsConnType,SuccessRecord[]> s_records =
|
private static HashMap<CommsConnType,SuccessRecord[]> s_records =
|
||||||
|
|
Loading…
Add table
Reference in a new issue