gnu.x11
Class MessageFactory

java.lang.Object
  extended by gnu.x11.MessageFactory

public class MessageFactory
extends java.lang.Object

Build X Error, X Event, and X Reply from input stream. Although both are incoming packets from X server to us, Reply and Event (and Error) are quite different in nature and thus treated very differently in this libraray. Event packets are of fixed length and can be easily constructed. However, events are exposed to the users of this library. Therefore, the interface to events of different types should be as accessible as possible. This leads us to dynamically construct events of specific and correct event types so that users can simply cast the return it and use it. Moreover, almost all events contain id to other objects such as Window and Atom, it makes sense to keep an Display reference in event so that those objects can be intern easily later. Another complication for event are extension events. Extension events are registered during querying and setting up extension. The information will be stored in the array Display.extension_event_factories. When an extension event arrive, a particular factory in the array will be called to construct and return an extension event object. Reply, on the other hand, are of various length and the reply length field must be inspected to construct packets correctly. However, reply packets are used soely inside this library. Therefore, only a minimum interface is supported as developers of this libraray should be familiar with details of the protocol and reply packets. If the packets are to be exposed to users of this library, clean interfaces such as Display.ExtensionReply and Fontable.FontReply should be provided.


Constructor Summary
MessageFactory()
           
 
Method Summary
static Error build_connection_error(Display display)
           
static Event build_core_event(Display display, byte[] data, int code)
           
static Error build_error(Display display)
           
static Event build_event(Display display, int code)
           
static Error build_extension_error(Display display, Data data, int code, int seq_no, int bad, int minor_opcode, int major_opcode)
           
static Event build_extension_event(Display display, byte[] data, int code)
           
static Data build_reply(Display display)
           
static Data build(Display display)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageFactory

public MessageFactory()
Method Detail

build_connection_error

public static Error build_connection_error(Display display)
                                    throws java.io.IOException
Throws:
java.io.IOException

build_error

public static Error build_error(Display display)
                         throws java.io.IOException
Throws:
java.io.IOException

build_event

public static Event build_event(Display display,
                                int code)
                         throws java.io.IOException
Throws:
java.io.IOException

build_core_event

public static Event build_core_event(Display display,
                                     byte[] data,
                                     int code)

build_extension_error

public static Error build_extension_error(Display display,
                                          Data data,
                                          int code,
                                          int seq_no,
                                          int bad,
                                          int minor_opcode,
                                          int major_opcode)

build_extension_event

public static Event build_extension_event(Display display,
                                          byte[] data,
                                          int code)

build

public static Data build(Display display)
                  throws java.io.IOException
Throws:
java.io.IOException

build_reply

public static Data build_reply(Display display)
                        throws java.io.IOException
Throws:
java.io.IOException