001/*
002 * jPOS Project [http://jpos.org]
003 * Copyright (C) 2000-2026 jPOS Software SRL
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jpos.space;
020
021/**
022 * Intercepts space operations.
023 *
024 * @author Alejandro Revilla
025 * @since  1.4.7
026
027 * @param <K> the key type
028 * @param <V> the value type
029 */
030public class SpaceInterceptor<K,V> implements Space<K,V> {
031    /** Underlying space delegated to by every operation. */
032    protected Space<K,V> sp;
033    /**
034     * Constructs an interceptor wrapping the given space.
035     *
036     * @param sp space to delegate to
037     */
038    public SpaceInterceptor (Space<K,V> sp) {
039        super();
040        this.sp = sp;
041    }
042    public void out (K key, V value) {
043        sp.out (key, value);
044    }
045    public void out (K key, V value, long timeout) {
046        sp.out (key, value, timeout);
047    }
048    public void push (K key, V value) {
049        sp.push (key, value);
050    }
051    public void push (K key, V value, long timeout) {
052        sp.push (key, value, timeout);
053    }
054    public void put (K key, V value) {
055        sp.put (key, value);
056    }
057    public void put (K key, V value, long timeout) {
058        sp.put (key, value, timeout);
059    }    
060    public V in  (K key) {
061        return sp.in (key);
062    }
063    public V rd  (K key) {
064        return sp.rd (key);
065    }
066    public V in  (K key, long timeout) {
067        return sp.in (key, timeout);
068    }
069    public V rd  (K key, long timeout) {
070        return sp.rd (key, timeout);
071    }
072    public V inp (K key) {
073        return sp.inp (key);
074    }
075    public V rdp (K key) {
076        return sp.rdp (key);
077    }
078    @Override
079    public void nrd(K key) {
080        sp.nrd(key);
081    }
082    @Override
083    public V nrd(K key, long timeout) {
084        return sp.nrd(key, timeout);
085    }
086
087    public boolean existAny (K[] keys) {
088        return sp.existAny (keys);
089    }
090    public boolean existAny (K[] keys, long timeout) {
091        return sp.existAny (keys, timeout);
092    }
093}