edu.wisc.ssec.mcidas.adde
Class AddeURL

java.lang.Object
  extended by edu.wisc.ssec.mcidas.adde.AddeURL
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AddeDatasetURL

public class AddeURL
extends Object
implements Cloneable

A class for holding information about an ADDE URL.


 URLs must all have the following format:

   adde://host/request?keyword_1=value_1&keyword_2=value_2

 where request can be one of the following:

   datasetinfo - request for data set information (LWPR)
   griddirectory - request for grid directory information (GDIR)
   griddata - request for grid data (GGET)
   imagedata - request for data in AreaFile format (AGET)
   imagedirectory - request for image directory information (ADIR)
   pointdata - request for point data (MDKS)
   textdata - request to read a text file (TXTG)
   wxtext   - request to read a weather text file (WTXG)
   obtext   - request to read a observation text file (OBTG)

 There can be any valid combination of the following supported keywords:

 -------for any request

   group=<groupname>         ADDE group name
   user=<user_id>            ADDE user identification
   proj=<proj #>             a valid ADDE project number
   trace=<0/1>               setting to 1 tells server to write debug
                               trace file
   version=                  ADDE version number, currently 1 except for
                             griddata requests
   debug=                    set to true to watch the printlns stream by
   compress=                 set to "gzip" if you want to use the GZIP
                             compression or "compress" if you want to use
                             transfers in Unix compress format (You need to
                             have the VisAD package if you want to support
                             this.)  default = none.
   port=                     Socket port to connect on.  Overridden by
                             a port specified in the host
                             (e.g., adde.ucar.edu:500)

 


Field Summary
static String ADDE_PROTOCOL
          The protocol
static String ALL
          Value for ALL
static int COMPRESS
          Flag for "compress" compression.
static String DEFAULT_VALUE
          Default value for key/value pairs (X)
static int GZIP
          Flag for GZip compression.
static String KEY_COMPRESS
          Keyword for compress
static String KEY_DEBUG
          Keyword for debug
static String KEY_PORT
          Keyword for port
static String KEY_PROJ
          Keyword for project
static String KEY_TRACE
          Keyword for trace
static String KEY_USER
          Keyword for user
static String KEY_VERSION
          Keyword for version
static String NO
          Value for no
static int NO_COMPRESS
          Flag for "no compress" compression.
static String REQ_ADIR
          ADIR request type
static String REQ_AGET
          AGET request type
static String REQ_DATASETINFO
          Data set info request type
static String REQ_GDIR
          GDIR request type
static String REQ_GGET
          GGET request type
static String REQ_GRIDDATA
          Grid data request type
static String REQ_GRIDDIR
          Grid directory request type
static String REQ_IMAGEDATA
          Image data request type
static String REQ_IMAGEDIR
          Image directory request type
static String REQ_LWPR
          LWPR request type
static String REQ_MDKS
          MDKS request type
static String REQ_OBTEXT
          obs text request type
static String REQ_OBTG
          OBTG request type
static String REQ_POINTDATA
          Point data request type
static String REQ_TEXT
          Text request type
static String REQ_TXTG
          TXTG request type
static String REQ_WTXG
          WTXG request type
static String REQ_WXTEXT
          weather text request type
static int TRACE_OFF
          flag for trace off
static int TRACE_ON
          flag for trace on
static String YES
          Value for yes
 
Constructor Summary
AddeURL()
          Create an ADDE URL
AddeURL(String host, String requestType)
          Create an ADDE URL from the given spec
AddeURL(String host, String requestType, String extraKeys)
          Create an ADDE URL from the given spec
 
Method Summary
protected  void appendKeyValue(StringBuffer buf, String name, String value)
          A utility method to make a name=value part of the adde request string
 Object clone()
          Clones this instance.
 boolean equals(Object o)
          Compare two AddeURLs
 int getCompression()
          Get the compression type for this ADDE URL
 boolean getDebug()
          Get the debug value for this ADDE URL
 String getExtraKeys()
          Get the extraKeys string for this ADDE URL
 String getHost()
          Get the host for this ADDE URL
 int getPort()
          Get the port for this ADDE URL
 int getProject()
          Get the project for this ADDE URL
 String getRequestType()
          Get the request type for this ADDE URL
 int getTrace()
          Get the trace value used for this ADDE URL
 String getURLString()
          Create the ADDE URL as a String
 String getUser()
          Get the project for this ADDE URL
 String getValue(String query, String key)
          Get the value for a particular key.
 String getVersion()
          Get the version for this ADDE URL
 int hashCode()
          Get the hashcode for this
