| Home >> All >> org >> zazof >> [ jteg Javadoc ] |
Source code: org/zazof/jteg/InformationMessage.java
1 /** 2 * Internal Message that can be used for informationpassing. 3 * It will listen to the "virtual" events "internalInfo=". 4 * Note that this message is not part of the tegprotocol, and will 5 * not be send by the tegserver. 6 * 7 * This message is valid for following protocols: 8 * version 3: N/A: Internal Message 9 * version 4: N/A: Internal Message 10 * version 5: N/A: Internal Message 11 * 12 * Content = "internalInfo=informationToBePassed" 13 * 14 * @author Jef De Geeter 15 * @author Yves Vandewoude 16 */ 17 18 19 package org.zazof.jteg; 20 21 import java.util.StringTokenizer; 22 23 public class InformationMessage extends Message{ 24 25 public InformationMessage(Message nextMessage){ 26 setNextMessage(nextMessage); 27 } 28 29 30 public Message decodeMessage(String messageDescription) 31 throws UnknownMessageException 32 { 33 String firstToken = (new StringTokenizer(messageDescription,"=")).nextToken(); 34 if (!(firstToken.equals("internalinfo"))) 35 { 36 // Not for me... 37 if (this.hasNextMessage()) 38 { 39 return getNextMessage().decodeMessage(messageDescription); 40 } 41 throw new UnknownMessageException(messageDescription); 42 } 43 else 44 { 45 StringTokenizer st = new StringTokenizer(messageDescription, "=,"); 46 st.nextToken(); //internalInfo 47 $info = st.nextToken(); 48 return this; 49 } 50 } 51 52 public String constructMessageString(String[] messageParts) 53 throws UnknownMessageException 54 { 55 if (!(messageParts[0]).equals("internalinfo")) 56 { 57 // Not for me... 58 if (this.hasNextMessage()) 59 { 60 return getNextMessage().constructMessageString(messageParts); 61 } 62 throw new UnknownMessageException("No String could be constructed for a message with this parameter: " + messageParts[0]); 63 } 64 else 65 { 66 return ("internalinfo=" + messageParts[1]); 67 } 68 } 69 70 71 public String getMessageName(){ 72 return "internalinfo"; 73 } 74 75 public String getInfo(){ 76 return $info; 77 } 78 79 private String $info; 80 }