org.opencms.acacia.client.export.CmsWrapperUtils Maven / Gradle / Ivy
Show all versions of opencms-gwt Show documentation
/*
* 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.client.export;
import org.opencms.acacia.shared.CmsEntity;
import org.opencms.acacia.shared.CmsEntityAttribute;
import java.util.List;
/**
* Utility class with helper methods for wrapping objects.
*/
public final class CmsWrapperUtils {
/**
* Hiding constructor.
*/
private CmsWrapperUtils() {
// nothing to do
}
/**
* Creates an array of entity attribute wrappers for a list of entity attributes.
*
* @param attributes the list of attributes
* @return the array of attribute wrappers
*/
public static CmsEntityAttributeWrapper[] arrayFromEntityAttributeList(List attributes) {
CmsEntityAttributeWrapper[] result = new CmsEntityAttributeWrapper[attributes.size()];
for (int i = 0; i < attributes.size(); i++) {
result[i] = new CmsEntityAttributeWrapper(attributes.get(i));
}
return result;
}
/**
* Creates an array of entity wrappers for a list of entities.
*
* @param entities the list of entities
* @return the array of entity wrappers
*/
public static CmsEntityWrapper[] arrayFromEntityList(List entities) {
CmsEntityWrapper[] result = new CmsEntityWrapper[entities.size()];
for (int i = 0; i < entities.size(); i++) {
result[i] = new CmsEntityWrapper(entities.get(i));
}
return result;
}
/**
* Converts a list of strings to an array.
*
* @param strings the string list
*
* @return the array of strings
*/
public static String[] arrayFromStringList(List strings) {
String[] result = new String[strings.size()];
for (int i = 0; i < strings.size(); i++) {
result[i] = strings.get(i);
}
return result;
}
}