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.Object
Generates 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.Comparator
comparator_
private int
iseq_
private java.lang.String
prefix_
-
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.Comparator
getComparator()
Returns a comparator which will order the IDs generated by this object in generation sequence.private java.lang.Integer
getIndex(java.lang.String id)
Returns an Integer giving the sequence index of the given id string.boolean
hasUsed(java.lang.String id)
Indicates whether a given client ID has previously been dispensed by this object.java.lang.String
next()
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. Ifid
does 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
-
-