edu.wisc.ssec.mcidasv.servermanager
Class RemoteAddeEntry

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.servermanager.RemoteAddeEntry
All Implemented Interfaces:
AddeEntry

public class RemoteAddeEntry
extends Object
implements AddeEntry


Nested Class Summary
static class RemoteAddeEntry.Builder
          Something of a hack... this approach allows us to build a RemoteAddeEntry in a readable way, despite there being multiple final fields.
 
Nested classes/interfaces inherited from interface edu.wisc.ssec.mcidasv.servermanager.AddeEntry
AddeEntry.EditorAction, AddeEntry.EntrySource, AddeEntry.EntryStatus, AddeEntry.EntryType, AddeEntry.EntryValidity
 
Field Summary
private  AddeAccount account
          Holds the accounting information for this entry.
static int ADDE_PORT
          Default port for remote ADDE servers.
private  String address
          The server "address" of this entry.
private  String asStringId
           
private  String entryAlias
          Allows the user to refer to this entry with an arbitrary name.
private  AddeEntry.EntrySource entrySource
          Where this entry came from.
private  AddeEntry.EntryStatus entryStatus
          Whether or not this entry is in the "active set".
private  AddeEntry.EntryType entryType
          This entry's type.
private  AddeEntry.EntryValidity entryValidity
          Whether or not this entry is valid.
private  String group
          The "dataset" of this entry.
private  int hashCode
          Used so that the hashCode of this entry is not needlessly recalculated.
static List<RemoteAddeEntry> INVALID_ENTRIES
          Represents a collection of invalid remote ADDE entries.
static RemoteAddeEntry INVALID_ENTRY
          Represents an invalid remote ADDE entry.
private  boolean isTemporary
           
private static org.slf4j.Logger logger
          Typical logger object.
private static String publicSrvFormat
          String.format(String, Object...)
 
Fields inherited from interface edu.wisc.ssec.mcidasv.servermanager.AddeEntry
DEFAULT_ACCOUNT
 
Constructor Summary
private RemoteAddeEntry(RemoteAddeEntry.Builder builder)
          Creates a new ADDE entry using a give "ADDE entry builder".
 
Method Summary
 String asStringId()
          Currently used as a identifier for convenient storage by the server manager.
static RemoteEntryEditor.AddeStatus checkEntry(boolean checkHost, RemoteAddeEntry entry)
          Attempts to verify whether or not the information in a given RemoteAddeEntry represents a valid remote ADDE server.
static RemoteEntryEditor.AddeStatus checkEntry(RemoteAddeEntry entry)
          Attempts to verify whether or not the information in a given RemoteAddeEntry represents a valid remote ADDE server.
static Map<AddeEntry.EntryType,RemoteEntryEditor.AddeStatus> checkEntryTypes(String host, String group)
           
static Map<AddeEntry.EntryType,RemoteEntryEditor.AddeStatus> checkEntryTypes(String host, String group, String user, String proj)
           
static boolean checkHost(RemoteAddeEntry entry)
          Determines whether or not the server specified in entry is listening on port 112.
 boolean equals(Object obj)
          Determines whether or not the given object is equivalent to this ADDE entry.
 AddeAccount getAccount()
          Accounting information associated with the current entry.
 String getAddress()
          Address of the server associated with the current entry.
 String getEntryAlias()
           
 AddeEntry.EntrySource getEntrySource()
          Source that specified this entry.
 AddeEntry.EntryStatus getEntryStatus()
          GUI status of the entry.
 String getEntryText()
          Handy String representation of this ADDE entry.
 AddeEntry.EntryType getEntryType()
          Type of chooser this entry should appear under.
 AddeEntry.EntryValidity getEntryValidity()
          Does this entry represent a "valid" ADDE server.
 String getGroup()
          Dataset/group located on the server.
 String getName()
          Name associated with this entry.
 int hashCode()
          Returns a hash code for this ADDE entry.
 boolean isEntryTemporary()
           
static Set<String> readGroups(String host, String user, String proj)
           
static Set<String> readPublicGroups(RemoteAddeEntry entry)
          Tries to connect to a given RemoteAddeEntry and read the list of ADDE "groups" available to the public.
