1 31 32 package org.opencms.workplace.list; 33 34 import org.opencms.main.CmsIllegalArgumentException; 35 import org.opencms.util.CmsStringUtil; 36 37 import java.util.HashMap ; 38 import java.util.Map ; 39 40 49 public class CmsListItem { 50 51 52 private final String m_id; 53 54 55 private final CmsListMetadata m_metadata; 56 57 58 private final Map m_values = new HashMap (); 59 60 66 public CmsListItem(CmsListMetadata metadata, String id) { 67 68 if (CmsStringUtil.isEmptyOrWhitespaceOnly(id)) { 69 throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_LIST_INVALID_NULL_ARG_1, "id")); 70 } 71 if (metadata == null) { 72 throw new CmsIllegalArgumentException(Messages.get().container( 73 Messages.ERR_LIST_INVALID_NULL_ARG_1, 74 "metadata")); 75 } 76 m_metadata = metadata; 77 m_id = id; 78 } 79 80 89 public Object get(String columnId) throws CmsIllegalArgumentException { 90 91 if (getMetadata().getColumnDefinition(columnId) == null 92 && getMetadata().getItemDetailDefinition(columnId) == null) { 93 throw new CmsIllegalArgumentException( 94 Messages.get().container(Messages.ERR_LIST_INVALID_COLUMN_1, columnId)); 95 } 96 return m_values.get(columnId); 97 } 98 99 106 public String getId() { 107 108 return m_id; 109 } 110 111 116 public CmsListMetadata getMetadata() { 117 118 return m_metadata; 119 } 120 121 131 public Object set(String columnId, Object value) throws CmsIllegalArgumentException { 132 133 if (getMetadata().getColumnDefinition(columnId) == null 134 && getMetadata().getItemDetailDefinition(columnId) == null) { 135 throw new CmsIllegalArgumentException( 136 Messages.get().container(Messages.ERR_LIST_INVALID_COLUMN_1, columnId)); 137 } 138 return m_values.put(columnId, value); 139 } 140 } | Popular Tags |