All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.xml.containerpage.CmsContainerPageBean Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH & Co. KG, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.xml.containerpage;

import org.opencms.util.CmsCollectionsGenericWrapper;
import org.opencms.util.CmsUUID;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.Transformer;

/**
 * Describes one locale of a container page.

* * @since 8.0 */ public class CmsContainerPageBean { /** The containers. */ private final Map m_containers; /** A lazy initialized map that describes if a certain element if part of this container. */ private transient Map m_containsElement; /** The id's of of all elements in this page. */ private transient List m_elementIds; /** The container elements. */ private transient List m_elements; /** The container names in the right order. */ private final List m_names; /** The supported types. */ private final Set m_types; /** * Creates a new container page bean.

* * @param containers the containers **/ public CmsContainerPageBean(List containers) { // we want to preserve container order Map cnts = new LinkedHashMap(); Set types = new HashSet(); List names = new ArrayList(); for (CmsContainerBean container : containers) { cnts.put(container.getName(), container); types.add(container.getType()); names.add(container.getName()); } m_containers = Collections.unmodifiableMap(cnts); m_types = Collections.unmodifiableSet(types); m_names = Collections.unmodifiableList(names); } /** * Returns true if the element with the provided id is contained in this container.

* * @param elementId the element id to check * * @return true if the element with the provided id is contained in this container */ public boolean containsElement(CmsUUID elementId) { return getElementIds().contains(elementId); } /** * Returns all container of this page.

* * @return all container of this page */ public Map getContainers() { return m_containers; } /** * Returns a lazy initialized map that describes if a certain element if part of this container.

* * @return a lazy initialized map that describes if a certain element if part of this container */ public Map getContainsElement() { if (m_containsElement == null) { m_containsElement = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() { public Object transform(Object input) { return Boolean.valueOf(containsElement((CmsUUID)input)); } }); } return m_containsElement; } /** * Returns the id's of all elements in this container.

* * @return the id's of all elements in this container */ public List getElementIds() { if (m_elementIds == null) { m_elementIds = new ArrayList(getElements().size()); for (CmsContainerElementBean element : getElements()) { m_elementIds.add(element.getId()); } } return m_elementIds; } /** * Returns the elements of all containers in this page.

* * @return the elements of all containers in this page */ public List getElements() { if (m_elements == null) { m_elements = new ArrayList(); for (CmsContainerBean container : m_containers.values()) { m_elements.addAll(container.getElements()); } } return m_elements; } /** * Returns the list of container names.

* * @return the list of container names */ public List getNames() { return m_names; } /** * Returns the types.

* * @return the types */ public Set getTypes() { return m_types; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy