Package de.spotnik.gpl.provider.treeutil

Examples of de.spotnik.gpl.provider.treeutil.StatusEvent


            int count = 1;
            String line, fromLine = null;
            ByteArrayOutputStream buf = null;
           
            // notify listeners
            StatusEvent event;
            event = new StatusEvent(mstore, StatusEvent.OPERATION_START, "open");
            mstore.processStatusEvent(event);
           
            for( line = in.readLine(); line != null; line = in.readLine())
            {
                if( line.indexOf(FROM) == 0)
                {
                    if( buf != null)
                    {
                        byte[] bytes = buf.toByteArray();
                        ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
                        MboxMessage m = new MboxMessage(this, fromLine, bin, count++);
                        acc.add(m);
                       
                        event = new StatusEvent(mstore, StatusEvent.OPERATION_UPDATE, "open", 1, StatusEvent.UNKNOWN,
                                                count - 1);
                        mstore.processStatusEvent(event);
                    }
                    fromLine = line;
                    buf = new ByteArrayOutputStream();
                }
                else if( buf != null)
                {
                    byte[] bytes = decodeFrom(line).getBytes();
                    buf.write(bytes, 0, bytes.length);
                    buf.write(10); // LF
                }
            }
            if( buf != null)
            {
                byte[] bytes = buf.toByteArray();
                ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
                MboxMessage m = new MboxMessage(this, fromLine, bin, count++);
                acc.add(m);
               
                event = new StatusEvent(mstore, StatusEvent.OPERATION_UPDATE, "open", 1, StatusEvent.UNKNOWN, count - 1);
                mstore.processStatusEvent(event);
            }
            this.messages = new MboxMessage[acc.size()];
            acc.toArray(this.messages);
            buf = null;
            acc = null;
           
            event = new StatusEvent(mstore, StatusEvent.OPERATION_END, "open");
            mstore.processStatusEvent(event);
           
            // OK
            this.open = true;
            notifyConnectionListeners(ConnectionEvent.OPENED);
View Full Code Here


           
            if( !this.readOnly)
            {
                // Save messages
                MboxStore mstore = (MboxStore) this.store;
                StatusEvent event;
                log.debug("saving " + this.file.getAbsolutePath());
                synchronized( this)
                {
                    OutputStream os = null;
                    try
                    {
                        os = getOutputStream();
                        BufferedOutputStream bos = new BufferedOutputStream(os);
                        MboxOutputStream mos = new MboxOutputStream(bos);
                       
                        event = new StatusEvent(mstore, StatusEvent.OPERATION_START, "close");
                        mstore.processStatusEvent(event);
                        for( int i = 0; i < this.messages.length; i++)
                        {
                            String fromLine = fromLine(this.messages[i]);
                            bos.write(fromLine.getBytes());
                            bos.write('\n');
                            bos.flush();
                            this.messages[i].writeTo(mos);
                            mos.flush();
                           
                            event = new StatusEvent(mstore, StatusEvent.OPERATION_UPDATE, "close", 1,
                                                    this.messages.length, i + 1);
                            mstore.processStatusEvent(event);
                        }
                       
                        event = new StatusEvent(mstore, StatusEvent.OPERATION_END, "close");
                        mstore.processStatusEvent(event);
                    }
                    catch( IOException e)
                    {
                        throw new MessagingException("I/O error writing mailbox", e);
View Full Code Here

TOP

Related Classes of de.spotnik.gpl.provider.treeutil.StatusEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.