001 /* 002 * ---------------------------------------------------------------------- 003 * Copyright (C) 2009 Enrique Lara (k957@68k.org) 004 * 005 * TinLizard is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public License 007 * as published by the Free Software Foundation; either version 3.0 008 * of the License, or (at your option) any later version. 009 * 010 * TinLizard is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with TinLizard. If not, see http://www.gnu.org/licenses/. 017 * ---------------------------------------------------------------------- 018 */ 019 package tinlizard.web; 020 021 import tinlizard.model.CurrentUser; 022 023 import tinlizard.util.Messages; 024 025 import java.util.ArrayList; 026 import java.util.Collection; 027 import java.util.Date; 028 import java.util.Iterator; 029 030 import org.jvnet.localizer.Localizable; 031 032 /** 033 * Bass Class for Web Accessible Collections. 034 */ 035 @SuppressWarnings("unchecked") 036 public abstract class ObjectCollectionWeb extends ObjectWeb<Collection<Object>> implements Collection<ObjectWeb> { 037 private final String name; 038 private final Collection<Object> subject; 039 private final Collection<ObjectWeb> delegate; 040 private final Date created; 041 private final String createdBy; 042 043 /** 044 * @deprecated 045 */ 046 ObjectCollectionWeb(final String name) { 047 this.name = name; 048 this.subject = new ArrayList<Object>(); 049 this.delegate = new ArrayList<ObjectWeb>(); 050 this.created = new Date(); 051 this.createdBy = Messages.SYSTEM(); 052 } 053 054 ObjectCollectionWeb(final Localizable name) { 055 this.name = name.toString(CurrentUser.getLocale()); 056 this.subject = new ArrayList<Object>(); 057 this.delegate = new ArrayList<ObjectWeb>(); 058 this.created = new Date(); 059 this.createdBy = Messages.SYSTEM(); 060 } 061 062 @Override 063 public String getName() { 064 return name; 065 } 066 067 @Override 068 protected final Collection<Object> getSubject() { 069 return subject; 070 } 071 072 protected final Collection<ObjectWeb> getDelegate() { 073 return delegate; 074 } 075 076 public final Date getCreated() { 077 return this.created; 078 } 079 080 public final String getCreatedBy() { 081 return this.createdBy; 082 } 083 084 public final Date getLastModified() { 085 return getCreated(); 086 } 087 088 public final String getLastModifiedBy() { 089 return getCreatedBy(); 090 } 091 092 public final boolean add(final ObjectWeb o) { 093 return delegate.add(o); 094 } 095 096 public final boolean addAll(final Collection<?extends ObjectWeb> c) { 097 return delegate.addAll(c); 098 } 099 100 public final void clear() { 101 delegate.clear(); 102 } 103 104 public final boolean contains(final Object o) { 105 return delegate.contains(o); 106 } 107 108 public final boolean containsAll(final Collection<?> c) { 109 return delegate.containsAll(c); 110 } 111 112 public final boolean isEmpty() { 113 return delegate.isEmpty(); 114 } 115 116 public final Iterator<ObjectWeb> iterator() { 117 return delegate.iterator(); 118 } 119 120 public final boolean remove(final Object o) { 121 return delegate.remove(o); 122 } 123 124 public final boolean removeAll(final Collection<?> c) { 125 return delegate.removeAll(c); 126 } 127 128 public final boolean retainAll(final Collection<?> c) { 129 return delegate.retainAll(c); 130 } 131 132 public final int size() { 133 return delegate.size(); 134 } 135 136 public final Object[] toArray() { 137 return delegate.toArray(); 138 } 139 140 public final Object[] toArray(final Object[] a) { 141 return delegate.toArray(a); 142 } 143 }