KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > mdr > handlers > AttrImmutListWrapper


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.mdr.handlers;
20
21 import java.util.Collection JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.ListIterator JavaDoc;
24 import org.netbeans.mdr.storagemodel.MdrStorage;
25
26 import org.netbeans.mdr.util.TransactionMutex;
27
28 /**
29  *
30  * @author Martin Matula
31  */

32 public final class AttrImmutListWrapper extends AttrImmutCollWrapper implements List JavaDoc {
33
34     /** Creates new ListWrapper */
35     public AttrImmutListWrapper(MdrStorage mdrStorage, FeaturedHandler source, int attrIndex, String JavaDoc attrName) {
36         super(mdrStorage, source, attrIndex, attrName);
37     }
38     
39     public AttrImmutListWrapper(MdrStorage mdrStorage, Collection JavaDoc inner) {
40         super(mdrStorage, inner);
41     }
42     
43     public List JavaDoc getInnerList() {
44         return (List JavaDoc) getInnerCollection();
45     }
46     
47     public Object JavaDoc remove(int param) {
48         throw new UnsupportedOperationException JavaDoc();
49     }
50     
51     public ListIterator JavaDoc listIterator(int param) {
52         lock(false);
53         try {
54             return new AttrImmutListIteratorWrapper(getInnerList().listIterator(param));
55         } finally {
56             unlock();
57         }
58     }
59     
60     public void add(int param, Object JavaDoc obj) {
61         throw new UnsupportedOperationException JavaDoc();
62     }
63     
64     public int indexOf(Object JavaDoc obj) {
65         lock(false);
66         try {
67             return getInnerList().indexOf(obj);
68         } finally {
69             unlock();
70         }
71     }
72     
73     public int lastIndexOf(Object JavaDoc obj) {
74         lock(false);
75         try {
76             return getInnerList().lastIndexOf(obj);
77         } finally {
78             unlock();
79         }
80     }
81     
82     public Object JavaDoc get(int param) {
83         lock(false);
84         try {
85             return getInnerList().get(param);
86         } finally {
87             unlock();
88         }
89     }
90     
91     public Object JavaDoc set(int param, Object JavaDoc obj) {
92         throw new UnsupportedOperationException JavaDoc();
93     }
94     
95     public boolean addAll(int param, Collection JavaDoc collection) {
96         throw new UnsupportedOperationException JavaDoc();
97     }
98     
99     public ListIterator JavaDoc listIterator() {
100         lock(false);
101         try {
102             return new AttrImmutListIteratorWrapper(getInnerList().listIterator());
103         } finally {
104             unlock();
105         }
106     }
107     
108     public List JavaDoc subList(int param, int param1) {
109         lock(false);
110         try {
111             return new AttrImmutListWrapper(storage, getInnerList().subList(param, param1));
112         } finally {
113             unlock();
114         }
115     }
116     
117     public boolean equals(Object JavaDoc object) {
118         if (object instanceof List JavaDoc) {
119             return super.equals(object);
120         } else {
121             return false;
122         }
123     }
124     
125     private final class AttrImmutListIteratorWrapper extends AttrImmutIteratorWrapper implements ListIterator JavaDoc {
126         private final ListIterator JavaDoc innerListIterator;
127         
128         AttrImmutListIteratorWrapper(ListIterator JavaDoc innerIterator) {
129             super(innerIterator);
130             this.innerListIterator = innerIterator;
131         }
132         
133         public int previousIndex() {
134             lock(false);
135             try {
136                 return innerListIterator.previousIndex();
137             } finally {
138                 unlock();
139             }
140         }
141         
142         public void set(Object JavaDoc obj) {
143             throw new UnsupportedOperationException JavaDoc();
144         }
145         
146         public int nextIndex() {
147             lock(false);
148             try {
149                 return innerListIterator.nextIndex();
150             } finally {
151                 unlock();
152             }
153         }
154         
155         public boolean hasPrevious() {
156             lock(false);
157             try {
158                 return innerListIterator.hasPrevious();
159             } finally {
160                 unlock();
161             }
162         }
163         
164         public void add(Object JavaDoc obj) {
165             throw new UnsupportedOperationException JavaDoc();
166         }
167         
168         public Object JavaDoc previous() {
169             lock(false);
170             try {
171                 return innerListIterator.previous();
172             } finally {
173                 unlock();
174             }
175         }
176     }
177 }
178
Popular Tags