001 /* 002 * mesopotamia @mesopotamia.version@ 003 * Multilingual parser and repository. 004 * Copyright (C) 2005 Hammurapi Group 005 * 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2 of the License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 019 * 020 * URL: http://http://www.hammurapi.biz 021 * e-Mail: support@hammurapi.biz 022 */ 023 package org.mesopotamia.util; 024 025 import java.util.AbstractList; 026 import java.util.List; 027 028 import biz.hammurapi.convert.ConverterClosure; 029 030 /** 031 * Generic duplicate of biz.hammurapi.UnmodifiableConvertingList 032 * @author Tatyana Konukova 033 * 034 */ 035 public class UnmodifiableConvertingList<T> extends AbstractList<T> { 036 private List master; 037 private ConverterClosure converter; 038 039 public UnmodifiableConvertingList(List master, ConverterClosure converter) { 040 super(); 041 this.master=master; 042 this.converter=converter; 043 } 044 045 @SuppressWarnings("unchecked") 046 public T get(int index) { 047 return (T) converter.convert(master.get(index)); 048 } 049 050 public int size() { 051 return master.size(); 052 } 053 054 /** 055 * @param o 056 * @return master list 057 */ 058 public List getMaster() { 059 return master; 060 } 061 }