public class DConnect2 extends Object implements Closeable
This class provides support for common DODS client-side operations such as dereferencing a OPeNDAP URL, communicating network activity status to the user and reading local OPeNDAP objects.
Unlike its C++ counterpart, this class does not store instances of the DAS,
DDS, etc. objects. Rather, the methods getDAS, etc. return
instances of those objects.
| Modifier and Type | Field and Description |
|---|---|
protected ucar.httpservices.HTTPSession |
_session |
| Constructor and Description |
|---|
DConnect2(InputStream stream) |
DConnect2(String urlString)
Creates an instance bound to url which accepts compressed documents.
|
DConnect2(String urlString,
boolean acceptCompress)
Creates an instance bound to url.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
captureDataDDS(InputStream is) |
static String |
captureStream(InputStream is) |
String |
CE()
Returns the constraint expression supplied with the URL given to the
constructor.
|
void |
close() |
DAS |
getDAS()
Returns the DAS object from the dataset referenced by this object's URL.
|
DataDDS |
getData(StatusUI statusUI)
Return the data object with no local constraint expression.
|
DataDDS |
getData(String CE) |
DataDDS |
getData(String CE,
StatusUI statusUI)
Returns the `Data object' from the dataset referenced by this object's
URL given the constraint expression CE.
|
DataDDS |
getData(String CE,
StatusUI statusUI,
BaseTypeFactory btf)
Returns the `Data object' from the dataset referenced by this object's
URL given the constraint expression CE.
|
DataDDS |
getDataDDX()
Returns the DataDDS object from the dataset referenced by this object's URL.
|
DataDDS |
getDataDDX(String CE)
Returns the DataDDS object from the dataset referenced by this object's URL.
|
DataDDS |
getDataDDX(String CE,
BaseTypeFactory btf)
Returns the DataDDS object from the dataset referenced by this object's URL.
|
DDS |
getDDS()
Returns the DDS object from the dataset referenced by this object's URL.
|
DDS |
getDDS(String CE)
Returns the DDS object from the dataset referenced by this object's URL.
|
DDS |
getDDX()
Returns the DDS object from the dataset referenced by this object's URL.
|
DDS |
getDDX(String CE)
Returns the DDS object from the dataset referenced by this object's URL.
|
String |
getLastExtendedHeader() |
String |
getLastModifiedHeader() |
String |
getLastModifiedInvalidHeader() |
ServerVersion |
getServerVersion()
Returns the
ServerVersion of the last connection. |
ucar.httpservices.HTTPSession |
getSession()
Return the session associated with this connection
|
boolean |
isLocal() |
static void |
main(String[] args) |
static void |
setAllowSessions(boolean b) |
void |
setServerVersion(int major,
int minor) |
String |
URL()
Returns the URL supplied to the constructor.
|
public DConnect2(String urlString) throws ucar.httpservices.HTTPException
urlString - connect to this URL.FileNotFoundException - thrown if urlString is not
a valid URL, or a filename which exists on the system.ucar.httpservices.HTTPExceptionpublic DConnect2(String urlString, boolean acceptCompress) throws ucar.httpservices.HTTPException
acceptDeflate is true
then HTTP Request headers will indicate to servers that this client can
accept compressed documents.urlString - Connect to this URL.acceptCompress - true if this client will accept compressed responsesFileNotFoundException - thrown if urlString is not
a valid URL, or a filename which exists on the system.ucar.httpservices.HTTPExceptionpublic DConnect2(InputStream stream) throws DAP2Exception
DAP2Exceptionpublic static void setAllowSessions(boolean b)
public void setServerVersion(int major,
int minor)
public boolean isLocal()
public final String CE()
String.
Note that the CE supplied to one of this object's constructors is
"sticky"; it will be used with every data request made with this object.
The CE passed to getData, however, is not sticky; it is used
only for that specific request. This method returns the sticky CE.
public final String URL()
public ucar.httpservices.HTTPSession getSession()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic static String captureStream(InputStream is) throws IOException
IOExceptionpublic static String captureDataDDS(InputStream is) throws IOException
IOExceptionpublic final ServerVersion getServerVersion()
ServerVersion of the last connection.ServerVersion of the last connection.public String getLastModifiedHeader()
public String getLastModifiedInvalidHeader()
public String getLastExtendedHeader()
public DAS getDAS() throws IOException, DAP2Exception
MalformedURLException - if the URL given to the
constructor has an errorIOException - if an error connecting to the remote serverDASException - on an error constructing the DASDAP2Exception - if an error returned by the remote serverpublic DDS getDDS() throws IOException, ParseException, DAP2Exception
MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DDS getDDS(String CE) throws IOException, ParseException, DAP2Exception
CE - The constraint expression to be applied to this request by the
server. This is combined with any CE given in the constructor.MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DDS getDDX() throws IOException, ParseException, DAP2Exception
MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DDS getDDX(String CE) throws IOException, ParseException, DDSException, DAP2Exception
CE - The constraint expression to be applied to this request by the
server. This is combined with any CE given in the constructor.MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DataDDS getDataDDX() throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DataDDS getDataDDX(String CE) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
CE - The constraint expression to use for this request.MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverpublic DataDDS getDataDDX(String CE, BaseTypeFactory btf) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
CE - The constraint expression to use for this request.btf - The BaseTypeFactory to build the member
variables in the DDS with.MalformedURLException - if the URL given to the constructor
has an errorIOException - if an error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if an error returned by the remote serverBaseTypeFactorypublic DataDDS getData(String CE, StatusUI statusUI, BaseTypeFactory btf) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Note that if CE is an empty String then the entire dataset will be returned, unless a "sticky" CE has been specified in the constructor.
CE - The constraint expression to be applied to this request by the
server. This is combined with any CE given in the constructor.statusUI - the StatusUI object to use for GUI updates
and user cancellation notification (may be null).btf - The BaseTypeFactory to build the member
variables in the DDS with.DataDDS object that results from applying the
given CE, combined with this object's sticky CE, on the referenced
dataset.MalformedURLException - if the URL given to the constructor
has an errorIOException - if any error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if any error returned by the remote serverpublic DataDDS getData(String CE) throws IOException, ParseException, DAP2Exception
IOExceptionParseExceptionDAP2Exceptionpublic DataDDS getData(String CE, StatusUI statusUI) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Note that if CE is an empty String then the entire dataset will be returned, unless a "sticky" CE has been specified in the constructor.
CE - The constraint expression to be applied to this request by the
server. This is combined with any CE given in the constructor.statusUI - the StatusUI object to use for GUI updates
and user cancellation notification (may be null).DataDDS object that results from applying the
given CE, combined with this object's sticky CE, on the referenced
dataset.MalformedURLException - if the URL given to the constructor
has an errorIOException - if any error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if any error returned by the remote serverpublic final DataDDS getData(StatusUI statusUI) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
getData("", statusUI).statusUI - the StatusUI object to use for GUI updates
and user cancellation notification (may be null).DataDDS object that results from applying
this object's sticky CE, if any, on the referenced dataset.MalformedURLException - if the URL given to the constructor
has an errorIOException - if any error connecting to the remote serverParseException - if the DDS parser returned an errorDDSException - on an error constructing the DDSDAP2Exception - if any error returned by the remote serverpublic static void main(String[] args)
args - command line arguments