View Javadoc

1   // $Id:NamespacesListModel.java 62 2008-04-20 12:28:56Z me $
2   /*
3    * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4    * 
5    * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6    * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7    * version.
8    * 
9    * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11   * 
12   * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14   */
15  /**
16   * 
17   */
18  package de.mindcrimeilab.xsanalyzer.model;
19  
20  import javax.swing.AbstractListModel;
21  import javax.swing.ListModel;
22  
23  import org.apache.xerces.xs.XSModel;
24  import org.apache.xerces.xs.XSNamespaceItemList;
25  
26  /**
27   * @author Michael Engelhardt<me@mindcrime-ilab.de>
28   * @author $Author:me $
29   * @version $Revision:62 $
30   * 
31   */
32  public class NamespacesListModel extends AbstractListModel implements ListModel {
33  
34      private final XSModel baseModel;
35  
36      public NamespacesListModel(XSModel model) {
37          baseModel = model;
38      }
39  
40      /*
41       * (non-Javadoc)
42       * 
43       * @see javax.swing.ListModel#getElementAt(int)
44       */
45      @Override
46      public Object getElementAt(int index) {
47          XSNamespaceItemList list = baseModel.getNamespaceItems();
48          return (null == list) ? null : list.item(index);
49      }
50  
51      /*
52       * (non-Javadoc)
53       * 
54       * @see javax.swing.ListModel#getSize()
55       */
56      @Override
57      public int getSize() {
58          XSNamespaceItemList list = baseModel.getNamespaceItems();
59          return (null == list) ? 0 : list.getLength();
60      }
61  
62  }