protected  String makeQuery()
          Make the query portion of the URL (e.g., key1=value1&key2=value2..)
protected  void parseQuery(String query)
          Parse the query string and set the values accordingly, subclasses should extend to parse their particular keywords
 void setCompression(int compress)
          Set the compression type used for this ADDE URL
 void setCompressionFromString(String type)
          Set the compression type from a string
 void setDebug(boolean debug)
          Set the debug value this ADDE URL
 void setExtraKeys(String extraKeys)
          Set the extraKeys string for this ADDE URL
 void setHost(String host)
          Set the host for this ADDE URL
 void setPort(int port)
          Set the port used for this ADDE URL
 void setProject(int project)
          Set the project for this ADDE URL
 void setRequestType(String requestType)
          Set the request type for this ADDE URL
 void setTrace(int trace)
          Set the trace value used for this ADDE URL
 void setUser(String user)
          Set the user for this ADDE URL
 void setVersion(String version)
          Set the version this ADDE URL
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADDE_PROTOCOL

public static final String ADDE_PROTOCOL
The protocol

See Also:
Constant Field Values

REQ_AGET

public static final String REQ_AGET
AGET request type

See Also:
Constant Field Values

REQ_ADIR

public static final String REQ_ADIR
ADIR request type

See Also:
Constant Field Values

REQ_LWPR

public static final String REQ_LWPR
LWPR request type

See Also:
Constant Field Values

REQ_GDIR

public static final String REQ_GDIR
GDIR request type

See Also:
Constant Field Values

REQ_GGET

public static final String REQ_GGET
GGET request type

See Also:
Constant Field Values

REQ_MDKS

public static final String REQ_MDKS
MDKS request type

See Also:
Constant Field Values

REQ_TXTG

public static final String REQ_TXTG
TXTG request type

See Also:
Constant Field Values

REQ_WTXG

public static final String REQ_WTXG
WTXG request type

See Also:
Constant Field Values

REQ_OBTG

public static final String REQ_OBTG
OBTG request type

See Also:
Constant Field Values

REQ_IMAGEDATA

public static final String REQ_IMAGEDATA
Image data request type

See Also:
Constant Field Values

REQ_IMAGEDIR

public static final String REQ_IMAGEDIR
Image directory request type

See Also:
Constant Field Values

REQ_DATASETINFO

public static final String REQ_DATASETINFO
Data set info request type

See Also:
Constant Field Values

REQ_TEXT

public static final String REQ_TEXT
Text request type

See Also:
Constant Field Values

REQ_WXTEXT

public static final String REQ_WXTEXT
weather text request type

See Also:
Constant Field Values

REQ_OBTEXT

public static final String REQ_OBTEXT
obs text request type

See Also:
Constant Field Values

REQ_GRIDDATA

public static final String REQ_GRIDDATA
Grid data request type

See Also:
Constant Field Values

REQ_GRIDDIR

public static final String REQ_GRIDDIR
Grid directory request type

See Also:
Constant Field Values

REQ_POINTDATA

public static final String REQ_POINTDATA
Point data request type

See Also:
Constant Field Values

DEFAULT_VALUE

public static final String DEFAULT_VALUE
Default value for key/value pairs (X)

See Also:
Constant Field Values

YES

public static final String YES
Value for yes

See Also:
Constant Field Values

NO

public static final String NO
Value for no

See Also:
Constant Field Values

ALL

public static final String ALL
Value for ALL

See Also:
Constant Field Values

KEY_TRACE

public static final String KEY_TRACE
Keyword for trace

See Also:
Constant Field Values

KEY_DEBUG

public static final String KEY_DEBUG
Keyword for debug

See Also:
Constant Field Values

KEY_PORT

public static final String KEY_PORT
Keyword for port

See Also:
Constant Field Values

KEY_PROJ

public static final String KEY_PROJ
Keyword for project

See Also:
Constant Field Values

KEY_USER

public static final String KEY_USER
Keyword for user

See Also:
Constant Field Values

KEY_COMPRESS

public static final String KEY_COMPRESS
Keyword for compress

See Also:
Constant Field Values

KEY_VERSION

public static final String KEY_VERSION
Keyword for version

See Also:
Constant Field Values

COMPRESS

public static final int COMPRESS
Flag for "compress" compression.

See Also:
Constant Field Values

NO_COMPRESS

public static final int NO_COMPRESS
Flag for "no compress" compression.

See Also:
Constant Field Values

