Package net.targetr.rc.util
Class IdGen
java.lang.Object
net.targetr.rc.util.IdGen
Generates new IDs for rooms and clients.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGenerates a new random client ID.static StringGenerates a new random room ID.static booleanAccepts client IDs of exactly eight ASCII letters, digits or hyphens.static booleanisValidRoomId(String id) Accepts room IDs of 4 to 11 ASCII letters, digits or hyphens.
-
Constructor Details
-
IdGen
public IdGen()Constructs a new IdGen.
-
-
Method Details
-
createClientId
Generates a new random client ID. The ID format is XXXXXXXX where X represents a character from the allowed set.- Returns:
- a new randomly generated string representing a client ID
-
createRoomId
Generates a new random room ID. The ID format is XXXX-XXXX where X represents a character from the allowed set.- Returns:
- a new randomly generated string representing a room ID
-
isValidRoomId
Accepts room IDs of 4 to 11 ASCII letters, digits or hyphens. Validation permits custom IDs beyond the generatedXXXX-XXXXformat.- Parameters:
id- the string to validate- Returns:
- true if the non-null ID has an accepted length and characters
-
isValidClientId
Accepts client IDs of exactly eight ASCII letters, digits or hyphens.- Parameters:
id- the string to validate- Returns:
- true if the non-null ID has an accepted length and characters
-