001/*
002 * (C) Copyright 2014 Nuxeo SA (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-2.1.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 *     <a href="mailto:grenard@nuxeo.com">Guillaume</a>
016 */
017package org.nuxeo.ecm.platform.sessioninspector.jsf.model;
018
019import java.util.Map;
020
021import javax.el.ValueExpression;
022
023import org.nuxeo.ecm.platform.ui.web.binding.alias.AliasVariableMapper;
024import org.nuxeo.runtime.javaagent.AgentLoader;
025
026/**
027 * @since 5.9.2
028 */
029public class UIAliasHolderWrapper extends UIComponentWrapper {
030
031    protected final AliasVariableMapper mapper;
032
033    public UIAliasHolderWrapper(String id, Object[] object) {
034        super(id, object);
035        mapper = (AliasVariableMapper) object[2];
036    }
037
038    @SuppressWarnings("boxing")
039    public Long getAliasVariableMapperSize() {
040        return AgentLoader.INSTANCE.getSizer().deepSizeOf(mapper.getVariables()) / 8;
041    }
042
043    public String getAliasId() {
044        if (mapper != null) {
045            return mapper.getId();
046        }
047        return null;
048    }
049
050    public Map<String, ValueExpression> getVariables() {
051        if (mapper != null) {
052            return mapper.getVariables();
053        }
054        return null;
055    }
056
057}