Package org.astrogrid.samp.hub
Class BasicHubService.ClientIdGenerator
- java.lang.Object
-
- org.astrogrid.samp.hub.BasicHubService.ClientIdGenerator
-
- Enclosing class:
- BasicHubService
private static class BasicHubService.ClientIdGenerator extends java.lang.ObjectGenerates client public IDs. These must be unique, but don't need to be hard to guess.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparatorcomparator_private intiseq_private java.lang.Stringprefix_
-
Constructor Summary
Constructors Constructor Description ClientIdGenerator(java.lang.String prefix)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ComparatorgetComparator()Returns a comparator which will order the IDs generated by this object in generation sequence.private java.lang.IntegergetIndex(java.lang.String id)Returns an Integer giving the sequence index of the given id string.booleanhasUsed(java.lang.String id)Indicates whether a given client ID has previously been dispensed by this object.java.lang.Stringnext()Returns the next unused id.
-
-
-
Method Detail
-
next
public java.lang.String next()
Returns the next unused id.- Returns:
- next id
-
hasUsed
public boolean hasUsed(java.lang.String id)
Indicates whether a given client ID has previously been dispensed by this object.- Parameters:
id- id to test- Returns:
- true iff id has been returned by a previous call of
next
-
getIndex
private java.lang.Integer getIndex(java.lang.String id)
Returns an Integer giving the sequence index of the given id string. Ifiddoes not look like a string generated by this object, null is returned.- Parameters:
id- identifier to test- Returns:
- object containing sequence index of
id, or null
-
getComparator
public java.util.Comparator getComparator()
Returns a comparator which will order the IDs generated by this object in generation sequence.- Returns:
- id comparator
-
-