private Object handleElement()

in commons-jcs3-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java [718:774]


    private Object handleElement(final LateralElementDescriptor<K, V> led) throws IOException
    {
        final String cacheName = led.getPayload().getCacheName();
        final K key = led.getPayload().getKey();
        Object obj = null;

        switch (led.getCommand())
        {
            case UPDATE:
                handlePut(led.getPayload());
                break;

            case REMOVE:
                // if a hash code was given and filtering is on
                // check to see if they are the same
                // if so, then don't remove, otherwise issue a remove
                if (led.getValHashCode() != -1 &&
                    getTcpLateralCacheAttributes().isFilterRemoveByHashCode())
                {
                    final ICacheElement<K, V> test = getCache( cacheName ).localGet( key );
                    if ( test != null )
                    {
                        if ( test.getVal().hashCode() == led.getValHashCode() )
                        {
                            log.debug( "Filtering detected identical hashCode [{0}], "
                                    + "not issuing a remove for led {1}",
                                    led.getValHashCode(), led );
                            return null;
                        }
                        log.debug( "Different hash codes, in cache [{0}] sent [{1}]",
                                test.getVal()::hashCode, led::getValHashCode );
                    }
                }
                handleRemove( cacheName, key );
                break;

            case REMOVEALL:
                handleRemoveAll( cacheName );
                break;

            case GET:
                obj = handleGet( cacheName, key );
                break;

            case GET_MATCHING:
                obj = handleGetMatching( cacheName, (String) key );
                break;

            case GET_KEYSET:
                obj = handleGetKeySet(cacheName);
                break;

            default: break;
        }

        return obj;
    }