01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.om.page.psml;
18:
19: import java.util.AbstractList;
20:
21: /**
22: * FragmentList
23: *
24: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
25: * @version $Id$
26: */
27: class FragmentList extends AbstractList {
28: private FragmentImpl fragment;
29:
30: FragmentList(FragmentImpl fragment) {
31: super ();
32: this .fragment = fragment;
33: }
34:
35: /* (non-Javadoc)
36: * @see java.util.List#add(int,java.lang.Object)
37: */
38: public void add(int index, Object element) {
39: // implement for modifiable AbstractList:
40: // add and maintain page implementation reference
41: fragment.accessFragments().add(index, element);
42: if ((fragment.getPage() != null)
43: && (element instanceof FragmentImpl)) {
44: ((FragmentImpl) element).setPage(fragment.getPage());
45: }
46: }
47:
48: /* (non-Javadoc)
49: * @see java.util.List#get(int)
50: */
51: public Object get(int index) {
52: // implement for modifiable AbstractList
53: return fragment.accessFragments().get(index);
54: }
55:
56: /* (non-Javadoc)
57: * @see java.util.List#remove(int)
58: */
59: public Object remove(int index) {
60: // implement for modifiable AbstractList
61: return fragment.accessFragments().remove(index);
62: }
63:
64: /* (non-Javadoc)
65: * @see java.util.List#set(int,java.lang.Object)
66: */
67: public Object set(int index, Object element) {
68: // implement for modifiable AbstractList:
69: // set and maintain page implementation reference
70: Object o = fragment.accessFragments().set(index, element);
71: if ((fragment.getPage() != null)
72: && (element instanceof FragmentImpl)) {
73: ((FragmentImpl) element).setPage(fragment.getPage());
74: }
75: return o;
76: }
77:
78: /* (non-Javadoc)
79: * @see java.util.List#size()
80: */
81: public int size() {
82: // implement for modifiable AbstractList
83: return fragment.accessFragments().size();
84: }
85: }
|