package baseclass;

import p2.pao.Pao;
import p2.pao.PaoField;
import p2.pao.PaoFieldAdapter;
import p2.pao.PaoSetRemote;
import p2.util.P2Exception;

public class PaoFieldAdapterCust extends PaoFieldAdapter {
	public PaoFieldAdapterCust(PaoField field) {
		super(field);
	}

	@Override
	public void action() throws P2Exception {
		super.action();
		if (getPaoField().getPao() instanceof PaoCust) {
			PaoCust cust = (PaoCust) getPaoField().getPao();
			cust.fieldAction(this, getPaoField().getName());
		}
	}

	@Override
	public void validate() throws P2Exception {
		super.validate();
		if (getPaoField().getPao() instanceof PaoCust) {
			PaoCust cust = (PaoCust) getPaoField().getPao();
			cust.fieldValidate(this, getPaoField().getName());
		}
	}

	public Pao getPao() throws P2Exception {
		return getPaoField().getPao();
	}

	public PaoSetRemote getPaoSet(String set) throws P2Exception {
		return getPaoField().getPao().getPaoSet(set);
	}
	@Override
	public PaoSetRemote getList() throws P2Exception {
		if (getPaoField().getPao() instanceof PaoCust) {
			PaoCust cust = (PaoCust) getPaoField().getPao();
			return cust.fieldGetlist(this, super.getList(), getPaoField()
					.getName());
		}
		return super.getList();
	}

	@Override
	public void initValue() throws P2Exception {
		super.initValue();
		if (getPaoField().getPao() instanceof PaoCust) {
			PaoCust cust = (PaoCust) getPaoField().getPao();
			cust.fieldInitValue(this, getPaoField().getName());
		}
	}
}
