opendap.dap
Class ServerVersion

java.lang.Object
  extended by opendap.dap.ServerVersion
All Implemented Interfaces:
java.io.Serializable

public class ServerVersion
extends java.lang.Object
implements java.io.Serializable

Aprses and holds the Server Version information returned by a DAP server. This information is used to determine the version of the DAP protocol used to by the DAP server to encode the data.

Currently the Server Version can come from more than one source. An DAP server responding to to a client request over HTTP must include either an XDAP header or an XDODS-Server header.
>
The XDAP header content is defined as the protocol version of the transmission and must be of the form:

MV.mv[.mmv]

Where:

MV = Major Version Number
mv = Minor Version Number
mmv = An optional sub-minor version number.

For example an XDAP header value of 3.2 indicates a major version of 3 minor version of 2. An XDAP header value of 2.6.3 indicates a major version number of 2, a minor version number of 6, and a subminor version of 3.

The XDODS-Server header is a legacy mechanism which identifies the version of the server software generating the response. This is somewhat loosely coupled to the protocol version and was the legacy mechanism for identifying the protocol version. It should be considered deprecated. Thus, clients seeking to read data from OPeNDAP servers should first check the server response for the existence of an XDAP header, if one is not found then the client should check for an XDODS-Server header. If the repsonse is missing both headers then an exception should be thrown as the server response is invalid.

Author:
ndp
See Also:
ClientIO, DDS, Serialized Form

Field Summary
static java.lang.String DAP2_PROTOCOL_VERSION
           
static int XDAP
           
static int XDODS_SERVER
           
 
Constructor Summary
ServerVersion(org.apache.commons.httpclient.methods.GetMethod method)
          Determines Server (Protocol) Version based on the headers associated with the passed org.apache.commons.httpclient.methods.GetMethod.
ServerVersion(int major, int minor)
          Construct a new ServerVersion, setting major and minor version explicitly.
ServerVersion(java.lang.String ver, int headerType)
          Construct a new ServerVersion, setting major and minor version based on the full version string.
ServerVersion(java.net.URLConnection connection)
          Determines Server (Protocol) Version based on the headers associated with the passed java.net.URLConnection.
 
Method Summary
 int getMajor()
          Returns the major version number.
 int getMinor()
          Returns the minor version number.
 int getSubMinor()
          Returns the sub-minor version number, if it exists.
 java.lang.String getVersionString()
          Returns the full version string.
 java.lang.String toString()
          Returns the full version string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XDODS_SERVER

public static final int XDODS_SERVER
See Also:
Constant Field Values

XDAP

public static final int XDAP
See Also:
Constant Field Values

DAP2_PROTOCOL_VERSION

public static final java.lang.String DAP2_PROTOCOL_VERSION
See Also:
Constant Field Values
Constructor Detail

ServerVersion

public ServerVersion(org.apache.commons.httpclient.methods.GetMethod method)
              throws DAP2Exception
Determines Server (Protocol) Version based on the headers associated with the passed org.apache.commons.httpclient.methods.GetMethod.

Parameters:
method - The GetMethod containing the DAP2 headers.
Throws:
DAP2Exception - When bad things happen (like the headers are missing or incorrectly constructed.

ServerVersion

public ServerVersion(java.net.URLConnection connection)
              throws DAP2Exception
Determines Server (Protocol) Version based on the headers associated with the passed java.net.URLConnection.

Parameters:
connection - The URLCOnnection containing the DAP2 headers
Throws:
DAP2Exception - When bad things happen (like the headers are missing or incorrectly constructed.

ServerVersion

public ServerVersion(java.lang.String ver,
                     int headerType)
              throws DAP2Exception
Construct a new ServerVersion, setting major and minor version based on the full version string. Currently the Server Version can come from more than one source. An OPeNDAP server responding to to a client request over HTTP must include either an XDAP header or an XDODS-Server header.
>
The XDAP header content is defined as the protocol version of the transmission and must be of the form:

MV.mv[.mmv]

Where:

MV = Major Version Number
mv = Minor Version Number
mmv = An optional sub-minor version number.

For example an XDAP header value of 3.2 indicates a major version of 3 minor version of 2. An XDAP header value of 2.6.3 indicates a major version number of 2, a minor version number of 6, and a subminor version of 3.

The XDODS-Server header is a legacy mechanism which identifies the version of the server software generating the response. This is somewhat loosely coupled to the protocol version and was the legacy mechanism for identifying the protocol version. It should be considered deprecated. Thus, clients seeking to read data from OPeNDAP servers should first check the server response for the existence of an XDAP header, if one is not found then the client should check for an XDODS-Server header. If the repsonse is missing both headers then an exception should be thrown as the server response is invalid.

Parameters:
ver - the full version string.
headerType - The type of header that the version was read from. May be set to ServerVersion.XDODS_SERVER or ServerVersion.XDAP
Throws:
DAP2Exception - When the things go wrong.

ServerVersion

public ServerVersion(int major,
                     int minor)
Construct a new ServerVersion, setting major and minor version explicitly.

Parameters:
major - the major version number.
minor - the minor version number.
Method Detail

getMajor

public final int getMajor()
Returns the major version number.

Returns:
the major version number.

getMinor

public final int getMinor()
Returns the minor version number.

Returns:
the minor version number.

getSubMinor

public final int getSubMinor()
Returns the sub-minor version number, if it exists.

Returns:
the minor version number or -1 if the sub-minor version has not been set.

toString

public final java.lang.String toString()
Returns the full version string.

Overrides:
toString in class java.lang.Object
Returns:
the full version string.

getVersionString

public final java.lang.String getVersionString()
Returns the full version string.

Returns:
the full version string.