001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     <a href="mailto:grenard@nuxeo.com">Guillaume</a>
018 */
019package org.nuxeo.ecm.platform.sessioninspector.jsf.model;
020
021import java.util.Map;
022
023import javax.el.ValueExpression;
024
025import org.nuxeo.ecm.platform.ui.web.binding.alias.AliasVariableMapper;
026import org.nuxeo.runtime.javaagent.AgentLoader;
027
028/**
029 * @since 5.9.2
030 */
031public class UIAliasHolderWrapper extends UIComponentWrapper {
032
033    protected final AliasVariableMapper mapper;
034
035    public UIAliasHolderWrapper(String id, Object[] object) {
036        super(id, object);
037        mapper = (AliasVariableMapper) object[2];
038    }
039
040    @SuppressWarnings("boxing")
041    public Long getAliasVariableMapperSize() {
042        return AgentLoader.INSTANCE.getSizer().deepSizeOf(mapper.getVariables()) / 8;
043    }
044
045    public String getAliasId() {
046        if (mapper != null) {
047            return mapper.getId();
048        }
049        return null;
050    }
051
052    public Map<String, ValueExpression> getVariables() {
053        if (mapper != null) {
054            return mapper.getVariables();
055        }
056        return null;
057    }
058
059}