1 18 package org.apache.activemq.transport.stomp; 19 20 import java.util.Arrays ; 21 import java.util.Collections ; 22 import java.util.HashMap ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 import org.apache.activemq.command.Command; 27 import org.apache.activemq.command.Endpoint; 28 import org.apache.activemq.command.Response; 29 import org.apache.activemq.state.CommandVisitor; 30 31 36 public class StompFrame implements Command { 37 38 private static final byte[] NO_DATA = new byte[]{}; 39 40 private String action; 41 private Map headers = Collections.EMPTY_MAP; 42 private byte[] content = NO_DATA; 43 44 public StompFrame(String command, HashMap headers, byte[] data) { 45 this.action = command; 46 this.headers = headers; 47 this.content = data; 48 } 49 50 public StompFrame() { 51 } 52 53 public String getAction() { 54 return action; 55 } 56 57 public void setAction(String command) { 58 this.action = command; 59 } 60 61 public byte[] getContent() { 62 return content; 63 } 64 65 public void setContent(byte[] data) { 66 this.content = data; 67 } 68 69 public Map getHeaders() { 70 return headers; 71 } 72 73 public void setHeaders(Map headers) { 74 this.headers = headers; 75 } 76 77 public int getCommandId() { 81 return 0; 82 } 83 84 public Endpoint getFrom() { 85 return null; 86 } 87 88 public Endpoint getTo() { 89 return null; 90 } 91 92 public boolean isBrokerInfo() { 93 return false; 94 } 95 96 public boolean isMessage() { 97 return false; 98 } 99 100 public boolean isMessageAck() { 101 return false; 102 } 103 104 public boolean isMessageDispatch() { 105 return false; 106 } 107 108 public boolean isMessageDispatchNotification() { 109 return false; 110 } 111 112 public boolean isResponse() { 113 return false; 114 } 115 116 public boolean isResponseRequired() { 117 return false; 118 } 119 120 public boolean isShutdownInfo() { 121 return false; 122 } 123 124 public boolean isWireFormatInfo() { 125 return false; 126 } 127 128 public void setCommandId(int value) { 129 } 130 131 public void setFrom(Endpoint from) { 132 } 133 134 public void setResponseRequired(boolean responseRequired) { 135 } 136 137 public void setTo(Endpoint to) { 138 } 139 140 public Response visit(CommandVisitor visitor) throws Exception { 141 return null; 142 } 143 144 public byte getDataStructureType() { 145 return 0; 146 } 147 148 public boolean isMarshallAware() { 149 return false; 150 } 151 152 public String toString() { 153 StringBuffer buffer = new StringBuffer (); 154 buffer.append(getAction()); 155 buffer.append("\n"); 156 Map headers = getHeaders(); 157 for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) { 158 Map.Entry entry = (Map.Entry ) iter.next(); 159 buffer.append(entry.getKey()); 160 buffer.append(":"); 161 buffer.append(entry.getValue()); 162 buffer.append("\n"); 163 } 164 buffer.append("\n"); 165 if( getContent()!=null ) { 166 try { 167 buffer.append(new String (getContent())); 168 } catch (Throwable e) { 169 buffer.append(Arrays.toString(getContent())); 170 } 171 } 172 return buffer.toString(); 173 } 174 } 175 | Popular Tags |