package com.brilliance.mda.runtime.mda.impl;

import com.brilliance.mda.runtime.mda.IStream;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * IStream 代理类
 */
public class StreamProxy extends DataGrid implements IStream {
    private IStream source;

    public StreamProxy() {

    }

    public StreamProxy(IStream source) {
        this.source = source;
    }

    public void setSource(IStream source) {
        this.source = source;
    }

    @Override
    public InputStream getInputStream() {
        if (source != null)
            return source.getInputStream();
        return null;
    }

    @Override
    public OutputStream getOutputStream() {
        if (source != null)
            return source.getOutputStream();
        return null;
    }

    @Override
    public void close() {
        if (source != null)
            source.close();
    }

    @Override
    public boolean isEmpty() {
        if (source != null)
            return source.isEmpty();
        return false;
    }

    @Override
    public void setType(String type) {
        if (source != null)
            source.setType(type);
    }

    @Override
    public String getType() {
        if (source != null)
            return source.getType();
        return null;
    }

    @Override
    public void setName(String name) {
        if (source != null)
            source.setName(name);
    }

    @Override
    public String getName() {
        if (source != null)
            return source.getName();
        return null;
    }

    @Override
    public String setValue(String value) {
        if (source != null)
            return source.setValue(value);
        return value;
    }

    @Override
    public String getValue() {
        if (source != null)
            return source.getValue();
        return null;
    }
}
