Package opendap.dap
Class DConnect2
- java.lang.Object
-
- opendap.dap.DConnect2
-
- All Implemented Interfaces:
Closeable,AutoCloseable
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcaptureDataDDS(InputStream is)static StringcaptureStream(InputStream is)StringCE()Returns the constraint expression supplied with the URL given to the constructor.voidclose()DASgetDAS()Returns the DAS object from the dataset referenced by this object's URL.DataDDSgetData(String CE)DataDDSgetData(String CE, StatusUI statusUI)Returns the `Data object' from the dataset referenced by this object's URL given the constraint expression CE.DataDDSgetData(String CE, StatusUI statusUI, BaseTypeFactory btf)Returns the `Data object' from the dataset referenced by this object's URL given the constraint expression CE.DataDDSgetData(StatusUI statusUI)Return the data object with no local constraint expression.DataDDSgetDataDDX()Returns the DataDDS object from the dataset referenced by this object's URL.DataDDSgetDataDDX(String CE)Returns the DataDDS object from the dataset referenced by this object's URL.DataDDSgetDataDDX(String CE, BaseTypeFactory btf)Returns the DataDDS object from the dataset referenced by this object's URL.DDSgetDDS()Returns the DDS object from the dataset referenced by this object's URL.DDSgetDDS(String CE)Returns the DDS object from the dataset referenced by this object's URL.DDSgetDDX()Returns the DDS object from the dataset referenced by this object's URL.DDSgetDDX(String CE)Returns the DDS object from the dataset referenced by this object's URL.StringgetLastExtendedHeader()StringgetLastModifiedHeader()StringgetLastModifiedInvalidHeader()ServerVersiongetServerVersion()Returns theServerVersionof the last connection.booleanisLocal()static voidsetAllowSessions(boolean b)voidsetServerVersion(int major, int minor)StringURL()Returns the URL supplied to the constructor.
-
-
-
Constructor Detail
-
DConnect2
public DConnect2(String urlString) throws IOException
Creates an instance bound to url which accepts compressed documents.- Parameters:
urlString- connect to this URL.- Throws:
FileNotFoundException- thrown ifurlStringis not a valid URL, or a filename which exists on the system.IOException
-
DConnect2
public DConnect2(String urlString, boolean acceptCompress) throws IOException
Creates an instance bound to url. IfacceptDeflateis true then HTTP Request headers will indicate to servers that this client can accept compressed documents.- Parameters:
urlString- Connect to this URL.acceptCompress- true if this client will accept compressed responses- Throws:
FileNotFoundException- thrown ifurlStringis not a valid URL, or a filename which exists on the system.IOException
-
DConnect2
public DConnect2(InputStream stream) throws DAP2Exception
- Throws:
DAP2Exception
-
-
Method Detail
-
setAllowSessions
public static void setAllowSessions(boolean b)
-
setServerVersion
public void setServerVersion(int major, int minor)
-
isLocal
public boolean isLocal()
-
CE
public final String CE()
Returns the constraint expression supplied with the URL given to the constructor. If no CE was given this returns an emptyString.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.- Returns:
- the constraint expression associated with this connection.
-
URL
public final String URL()
Returns the URL supplied to the constructor. If the URL contained a constraint expression that is not returned.- Returns:
- the URL of this connection.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
captureStream
public static String captureStream(InputStream is) throws IOException
- Throws:
IOException
-
captureDataDDS
public static String captureDataDDS(InputStream is) throws IOException
- Throws:
IOException
-
getServerVersion
public final ServerVersion getServerVersion()
Returns theServerVersionof the last connection.- Returns:
- the
ServerVersionof the last connection.
-
getLastModifiedHeader
public String getLastModifiedHeader()
- Returns:
- value of Last-Modified Header from last connection, may be null
-
getLastModifiedInvalidHeader
public String getLastModifiedInvalidHeader()
- Returns:
- value of X-Last-Modified-Invalid Header from last connection, may be null
-
getLastExtendedHeader
public String getLastExtendedHeader()
- Returns:
- value of Last-Extended Header from last connection, may be null
-
getDAS
public DAS getDAS() throws IOException, DAP2Exception
Returns the DAS object from the dataset referenced by this object's URL. The DAS object is referred to by appending `.das' to the end of a DODS URL.- Returns:
- the DAS associated with the referenced dataset.
- Throws:
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 server
-
getDDS
public DDS getDDS() throws IOException, ParseException, DAP2Exception
Returns the DDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.dds' to the end of a OPeNDAP URL.- Returns:
- the DDS associated with the referenced dataset.
- Throws:
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 server
-
getDDS
public DDS getDDS(String CE) throws IOException, ParseException, DAP2Exception
Returns the DDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.dds' to the end of a OPeNDAP URL. If reading from a file, access the DDS object from the captured .dods response.- Parameters:
CE- The constraint expression to be applied to this request by the server. This is combined with any CE given in the constructor.- Returns:
- the DDS associated with the referenced dataset.
- Throws:
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 server
-
getDDX
public DDS getDDX() throws IOException, ParseException, DAP2Exception
Returns the DDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.ddx' to the end of a OPeNDAP URL. The server should send back a DDX (A DDS in XML format) which will get parsed here (locally) and a new DDS instantiated using the DDSXMLParser.- Returns:
- the DDS associated with the referenced dataset.
- Throws:
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 server
-
getDDX
public DDS getDDX(String CE) throws IOException, ParseException, DDSException, DAP2Exception
Returns the DDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.ddx' to the end of a OPeNDAP URL. The server should send back a DDX (A DDS in XML format) which will get parsed here (locally) and a new DDS instantiated using the DDSXMLParser.- Parameters:
CE- The constraint expression to be applied to this request by the server. This is combined with any CE given in the constructor.- Returns:
- the DDS associated with the referenced dataset.
- Throws:
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 server
-
getDataDDX
public DataDDS getDataDDX() throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Returns the DataDDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.ddx' to the end of a OPeNDAP URL. The server should send back a DDX (A DDS in XML format) which will get parsed here (locally) and a new DDS instantiated using the DDSXMLParser.- Returns:
- the DataDDS associated with the referenced dataset.
- Throws:
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 server
-
getDataDDX
public DataDDS getDataDDX(String CE) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Returns the DataDDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.ddx' to the end of a OPeNDAP URL. The server should send back a DDX (A DDS in XML format) which will get parsed here (locally) and a new DDS instantiated using the DDSXMLParser.- Parameters:
CE- The constraint expression to use for this request.- Returns:
- the DataDDS associated with the referenced dataset.
- Throws:
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 server
-
getDataDDX
public DataDDS getDataDDX(String CE, BaseTypeFactory btf) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Returns the DataDDS object from the dataset referenced by this object's URL. The DDS object is referred to by appending `.ddx' to the end of a OPeNDAP URL. The server should send back a DDX (A DDS in XML format) which will get parsed here (locally) and a new DDS instantiated using the DDSXMLParser.- Parameters:
CE- The constraint expression to use for this request.btf- TheBaseTypeFactoryto build the member variables in the DDS with.- Returns:
- the DataDDS associated with the referenced dataset.
- Throws:
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 server- See Also:
BaseTypeFactory
-
getData
public DataDDS getData(String CE, StatusUI statusUI, BaseTypeFactory btf) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Returns the `Data object' from the dataset referenced by this object's URL given the constraint expression CE. Note that the Data object is really just a DDS object with data bound to the variables. The DDS will probably contain fewer variables (and those might have different types) than in the DDS returned by getDDS() because that method returns the entire DDS (but without any data) while this method returns only those variables listed in the projection part of the constraint expression.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.
- Parameters:
CE- The constraint expression to be applied to this request by the server. This is combined with any CE given in the constructor.statusUI- theStatusUIobject to use for GUI updates and user cancellation notification (may be null).btf- TheBaseTypeFactoryto build the member variables in the DDS with.- Returns:
- The
DataDDSobject that results from applying the given CE, combined with this object's sticky CE, on the referenced dataset. - Throws:
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 server
-
getData
public DataDDS getData(String CE) throws IOException, ParseException, DAP2Exception
- Throws:
IOExceptionParseExceptionDAP2Exception
-
getData
public DataDDS getData(String CE, StatusUI statusUI) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Returns the `Data object' from the dataset referenced by this object's URL given the constraint expression CE. Note that the Data object is really just a DDS object with data bound to the variables. The DDS will probably contain fewer variables (and those might have different types) than in the DDS returned by getDDS() because that method returns the entire DDS (but without any data) while this method returns only those variables listed in the projection part of the constraint expression.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.
- Parameters:
CE- The constraint expression to be applied to this request by the server. This is combined with any CE given in the constructor.statusUI- theStatusUIobject to use for GUI updates and user cancellation notification (may be null).- Returns:
- The
DataDDSobject that results from applying the given CE, combined with this object's sticky CE, on the referenced dataset. - Throws:
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 server
-
getData
public final DataDDS getData(StatusUI statusUI) throws MalformedURLException, IOException, ParseException, DDSException, DAP2Exception
Return the data object with no local constraint expression. Same asgetData("", statusUI).- Parameters:
statusUI- theStatusUIobject to use for GUI updates and user cancellation notification (may be null).- Returns:
- The
DataDDSobject that results from applying this object's sticky CE, if any, on the referenced dataset. - Throws:
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 server
-
-