static Set<String> readPublicGroups(String host)
           
 void setEntryAlias(String newAlias)
           
 void setEntryStatus(AddeEntry.EntryStatus newStatus)
           
 void setEntryValidity(AddeEntry.EntryValidity entryValidity)
           
 String toString()
          String representation of this entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final org.slf4j.Logger logger
Typical logger object.


INVALID_ENTRY

public static final RemoteAddeEntry INVALID_ENTRY
Represents an invalid remote ADDE entry.


INVALID_ENTRIES

public static final List<RemoteAddeEntry> INVALID_ENTRIES
Represents a collection of invalid remote ADDE entries.


ADDE_PORT

public static final int ADDE_PORT
Default port for remote ADDE servers.

See Also:
Constant Field Values

publicSrvFormat

private static final String publicSrvFormat
String.format(String, Object...)-friendly string for building a request to read a server's PUBLIC.SRV.

See Also:
Constant Field Values

account

private final AddeAccount account
Holds the accounting information for this entry.


address

private final String address
The server "address" of this entry.


group

private final String group
The "dataset" of this entry.


isTemporary

private final boolean isTemporary

entryType

private AddeEntry.EntryType entryType
This entry's type.


entryValidity

private AddeEntry.EntryValidity entryValidity
Whether or not this entry is valid.


entrySource

private AddeEntry.EntrySource entrySource
Where this entry came from.


entryStatus

private AddeEntry.EntryStatus entryStatus
Whether or not this entry is in the "active set".


entryAlias

private String entryAlias
Allows the user to refer to this entry with an arbitrary name.


asStringId

private String asStringId

hashCode

private volatile int hashCode
Used so that the hashCode of this entry is not needlessly recalculated.

See Also:
hashCode()
Constructor Detail

RemoteAddeEntry

private RemoteAddeEntry(RemoteAddeEntry.Builder builder)
Creates a new ADDE entry using a give "ADDE entry builder".

Parameters:
builder - Object used to build this entry.
Method Detail

getAddress

public String getAddress()
Description copied from interface: AddeEntry
Address of the server associated with the current entry. LocalAddeEntrys will return localhost.

Specified by:
getAddress in interface AddeEntry
Returns:
address

getGroup

public String getGroup()
Description copied from interface: AddeEntry
Dataset/group located on the server.

Specified by:
getGroup in interface AddeEntry
Returns:
group

getName

public String getName()
Description copied from interface: AddeEntry
Name associated with this entry.

Specified by:
getName in interface AddeEntry
Returns:
Name associated with this entry.

getAccount

public AddeAccount getAccount()
Description copied from interface: AddeEntry
Accounting information associated with the current entry. If the server does not require accounting information, this method returns AddeEntry.DEFAULT_ACCOUNT.

Specified by:
getAccount in interface AddeEntry
Returns:
account

getEntryType

public AddeEntry.EntryType getEntryType()
Description copied from interface: AddeEntry
Type of chooser this entry should appear under.

Specified by:
getEntryType in interface AddeEntry
Returns:
entryType

getEntryValidity

public AddeEntry.EntryValidity getEntryValidity()
Description copied from interface: AddeEntry
Does this entry represent a "valid" ADDE server.

Specified by:
getEntryValidity in interface AddeEntry
Returns:
entryValidity

setEntryValidity

public void setEntryValidity(AddeEntry.EntryValidity entryValidity)

getEntrySource

public AddeEntry.EntrySource getEntrySource()
Description copied from interface: AddeEntry
Source that specified this entry. For example; allows you to distinguish "system" entries (which cannot be removed, only disabled) from entries created by the user (full control).

Specified by:
getEntrySource in interface AddeEntry
Returns:
entrySource

getEntryStatus

public AddeEntry.EntryStatus getEntryStatus()
Description copied from interface: AddeEntry
GUI status of the entry. Differs from AddeEntry.EntryValidity in that EntryStatus controls this entry showing up in a chooser and has nothing to do with whether or not the entry is a valid ADDE server.

Specified by:
getEntryStatus in interface AddeEntry
Returns:
entryStatus

setEntryStatus

