dods.servers.agg
Class ProxySDArray

java.lang.Object
  extended by dods.dap.BaseType
      extended by dods.dap.DVector
          extended by dods.dap.DArray
              extended by dods.dap.Server.SDArray
                  extended by dods.servers.agg.ProxySDArray
All Implemented Interfaces:
ClientIO, RelOps, ServerArrayMethods, ServerMethods, HasProxyObject, Cloneable

public class ProxySDArray
extends SDArray
implements HasProxyObject

Proxy for an array in another (DODS) dataset. If its 1D, read the entire array the first time and cache it.

Version:
$Revision: 1.4 $
Author:
jcaron

Method Summary
static BaseType assignBaseType(BaseType bt)
          Override so we can cache the whole array, and subset it locally.
 Object getProxy()
          get the underlying proxy
 boolean read(String datasetName, Object specialO)
          Read the value from original dataset (parameters are ignored).
 void setProxy(Object v)
          get/set the underlying proxy
 
Methods inherited from class dods.dap.Server.SDArray
appendDim, appendDim, equal, getStart, getStop, getStride, greater_eql, greater, isProject, isRead, isSynthesized, less_eql, less, not_equal, printDecl, printVal, regexp, serialize, setProject, setProject, setProjection, setRead, setSynthesized
 
Methods inherited from class dods.dap.DArray
checkSemantics, clone, getDimension, getDimensions, getFirstDimension, getTypeName, numDimensions
 
Methods inherited from class dods.dap.DVector
addVariable, deserialize, externalize, getLength, getPrimitiveVector, setLength
 
Methods inherited from class dods.dap.BaseType
checkSemantics, elementCount, elementCount, getLongName, getName, getParent, newPrimitiveVector, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printVal, printVal, printVal, setName, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setProxy

public void setProxy(Object v)
get/set the underlying proxy

Specified by:
setProxy in interface HasProxyObject

getProxy

public Object getProxy()
Description copied from interface: HasProxyObject
get the underlying proxy

Specified by:
getProxy in interface HasProxyObject

read

public boolean read(String datasetName,
                    Object specialO)
             throws IOException,
                    EOFException
Read the value from original dataset (parameters are ignored).

Specified by:
read in interface ServerMethods
Specified by:
read in class SDArray
Parameters:
datasetName - String identifying the file or other data store from which to read a vaue for this variable.
specialO - This Object is a goody that is used by Server implementations to deliver important, and as yet unknown, stuff to the read method. If you don't need it, make it a null.
Returns:
true if more data remains to be read, otherwise false. This is an abtsract method that must be implemented as part of the installation/localization of a DODS server.
Throws:
IOException
EOFException

assignBaseType

public static BaseType assignBaseType(BaseType bt)
Override so we can cache the whole array, and subset it locally.

Parameters:
dataset -
sink -
ce -
specialO -
Throws:
NoSuchVariableException
SDODSException
IOException - public void serialize(String dataset, DataOutputStream sink, CEEvaluator ce, Object specialO) throws NoSuchVariableException,SDODSException, IOException { if (!ce.evalClauses(specialO)) return; if(!isRead()) read(dataset, specialO); PrimitiveVector vals = getPrimitiveVector(); if (cachedData) { // full data is in the PrimitiveVector, just have to subset it int stride0 = (getStride(0) > 1) ? getStride(0) : 1; int length = 1 + (getStop(0) - getStart(0)) / stride0; sink.writeInt(length); if(vals instanceof BaseTypePrimitiveVector){ BaseTypePrimitiveVector bvals = (BaseTypePrimitiveVector) vals; for(int i=getStart(0); i<=getStop(0); i+=stride0) { ServerMethods sm = (ServerMethods) bvals.getValue(i); sm.serialize(dataset,sink,ce, specialO); } } else { sink.writeInt(length); vals.externalize( sink, getStart(0), getStop(0), stride0); } } else { // just the wanted data is in the PrimitiveVector int length = vals.getLength(); sink.writeInt(length); if(vals instanceof BaseTypePrimitiveVector){ BaseTypePrimitiveVector bvals = (BaseTypePrimitiveVector) vals; for(int i=0; i