Package org.astrogrid.samp.xmlrpc
Class LockInfo
- java.lang.Object
-
- java.util.AbstractMap
-
- org.astrogrid.samp.SampMap
-
- org.astrogrid.samp.xmlrpc.LockInfo
-
- All Implemented Interfaces:
java.util.Map
public class LockInfo extends SampMap
Represents the information read from a SAMP Standard Profile Lockfile. This contains a key-value entry for each assignment read from the file. Any non-assignment lines are not represented by this object.- Since:
- 14 Jul 2008
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_VERSION_VALUE
SAMP Standard Profile version for this toolkit implementation.static java.lang.String
SECRET_KEY
Key for opaque text string required by the hub for registration.static java.lang.String
VERSION_KEY
Key for the SAMP Standard Profile version implemented by the hub.static java.lang.String
XMLRPCURL_KEY
Key for XML-RPC endpoint for communication with the hub.
-
Constructor Summary
Constructors Constructor Description LockInfo()
Constructs an empty LockInfo.LockInfo(java.lang.String secret, java.lang.String xmlrpcurl)
Constructs a LockInfo from a given SAMP secret and XML-RPC URL.LockInfo(java.util.Map map)
Constructs a LockInfo based on an existing map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LockInfo
asLockInfo(java.util.Map map)
Returns a given map as a LockInfo object.void
check()
Checks that this object is ready for use with the SAMP toolkit.java.lang.String
getSecret()
Returns the value of theSECRET_KEY
key.java.lang.String
getVersion()
Returns the value of theVERSION_KEY
key.java.net.URL
getXmlrpcUrl()
Returns the value of theXMLRPCURL_KEY
key.static LockInfo
readLockFile(java.io.InputStream in)
Returns the LockInfo read from a given stream.static LockInfo
readLockFile(java.net.URL url)
Returns a LockInfo as read from a lockfile at a given location.-
Methods inherited from class org.astrogrid.samp.SampMap
checkHasKeys, entrySet, getList, getMap, getString, getUrl, put
-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
-
-
-
-
Field Detail
-
SECRET_KEY
public static final java.lang.String SECRET_KEY
Key for opaque text string required by the hub for registration.- See Also:
- Constant Field Values
-
XMLRPCURL_KEY
public static final java.lang.String XMLRPCURL_KEY
Key for XML-RPC endpoint for communication with the hub.- See Also:
- Constant Field Values
-
VERSION_KEY
public static final java.lang.String VERSION_KEY
Key for the SAMP Standard Profile version implemented by the hub.- See Also:
- Constant Field Values
-
DEFAULT_VERSION_VALUE
public static final java.lang.String DEFAULT_VERSION_VALUE
SAMP Standard Profile version for this toolkit implementation.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LockInfo
public LockInfo()
Constructs an empty LockInfo.
-
LockInfo
public LockInfo(java.util.Map map)
Constructs a LockInfo based on an existing map.- Parameters:
map
- map containing initial data for this object
-
LockInfo
public LockInfo(java.lang.String secret, java.lang.String xmlrpcurl)
Constructs a LockInfo from a given SAMP secret and XML-RPC URL. The version string is set to the default for this toolkit.- Parameters:
secret
- value forSECRET_KEY
keyxmlrpcurl
- value forXMLRPCURL_KEY
key
-
-
Method Detail
-
getXmlrpcUrl
public java.net.URL getXmlrpcUrl()
Returns the value of theXMLRPCURL_KEY
key.- Returns:
- hub XML-RPC connection URL
-
getVersion
public java.lang.String getVersion()
Returns the value of theVERSION_KEY
key.- Returns:
- version of the SAMP standard profile implemented
-
getSecret
public java.lang.String getSecret()
Returns the value of theSECRET_KEY
key.- Returns:
- password for hub connection
-
check
public void check()
Description copied from class:SampMap
Checks that this object is ready for use with the SAMP toolkit. As well as callingSampUtils.checkMap(java.util.Map)
(ensuring that all keys are Strings, and all values Strings, Lists or Maps), subclass-specific invariants may be checked. In the case that there's something wrong, an informativeDataException
will be thrown.
-
readLockFile
public static LockInfo readLockFile(java.net.URL url) throws java.io.IOException
Returns a LockInfo as read from a lockfile at a given location. If the lockfile does not exist, null is returned. An exception may be thrown if it exists but is cannot be read.- Parameters:
url
- lockfile location- Returns:
- lockfile contents, or null if it is absent
- Throws:
java.io.IOException
-
readLockFile
public static LockInfo readLockFile(java.io.InputStream in) throws java.io.IOException
Returns the LockInfo read from a given stream. The stream is closed if the read is successful.- Parameters:
in
- input stream to read- Returns:
- lockfile information
- Throws:
java.io.IOException
-
asLockInfo
public static LockInfo asLockInfo(java.util.Map map)
Returns a given map as a LockInfo object.- Parameters:
map
- map- Returns:
- lock info
-
-