GZIP

public static final int GZIP
Flag for GZip compression.

See Also:
Constant Field Values

TRACE_ON

public static final int TRACE_ON
flag for trace on

See Also:
Constant Field Values

TRACE_OFF

public static final int TRACE_OFF
flag for trace off

See Also:
Constant Field Values
Constructor Detail

AddeURL

public AddeURL()
Create an ADDE URL


AddeURL

public AddeURL(String host,
               String requestType)
Create an ADDE URL from the given spec

Parameters:
host - host to send to
requestType - type of request (REQ_*)

AddeURL

public AddeURL(String host,
               String requestType,
               String extraKeys)
Create an ADDE URL from the given spec

Parameters:
host - host to send to
requestType - type of request (REQ_*)
extraKeys - extra key/value arguments
Method Detail

getURLString

public String getURLString()
Create the ADDE URL as a String

Returns:
an Adde URL

makeQuery

protected String makeQuery()
Make the query portion of the URL (e.g., key1=value1&key2=value2..) Subclasses should override.

Returns:
the query portion of the URL

parseQuery

protected void parseQuery(String query)
Parse the query string and set the values accordingly, subclasses should extend to parse their particular keywords

Parameters:
query - query string

getValue

public String getValue(String query,
                       String key)
Get the value for a particular key.

Parameters:
query - the query string
key - the key to search
Returns:
the value or null if it doesn't exist

appendKeyValue

protected void appendKeyValue(StringBuffer buf,
                              String name,
                              String value)
A utility method to make a name=value part of the adde request string

Parameters:
buf - The buffer to append to
name - The property name
value - The value

equals

public boolean equals(Object o)
Compare two AddeURLs

Overrides:
equals in class Object
Parameters:
o - Object in question
Returns:
true if they are the same object or if all

hashCode

public int hashCode()
Get the hashcode for this

Overrides:
hashCode in class Object
Returns:
the hashcode

getHost

public String getHost()
Get the host for this ADDE URL

Returns:
the host

setHost

public void setHost(String host)
Set the host for this ADDE URL

Parameters:
host - the host

getRequestType

public String getRequestType()
Get the request type for this ADDE URL

Returns:
the host

setRequestType

public void setRequestType(String requestType)
Set the request type for this ADDE URL

Parameters:
requestType - the request Type

getExtraKeys

public String getExtraKeys()
Get the extraKeys string for this ADDE URL

Returns:
the extraKeys string

setExtraKeys

public void setExtraKeys(String extraKeys)
Set the extraKeys string for this ADDE URL

Parameters:
extraKeys - the extraKeys

getUser

public String getUser()
Get the project for this ADDE URL

Returns:
the project

setUser

public void setUser(String user)
Set the user for this ADDE URL

Parameters:
user - the user

getProject

public int getProject()
Get the project for this ADDE URL

Returns:
the project

setProject

public void setProject(int project)
Set the project for this ADDE URL

Parameters:
project - the project

getVersion

public String getVersion()
Get the version for this ADDE URL

Returns:
the version

setVersion

public void setVersion(String version)
Set the version this ADDE URL

Parameters:
version - the version

getDebug

public boolean getDebug()
Get the debug value for this ADDE URL

Returns:
the debug value (true or false)

setDebug

public void setDebug(boolean debug)
Set the debug value this ADDE URL

Parameters:
debug - the debug value (true or false);

getPort

public int getPort()
Get the port for this ADDE URL

Returns:
the port

setPort

public void setPort(int port)
Set the port used for this ADDE URL

Parameters:
port - the port

getCompression

public int getCompression()
Get the compression type for this ADDE URL

Returns:
the compression type

setCompression

public void setCompression(int compress)
Set the compression type used for this ADDE URL

Parameters:
compress - the compression type (GZIP, NO_COMPRESS, COMPRESS)

getTrace

public int getTrace()
Get the trace value used for this ADDE URL

Returns:
the trace value (TRACE_ON, TRACE_OFF)

setTrace

public void setTrace(int trace)
Set the trace value used for this ADDE URL

Parameters:
trace - the trace value (TRACE_ON, TRACE_OFF)

setCompressionFromString

public void setCompressionFromString(String type)
Set the compression type from a string

Parameters:
type - the string type

clone

public Object clone()
             throws CloneNotSupportedException
Clones this instance.

This implementation never throws CloneNotSupportException

Overrides:
clone in class Object
Returns:
A clone of this instance.
Throws:
CloneNotSupportedException - if cloning isn't supported.