public void setEntryStatus(AddeEntry.EntryStatus newStatus)
Specified by:
setEntryStatus in interface AddeEntry

getEntryAlias

public String getEntryAlias()
Specified by:
getEntryAlias in interface AddeEntry

setEntryAlias

public void setEntryAlias(String newAlias)
Specified by:
setEntryAlias in interface AddeEntry

isEntryTemporary

public boolean isEntryTemporary()
Specified by:
isEntryTemporary in interface AddeEntry

getEntryText

public String getEntryText()
Handy String representation of this ADDE entry. Currently looks like ADDRESS/GROUP, but this is subject to change.

Specified by:
getEntryText in interface AddeEntry
Returns:
Alternate String representation of this entry.

equals

public boolean equals(Object obj)
Determines whether or not the given object is equivalent to this ADDE entry.

Overrides:
equals in class Object
Parameters:
obj - Object to test against. null values are okay, but return false.
Returns:
true if the given object is the same as this ADDE entry, false otherwise... including when o is null.

hashCode

public int hashCode()
Returns a hash code for this ADDE entry. The hash code is computed using the values of the following fields: address, group, entryType, account.

Overrides:
hashCode in class Object
Returns:
Hash code value for this object.

asStringId

public String asStringId()
Description copied from interface: AddeEntry
Currently used as a identifier for convenient storage by the server manager.

Specified by:
asStringId in interface AddeEntry

toString

public String toString()
Description copied from interface: AddeEntry
String representation of this entry.

Specified by:
toString in interface AddeEntry
Overrides:
toString in class Object

readPublicGroups

public static Set<String> readPublicGroups(RemoteAddeEntry entry)
Tries to connect to a given RemoteAddeEntry and read the list of ADDE "groups" available to the public.

Parameters:
entry - The RemoteAddeEntry to query. Cannot be null.
Returns:
The Set of public groups on entry.
Throws:
NullPointerException - if entry is null.
IllegalArgumentException - if the server address is an empty String.

checkHost

public static boolean checkHost(RemoteAddeEntry entry)
Determines whether or not the server specified in entry is listening on port 112.

Parameters:
entry - Descriptor containing the server to check.
Returns:
true if a connection was opened, false otherwise.
Throws:
NullPointerException - if entry is null.

checkEntry

public static RemoteEntryEditor.AddeStatus checkEntry(RemoteAddeEntry entry)
Attempts to verify whether or not the information in a given RemoteAddeEntry represents a valid remote ADDE server. If not, the method tries to determine which parts of the entry are invalid.

Note that this method uses checkHost(RemoteAddeEntry) to verify that the server is listening. To forego the check, simply call checkEntry(false, entry).

Parameters:
entry - RemoteAddeEntry to check. Cannot be null.
Returns:
The RemoteEntryEditor.AddeStatus that represents the verification status of entry.
See Also:
checkHost(RemoteAddeEntry), checkEntry(boolean, RemoteAddeEntry)

checkEntry

public static RemoteEntryEditor.AddeStatus checkEntry(boolean checkHost,
                                                      RemoteAddeEntry entry)
Attempts to verify whether or not the information in a given RemoteAddeEntry represents a valid remote ADDE server. If not, the method tries to determine which parts of the entry are invalid.

Parameters:
checkHost - true tries to connect to the remote ADDE server before doing anything else.
entry - RemoteAddeEntry to check. Cannot be null.
Returns:
The RemoteEntryEditor.AddeStatus that represents the verification status of entry.
Throws:
NullPointerException - if entry is null.
See Also:
RemoteEntryEditor.AddeStatus

checkEntryTypes

public static Map<AddeEntry.EntryType,RemoteEntryEditor.AddeStatus> checkEntryTypes(String host,
                                                                                    String group)

checkEntryTypes

public static Map<AddeEntry.EntryType,RemoteEntryEditor.AddeStatus> checkEntryTypes(String host,
                                                                                    String group,
                                                                                    String user,
                                                                                    String proj)

readPublicGroups

public static Set<String> readPublicGroups(String host)

readGroups

public static Set<String> readGroups(String host,
                                     String user,
                                     String proj)