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:
  `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

## Nested Class Summary

## Nested classes/interfaces inherited from class java.util.AbstractMap

`AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

## Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K,V>`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_VERSION_VALUE`
SAMP Standard Profile version for this toolkit implementation.
`static final String`
`SECRET_KEY`
Key for opaque text string required by the hub for registration.
`static final String`
`VERSION_KEY`
Key for the SAMP Standard Profile version implemented by the hub.
`static final String`
`XMLRPCURL_KEY`
Key for XML-RPC endpoint for communication with the hub.

### Fields inherited from class org.astrogrid.samp.SampMap

`EMPTY`

## Constructor Summary

Constructors
Constructor
Description
`LockInfo()`
Constructs an empty LockInfo.
`LockInfo(String secret, String xmlrpcurl)`
Constructs a LockInfo from a given SAMP secret and XML-RPC URL.
`LockInfo(Map map)`
Constructs a LockInfo based on an existing map.

## Method Summary

Modifier and Type
Method
Description
`static LockInfo`
`asLockInfo(Map map)`
Returns a given map as a LockInfo object.
`void`
`check()`
Checks that this object is ready for use with the SAMP toolkit.
`String`
`getSecret()`
Returns the value of the `SECRET_KEY` key.
`String`
`getVersion()`
Returns the value of the `VERSION_KEY` key.
`URL`
`getXmlrpcUrl()`
Returns the value of the `XMLRPCURL_KEY` key.
`static LockInfo`
`readLockFile(InputStream in)`
Returns the LockInfo read from a given stream.
`static LockInfo`
`readLockFile(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`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Map

`compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll`

## Field Details

### SECRET_KEY

public static final String SECRET_KEY
Key for opaque text string required by the hub for registration.

See Also:
  - Constant Field Values

### XMLRPCURL_KEY

public static final String XMLRPCURL_KEY
Key for XML-RPC endpoint for communication with the hub.

See Also:
  - Constant Field Values

### VERSION_KEY

public static final 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 String DEFAULT_VERSION_VALUE
SAMP Standard Profile version for this toolkit implementation.

See Also:
  - Constant Field Values

## Constructor Details

### LockInfo

public LockInfo()
Constructs an empty LockInfo.

### LockInfo

public LockInfo(Map map)
Constructs a LockInfo based on an existing map.

Parameters:
  `map` - map containing initial data for this object

### LockInfo

public LockInfo(String secret, 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 for `SECRET_KEY` key
  `xmlrpcurl` - value for `XMLRPCURL_KEY` key

## Method Details

### getXmlrpcUrl

public URL getXmlrpcUrl()
Returns the value of the `XMLRPCURL_KEY` key.

Returns:
  hub XML-RPC connection URL

### getVersion

public String getVersion()
Returns the value of the `VERSION_KEY` key.

Returns:
  version of the SAMP standard profile implemented

### getSecret

public String getSecret()
Returns the value of the `SECRET_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 calling `SampUtils.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 informative `DataException` will be thrown.

Overrides:
  `check` in class `SampMap`

### readLockFile

public static LockInfo readLockFile(URL url) throws 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:
  `IOException`

### readLockFile

public static LockInfo readLockFile(InputStream in) throws 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:
  `IOException`

### asLockInfo

public static LockInfo asLockInfo(Map map)
Returns a given map as a LockInfo object.

Parameters:
  `map` - map
Returns:
  lock info