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

org.opencms.acacia.shared.CmsEntityAttribute 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 (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, 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.acacia.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Serializable entity attribute implementation.

*/ public class CmsEntityAttribute implements Serializable { /** Serial version id. */ private static final long serialVersionUID = 8283921354261037725L; /** The complex type values. */ private List m_entityValues; /** The attribute name. */ private String m_name; /** The simple type values. */ private List m_simpleValues; /** * Constructor. For serialization only.

*/ protected CmsEntityAttribute() { } /** * Creates a entity type attribute.

* * @param name the attribute name * @param values the attribute values * * @return the newly created attribute */ public static CmsEntityAttribute createEntityAttribute(String name, List values) { CmsEntityAttribute result = new CmsEntityAttribute(); result.m_name = name; result.m_entityValues = Collections.unmodifiableList(values); return result; } /** * Creates a simple type attribute.

* * @param name the attribute name * @param values the attribute values * * @return the newly created attribute */ public static CmsEntityAttribute createSimpleAttribute(String name, List values) { CmsEntityAttribute result = new CmsEntityAttribute(); result.m_name = name; result.m_simpleValues = Collections.unmodifiableList(values); return result; } /** * Returns the attribute name.

* * @return the attribute name */ public String getAttributeName() { return m_name; } /** * Returns the first complex value in the list.

* * @return the first complex value */ public CmsEntity getComplexValue() { return m_entityValues.get(0); } /** * Returns the list of complex values.

* * @return the list of complex values */ public List getComplexValues() { List result = new ArrayList(); result.addAll(m_entityValues); return Collections.unmodifiableList(result); } /** * Returns the first simple value in the list.

* * @return the first simple value */ public String getSimpleValue() { return m_simpleValues.get(0); } /** * Returns the list of simple values.

* * @return the list of simple values */ public List getSimpleValues() { return Collections.unmodifiableList(m_simpleValues); } /** * Returns the number of values set for this attribute.

* * @return the number of values */ public int getValueCount() { if (isComplexValue()) { return m_entityValues.size(); } return m_simpleValues.size(); } /** * Returns if the is a complex type value.

* * @return true if this is a complex type value */ public boolean isComplexValue() { return m_entityValues != null; } /** * Returns if the is a simple type value.

* * @return true if this is a simple type value */ public boolean isSimpleValue() { return m_simpleValues != null; } /** * Returns if this is a single value attribute.

* * @return true if this is a single value attribute */ public boolean isSingleValue() { if (isComplexValue()) { return m_entityValues.size() == 1; } return m_simpleValues.size() == 1; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy