src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicInstantMessaging.java
/**
     * Transform provided source event by processing transform layers in
     * sequence.
     *
     * @param evt the source event to transform
     * @param eventType the event type of the source event
     * @return returns the resulting (transformed) events, if any. (I.e. an
     *         array of 0 or more size containing events.)
     */
Transform provided source event by processing transform layers in
sequence.

@param evt the source event to transform
@param eventType the event type of the source event
@return returns the resulting (transformed) events, if any.
Transform provided source event by processing transform layers in sequence . @param evt the source event to transform @param eventType the event type of the source event @return returns the resulting ( transformed ) events if any .
private EventObject[] messageTransform(final EventObject evt,
                                           final MessageEventType eventType)
    {
        if (evt == null)
        {
            return new EventObject[0];
        }
        ProtocolProviderService protocolProvider;
        switch (eventType)
        {
        case MessageDelivered:
            protocolProvider
                = ((MessageDeliveredEvent) evt)
                    .getDestinationContact().getProtocolProvider();
            break;
        case MessageDeliveryFailed:
            protocolProvider
                = ((MessageDeliveryFailedEvent) evt)
                    .getDestinationContact().getProtocolProvider();
            break;
        case MessageDeliveryPending:
            protocolProvider
                = ((MessageDeliveredEvent) evt)
                    .getDestinationContact().getProtocolProvider();
            break;
        case MessageReceived:
            protocolProvider
                = ((MessageReceivedEvent) evt)
                    .getSourceContact().getProtocolProvider();
            break;
        default:
            return new EventObject[] {evt};
        }
        OperationSetInstantMessageTransformImpl opSetMessageTransform
            = (OperationSetInstantMessageTransformImpl) protocolProvider
                .getOperationSet(OperationSetInstantMessageTransform.class);
        if (opSetMessageTransform == null)
            return new EventObject[] {evt};
        final LinkedList<EventObject> current = new LinkedList<EventObject>();
        current.add(evt);
        final LinkedList<EventObject> next = new LinkedList<EventObject>();
        for (Map.Entry<Integer, Vector<TransformLayer>> entry
                : opSetMessageTransform.transformLayers.entrySet())
        {
            for (TransformLayer transformLayer : entry.getValue())
            {
                next.clear();
                while (!current.isEmpty())
                {
                    final EventObject event = current.remove();
                    switch (eventType)
                    {
                    case MessageDelivered:
                        MessageDeliveredEvent transformedDelivered =
                            transformLayer.messageDelivered(
                                (MessageDeliveredEvent) event);
                        if (transformedDelivered != null)
                        {
                            next.add(transformedDelivered);
                        }
                        break;
                    case MessageDeliveryPending:
                        MessageDeliveredEvent[] evts = transformLayer
                            .messageDeliveryPending(
                                (MessageDeliveredEvent) event);
                        for (MessageDeliveredEvent mde : evts)
                        {
                            if (mde != null)
                            {
                                next.add(mde);
                            }
                        }
                        break;
                    case MessageDeliveryFailed:
                        MessageDeliveryFailedEvent transformedDeliveryFailed =
                            transformLayer.messageDeliveryFailed(
                                (MessageDeliveryFailedEvent) event);
                        if (transformedDeliveryFailed != null)
                        {
                            next.add(transformedDeliveryFailed);
                        }
                        break;
                    case MessageReceived:
                        MessageReceivedEvent transformedReceived =
                            transformLayer
                                .messageReceived((MessageReceivedEvent) event);
                        if (transformedReceived != null)
                        {
                            next.add(transformedReceived);
                        }
                        break;
                    default:
                        next.add(event);
                        /*
                         * We either have nothing to do or we do not know
                         * what to do. Anyway, we'll silence the compiler.
                         */
                        break;
                    }
                }
                current.addAll(next);
            }
        }
        return current.toArray(new EventObject[current.size()]);
    }
private EventObject [ ] messageTransform ( final EventObject evt , final MessageEventType eventType ) { if ( evt == null ) { return new EventObject [ 0 ] ; } ProtocolProviderService protocolProvider ; switch ( eventType ) { case MessageDelivered : protocolProvider = ( ( MessageDeliveredEvent ) evt ) . getDestinationContact ( ) . getProtocolProvider ( ) ; break ; case MessageDeliveryFailed : protocolProvider = ( ( MessageDeliveryFailedEvent ) evt ) . getDestinationContact ( ) . getProtocolProvider ( ) ; break ; case MessageDeliveryPending : protocolProvider = ( ( MessageDeliveredEvent ) evt ) . getDestinationContact ( ) . getProtocolProvider ( ) ; break ; case MessageReceived : protocolProvider = ( ( MessageReceivedEvent ) evt ) . getSourceContact ( ) . getProtocolProvider ( ) ; break ; default : return new EventObject [ ] { evt } ; } OperationSetInstantMessageTransformImpl opSetMessageTransform = ( OperationSetInstantMessageTransformImpl ) protocolProvider . getOperationSet ( OperationSetInstantMessageTransform . class ) ; if ( opSetMessageTransform == null ) return new EventObject [ ] { evt } ; final LinkedList < EventObject > current = new LinkedList < EventObject > ( ) ; current . add ( evt ) ; final LinkedList < EventObject > next = new LinkedList < EventObject > ( ) ; for ( Map . Entry < Integer , Vector < TransformLayer > > entry : opSetMessageTransform . transformLayers . entrySet ( ) ) { for ( TransformLayer transformLayer : entry . getValue ( ) ) { next . clear ( ) ; while ( ! current . isEmpty ( ) ) { final EventObject event = current . remove ( ) ; switch ( eventType ) { case MessageDelivered : MessageDeliveredEvent transformedDelivered = transformLayer . messageDelivered ( ( MessageDeliveredEvent ) event ) ; if ( transformedDelivered != null ) { next . add ( transformedDelivered ) ; } break ; case MessageDeliveryPending : MessageDeliveredEvent [ ] evts = transformLayer . messageDeliveryPending ( ( MessageDeliveredEvent ) event ) ; for ( MessageDeliveredEvent mde : evts ) { if ( mde != null ) { next . add ( mde ) ; } } break ; case MessageDeliveryFailed : MessageDeliveryFailedEvent transformedDeliveryFailed = transformLayer . messageDeliveryFailed ( ( MessageDeliveryFailedEvent ) event ) ; if ( transformedDeliveryFailed != null ) { next . add ( transformedDeliveryFailed ) ; } break ; case MessageReceived : MessageReceivedEvent transformedReceived = transformLayer . messageReceived ( ( MessageReceivedEvent ) event ) ; if ( transformedReceived != null ) { next . add ( transformedReceived ) ; } break ; default : next . add ( event ) ; /*
                         * We either have nothing to do or we do not know
                         * what to do. Anyway, we'll silence the compiler.
                         */ break ; } } current . addAll ( next ) ; } } return current . toArray ( new EventObject [ current . size ( ) ] ) ; }
Transform provided source event by processing transform layers in
 sequence.
Transform provided source event by processing transform layers in sequence .
// 'current' contains the events that need to be transformed. It should // not contain null values. // Add source event as start of transformation. // 'next' contains the resulting events after transformation in the // current iteration. It should not contain null values. // Set events for next round of transformations.