package com.jscape.inet.ftp;

import com.jscape.util.Assert;

/**
 * @author Alex
 * @version 1.0
 * @see <a href="FtpProtocolInterpreter.java.html">Source code</a>
 */
final class FtpProtocolInterpreter
        implements ClientProtocolInterpreter {

    private FtpBaseImplementation implementation;

    /**
     * Creates a new interpreter instance.
     *
     * @param implementation implementation
     */
    FtpProtocolInterpreter(FtpBaseImplementation implementation) {
        Assert.notNull(implementation);
        this.implementation = implementation;
    }

    /**
     * Returns implementation.
     *
     * @return implementation
     */
    public FtpBaseImplementation getImplementation() {
        return this.implementation;
    }

    /**
     * @see ClientProtocolInterpreter#sendCommand(String)
     */
    public void sendCommand(String command)
            throws FtpException {
        this.implementation.sendCommand(command);
    }

    /**
     * @see com.jscape.inet.ftp.ClientProtocolInterpreter#receiveReply()
     */
    public String receiveReply()
            throws FtpException {
        this.implementation.readResponse();
        return this.implementation.getResponse();
    }

}
