Class 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
  • Field Details

    • SECRET_KEY

      public static final String SECRET_KEY
      Key for opaque text string required by the hub for registration.
      See Also:
    • XMLRPCURL_KEY

      public static final String XMLRPCURL_KEY
      Key for XML-RPC endpoint for communication with the hub.
      See Also:
    • VERSION_KEY

      public static final String VERSION_KEY
      Key for the SAMP Standard Profile version implemented by the hub.
      See Also:
    • DEFAULT_VERSION_VALUE

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