Package org.astrogrid.samp.client

# Class DefaultClientProfile

java.lang.Object
org.astrogrid.samp.client.DefaultClientProfile

public class DefaultClientProfile extends Object
Factory which supplies the default ClientProfile for use by SAMP clients. By using this class to obtain ClientProfile instances, applications can be used with non-standard profiles supplied at runtime without requiring any code changes.

The profile returned by this class depends on the SAMP_HUB environment variable (`HUBLOC_ENV`). If it consists of the prefix "`jsamp-class:`" (`HUBLOC_CLASS_PREFIX`) followed by the classname of a class which implements `ClientProfile` and has a no-arg constructor, then an instance of the named class is used. Otherwise, an instance of `StandardClientProfile` or `WebClientProfile` is returned.

Since:
  4 Aug 2009
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`HUBLOC_CLASS_PREFIX`
Prefix for SAMP_HUB env var indicating a supplied ClientProfile implementation ("jsamp-class:").
`static final String`
`HUBLOC_ENV`
Environment variable used for hub location ("SAMP_HUB").

## Method Summary

Modifier and Type
Method
Description
`static ClientProfile`
`getProfile()`
Returns a ClientProfile instance suitable for general purpose use.
`static void`
`setProfile(ClientProfile profile)`
Sets the profile object which will be returned by `getProfile()`.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### HUBLOC_ENV

public static final String HUBLOC_ENV
Environment variable used for hub location ("SAMP_HUB").

See Also:
  - Constant Field Values

### HUBLOC_CLASS_PREFIX

public static final String HUBLOC_CLASS_PREFIX
Prefix for SAMP_HUB env var indicating a supplied ClientProfile implementation ("jsamp-class:").

See Also:
  - Constant Field Values

## Method Details

### getProfile

public static ClientProfile getProfile()
Returns a ClientProfile instance suitable for general purpose use. By default this is currently the Standard Profile (`StandardClientProfile.getInstance()`), but the instance may be modified programatically or by use of the SAMP_HUB environment variable.

If no instance has been set, the SAMP_HUB environment variable is examined. If it consists of the prefix "`jsamp-class:`" (`HUBLOC_CLASS_PREFIX`) followed by the classname of a class which implements `ClientProfile` and has a no-arg constructor, then an instance of the named class is used. Otherwise, an instance of `StandardClientProfile` is returned.

The instance is obtained lazily.

Returns:
  client profile instance

### setProfile

public static void setProfile(ClientProfile profile)
Sets the profile object which will be returned by `getProfile()`.

Parameters:
  `profile` - default profile instance