001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.core.write;
021
022import java.net.SocketAddress;
023
024import org.apache.mina.core.future.WriteFuture;
025
026/**
027 * A wrapper for an existing {@link WriteRequest}.
028 *
029 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
030 */
031public class WriteRequestWrapper implements WriteRequest {
032
033    private final WriteRequest parentRequest;
034
035    /**
036     * Creates a new instance that wraps the specified request.
037     * 
038     * @param parentRequest The parent's request
039     */
040    public WriteRequestWrapper(WriteRequest parentRequest) {
041        if (parentRequest == null) {
042            throw new IllegalArgumentException("parentRequest");
043        }
044        this.parentRequest = parentRequest;
045    }
046
047    /**
048     * {@inheritDoc}
049     */
050    public SocketAddress getDestination() {
051        return parentRequest.getDestination();
052    }
053
054    /**
055     * {@inheritDoc}
056     */
057    public WriteFuture getFuture() {
058        return parentRequest.getFuture();
059    }
060
061    /**
062     * {@inheritDoc}
063     */
064    public Object getMessage() {
065        return parentRequest.getMessage();
066    }
067
068    /**
069     * {@inheritDoc}
070     */
071    public WriteRequest getOriginalRequest() {
072        return parentRequest.getOriginalRequest();
073    }
074
075    /**
076     * @return the wrapped request object.
077     */
078    public WriteRequest getParentRequest() {
079        return parentRequest;
080    }
081
082    /**
083     * {@inheritDoc}
084     */
085    @Override
086    public String toString() {
087        return "WR Wrapper" + parentRequest.toString();
088    }
089
090    /**
091     * {@inheritDoc}
092     */
093    public boolean isEncoded() {
094        return false;
095    }
096}