1 11 12 package org.jivesoftware.messenger.spi; 13 14 import org.jivesoftware.messenger.StreamID; 15 import org.jivesoftware.messenger.StreamIDFactory; 16 import java.util.Random ; 17 18 24 public class BasicStreamIDFactory implements StreamIDFactory { 25 26 29 Random random = new Random (); 30 31 public StreamID createStreamID() { 32 return new BasicStreamID(Integer.toHexString(random.nextInt())); 33 } 34 35 public StreamID createStreamID(String name) { 36 return new BasicStreamID(name); 37 } 38 39 private class BasicStreamID implements StreamID { 40 String id; 41 42 public BasicStreamID(String id) { 43 this.id = id; 44 } 45 46 public String getID() { 47 return id; 48 } 49 50 public String toString() { 51 return id; 52 } 53 54 public int hashCode() { 55 return id.hashCode(); 56 } 57 } 58 } 59 | Popular Tags |