001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (C) Alkacon Software (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.acacia.client.export; 029 030import org.opencms.acacia.shared.CmsEntity; 031import org.opencms.acacia.shared.CmsEntityAttribute; 032 033import java.util.List; 034 035/** 036 * Utility class with helper methods for wrapping objects.<p> 037 */ 038public final class CmsWrapperUtils { 039 040 /** 041 * Hiding constructor.<p> 042 */ 043 private CmsWrapperUtils() { 044 045 // nothing to do 046 } 047 048 /** 049 * Creates an array of entity attribute wrappers for a list of entity attributes.<p> 050 * 051 * @param attributes the list of attributes 052 * @return the array of attribute wrappers 053 */ 054 public static CmsEntityAttributeWrapper[] arrayFromEntityAttributeList(List<CmsEntityAttribute> attributes) { 055 056 CmsEntityAttributeWrapper[] result = new CmsEntityAttributeWrapper[attributes.size()]; 057 for (int i = 0; i < attributes.size(); i++) { 058 result[i] = new CmsEntityAttributeWrapper(attributes.get(i)); 059 } 060 return result; 061 } 062 063 /** 064 * Creates an array of entity wrappers for a list of entities.<p> 065 * 066 * @param entities the list of entities 067 * @return the array of entity wrappers 068 */ 069 public static CmsEntityWrapper[] arrayFromEntityList(List<CmsEntity> entities) { 070 071 CmsEntityWrapper[] result = new CmsEntityWrapper[entities.size()]; 072 for (int i = 0; i < entities.size(); i++) { 073 result[i] = new CmsEntityWrapper(entities.get(i)); 074 } 075 return result; 076 } 077 078 /** 079 * Converts a list of strings to an array.<p> 080 * 081 * @param strings the string list 082 * 083 * @return the array of strings 084 */ 085 public static String[] arrayFromStringList(List<String> strings) { 086 087 String[] result = new String[strings.size()]; 088 for (int i = 0; i < strings.size(); i++) { 089 result[i] = strings.get(i); 090 } 091 return result; 092 } 093 094}