// FileFlatField.java
//
/*
VisAD system for interactive analysis and visualization of numerical
data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
package visad.data;
import java.io.IOException;
import java.rmi.RemoteException;
import visad.FlatField;
import visad.*;
public class FileFlatField extends FlatField {
// note FileFlatField extends FlatField but may not inherit
// any of its methods - it must re-implement all of them
// through the adapted FlatField
// number of FlatFields in cache
private static final int MAX_FILE_FLAT_FIELDS = 10;
// array of cached FlatFields
private static transient FlatField[] adaptedFlatFields =
new FlatField[MAX_FILE_FLAT_FIELDS];
// true if cache entry differs from file contents
private static transient boolean adaptedFlatFieldDirty[] =
new boolean[MAX_FILE_FLAT_FIELDS];
// the FileFlatField that owns this cache entry
private static transient FileFlatField[] adaptedFlatFieldOwner =
new FileFlatField[MAX_FILE_FLAT_FIELDS];
// adaptedFlatFieldSizes and adaptedFlatFieldTimes
// may be useful for cache allocation algorithms
// approximate sizes of FlatFields in cache
private static transient long[] adaptedFlatFieldSizes =
new long[MAX_FILE_FLAT_FIELDS];
// times of most recent accesses to FlatFields in cache
private static transient long[] adaptedFlatFieldTimes =
new long[MAX_FILE_FLAT_FIELDS];
// index of cache entry owned by this FileFlatField;
// but only if
// this == adaptedFlatFieldOwner[adaptedFlatFieldIndex]
private transient int adaptedFlatFieldIndex;
// this is the FileAccessor for reading and writing values from
// and to the adapted file
transient FileAccessor fileAccessor;
// this implements a strategy for cache replacement;
// this separates the cahce strategy algorithm from the logic
// of FileFlatField
private transient CacheStrategy cacheStrategy;
static
{
// initialize cache of FlatFields
if (adaptedFlatFieldOwner != null && adaptedFlatFields != null &&
adaptedFlatFieldSizes != null && adaptedFlatFieldTimes != null &&
adaptedFlatFieldDirty != null) {
for (int i=0; i
* clone() contract in that the returned object will compare unequal to
* this instance. As such, this method should probably not be invoked.
*
* @return A clone of this instance.
*/
public Object clone()
{
/*
* This implementation should probably just throw a
* CloneNotSupportedException but can't because FlatField.clone() doesn't.
*/
FlatField fld = getAdaptedFlatField();
if (fld == null) {
return null;
}
return fld.clone();
}
public String toString()
{
FlatField fld = getAdaptedFlatField();
if (fld == null) {
return "Cannot get cached FlatField";
}
return fld.toString();
}
public String longString(String pre)
{
FlatField fld = getAdaptedFlatField();
if (fld == null) {
return pre + "Cannot get cached FlatField";
}
try {
return fld.longString(pre);
} catch (VisADException e) {
return pre + e.getMessage();
}
}
private void readObject(java.io.ObjectInputStream oos)
throws ClassNotFoundException, IOException
{
throw new java.io.NotSerializableException("FileFlatField is not serializable");
}
private void writeObject(java.io.ObjectOutputStream oos)
throws IOException
{
throw new java.io.NotSerializableException("FileFlatField is not serializable");
}
}
Ads help maintain this website.