for (int i = buffer.length - 4; i < buffer.length; i++){ count += ((buffer[i] & 0xff) << shift); shift += 8;
if (buffer.length > 4) { for (int i = buffer.length - 4; i < buffer.length; i++){ count += ((buffer[i] & 0xff) << shift); shift += 8; }
        public void run(){            try {                while (running){                    int op = nextOperation(db);                    switch (op){                        case op_response:                            receiveResponse(db, op);                            break;                        case op_exit:                        case op_disconnect:                            this.close();                            break;                        case op_event:                            int dbHandle = db.in.readInt();                            byte [] buffer = db.in.readBuffer();                            // AST info, can be ignored                            for (int i = 0; i < 8; i++){                                db.in.read();                            }                            int eventId = db.in.readInt();                                                        int count = 0;                            int shift = 0;                            for (int i = buffer.length - 4;                                     i < buffer.length; i++){                                count += ((buffer[i] & 0xff) << shift);                                shift += 8;                            }                            EventGlob glob = null;                            synchronized (globMap){                                glob = (EventGlob)globMap.remove(                                        Integer.toString(eventId));                            }                            if (glob != null){                                glob.getEventHandle().setInternalCount(count);                                glob.getEventHandler().eventOccurred();                            }                            break;                    }                }                                 doClose();            } catch (IOException ioe){                throw new RuntimeException(                        "IOException in event loop: " + ioe.getMessage());            } catch (GDSException gdse){                throw new RuntimeException(                        "GDSException in event loop: " + gdse.getMessage());            }        }