001/*
002 * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: ProtectedEditableModelImpl.java 21685 2007-06-30 21:02:58Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.ui.web.model.impl;
021
022import javax.el.ValueExpression;
023
024import org.nuxeo.ecm.platform.ui.web.model.EditableModel;
025import org.nuxeo.ecm.platform.ui.web.model.ProtectedEditableModel;
026
027/**
028 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
029 */
030public class ProtectedEditableModelImpl implements ProtectedEditableModel {
031
032    protected final EditableModel delegate;
033
034    protected final ProtectedEditableModel parent;
035
036    protected final ValueExpression binding;
037
038    public ProtectedEditableModelImpl(EditableModel delegate, ProtectedEditableModel parent, ValueExpression binding) {
039        this.delegate = delegate;
040        this.parent = parent;
041        this.binding = binding;
042    }
043
044    @Override
045    public int getRowCount() {
046        return delegate.getRowCount();
047    }
048
049    @Override
050    public Object getRowData() {
051        return delegate.getRowData();
052    }
053
054    @Override
055    public int getRowIndex() {
056        return delegate.getRowIndex();
057    }
058
059    @Override
060    public void setRowData(Object rowData) {
061        delegate.setRowData(rowData);
062    }
063
064    @Override
065    public boolean isRowNew() {
066        return delegate.isRowNew();
067    }
068
069    @Override
070    public ValueExpression getBinding() {
071        return binding;
072    }
073
074    @Override
075    public ProtectedEditableModel getParent() {
076        return parent;
077    }
078
079    @Override
080    public String toString() {
081        final StringBuilder buf = new StringBuilder();
082        buf.append(ProtectedEditableModelImpl.class.getSimpleName());
083        buf.append(" {");
084        buf.append(" binding=");
085        buf.append(binding);
086        buf.append(", delegate=");
087        buf.append(delegate);
088        buf.append(", parent=");
089        buf.append(parent);
090        buf.append('}');
091        return buf.toString();
092    }
093
094}