1 /*------------------------------------------------------------------------------
 2 Name:      XmlScriptAccess.java
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 ------------------------------------------------------------------------------*/
 6 package org.xmlBlaster.client.activex;
 7 
 8 import org.xmlBlaster.client.key.UpdateKey;
 9 import org.xmlBlaster.client.qos.UpdateQos;
10 import org.xmlBlaster.util.Base64;
11 
12 /**
13  * Event object used to transport a callback message back to ActiveX (C#, VisualBasic). 
14  * @author <a href="mailto:xmlBlaster@marcelruff.info">Marcel Ruff</a>
15  */
16 public class UpdateEvent extends java.util.EventObject {
17    private static final long serialVersionUID = 1386617497220678458L;
18    String cbSessionId;
19    UpdateKey key;
20    byte[] content;
21    UpdateQos qos;
22    public UpdateEvent(Object source, String cbSessionId, UpdateKey key, byte[] content, UpdateQos qos) {
23       super(source);
24       this.cbSessionId = cbSessionId;
25       this.key = key;
26       this.content = content;
27       this.qos = qos;
28    }
29    
30    public String getCbSessionId() {
31       return this.cbSessionId;
32    }
33    
34    public UpdateKey getKey() {
35       return this.key;
36    }
37 
38    /**
39     * NOTE: Passing byte[] seems to be broken with Java bridge! 
40     *
41     * If you have binary data use #getContentBase64() as a work around
42     * you need to decode it yourself in Basic/C#.<br />
43     * If you have a string content (like xml markup) you can call
44     * #getContentStr() directly.
45     *
46     * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4887461
47     */ 
48    public byte[] getContent() {
49       return this.content;
50    }
51 
52    public String getContentStr() {
53       return new String(this.content);
54    }
55 
56    public int getContentLength() {
57       return this.content.length;
58    }
59 
60    /**
61     * Access binary content encoded with Base64. 
62     */
63    public String getContentBase64() {
64       String encoded = Base64.encode(this.content);
65       return encoded;
66    }
67 
68    public UpdateQos getQos() {
69       return this.qos;
70    }
71 }


syntax highlighted by Code2HTML, v. 0.9.1