Revision 41212 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/paging/impl/FeaturePagingHelperImpl.java

View differences:

FeaturePagingHelperImpl.java
23 23
 */
24 24
package org.gvsig.fmap.dal.feature.paging.impl;
25 25

  
26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.List;
29
import java.util.ListIterator;
26 30
import org.slf4j.Logger;
27 31
import org.slf4j.LoggerFactory;
28 32

  
......
73 77

  
74 78
    private Feature[] features = null;
75 79

  
80
    private boolean initialization_completed = false;
76 81
    /**
77 82
     * Constructs a FeaturePagingHelperImpl from data of a FeatureStore.
78 83
     * 
......
157 162
                + "and a page size of {}", new Long(getCalculator()
158 163
                .getNumPages()), new Integer(pageSize));
159 164
        }
165
        this.initialization_completed = true;
160 166
    }
161 167

  
162 168
    /**
......
210 216
                new IndexOutOfBoundsException("positionForIndex too big: "
211 217
                    + positionForIndex));
212 218
        } else {
213
            return features[(int) positionForIndex];
219
            Feature feature = features[(int) positionForIndex];
220
            return feature;
214 221
        }
215 222
        
216 223
    }
......
302 309
     * Loads all the Features of the current page.
303 310
     */
304 311
    protected void loadCurrentPageData() throws BaseException {
312
        if( !initialization_completed ) {
313
            return;
314
        }
305 315
        final int currentPageSize = getCalculator().getCurrentPageSize();
306 316
        final Feature[] values = new Feature[currentPageSize];
307 317

  
......
508 518
        return new DynObjectFeatureFacade(getFeatureAt(index));
509 519
    }
510 520

  
521
    public List asList() {
522
        return new FeaturePagingHelperList();
523
    }
524
    
525
    public List asListOfDynObjects() {
526
        return new DynObjectPagingHelperList();
527
    }    
528
    
529
    private class FeaturePagingHelperList extends PagingHelperList {
530
        public Object get(int i) {
531
            try {
532
                return getFeatureAt(i);
533
            } catch (BaseException ex) {
534
                throw  new RuntimeException(ex);
535
            }
536
        }
537
    }
538
    
539
    private class DynObjectPagingHelperList extends PagingHelperList {
540
        public Object get(int i) {
541
            try {
542
                return getDynObjectAt(i);
543
            } catch (BaseException ex) {
544
                throw  new RuntimeException(ex);
545
            }
546
        }
547
    }
548
    
549
    private abstract class PagingHelperList implements List {
550

  
551
        public int size() {
552
            try {
553
                return (int) getFeatureSet(false).getSize();
554
            } catch (DataException ex) {
555
                throw  new RuntimeException(ex);
556
            }
557
        }
558

  
559
        public boolean isEmpty() {
560
            try {
561
                return getFeatureSet(false).isEmpty();
562
            } catch (DataException ex) {
563
                throw  new RuntimeException(ex);
564
            }
565
        }
566

  
567
        public Iterator iterator() {
568
            try {
569
                return getFeatureSet(false).fastIterator();
570
            } catch (DataException ex) {
571
                throw  new RuntimeException(ex);
572
            }
573
        }
574

  
575
        public boolean contains(Object o) {
576
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
577
        }
578

  
579
        public Object[] toArray() {
580
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
581
        }
582

  
583
        public Object[] toArray(Object[] ts) {
584
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
585
        }
586

  
587
        public boolean add(Object e) {
588
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
589
        }
590

  
591
        public boolean remove(Object o) {
592
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
593
        }
594

  
595
        public boolean containsAll(Collection clctn) {
596
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
597
        }
598

  
599
        public boolean addAll(Collection clctn) {
600
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
601
        }
602

  
603
        public boolean addAll(int i, Collection clctn) {
604
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
605
        }
606

  
607
        public boolean removeAll(Collection clctn) {
608
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
609
        }
610

  
611
        public boolean retainAll(Collection clctn) {
612
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
613
        }
614

  
615
        public void clear() {
616
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
617
        }
618

  
619
        public Object set(int i, Object e) {
620
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
621
        }
622

  
623
        public void add(int i, Object e) {
624
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
625
        }
626

  
627
        public Object remove(int i) {
628
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
629
        }
630

  
631
        public int indexOf(Object o) {
632
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
633
        }
634

  
635
        public int lastIndexOf(Object o) {
636
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
637
        }
638

  
639
        public ListIterator listIterator() {
640
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
641
        }
642

  
643
        public ListIterator listIterator(int i) {
644
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
645
        }
646

  
647
        public List subList(int i, int i1) {
648
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
649
        }
650
        
651
    }
511 652
}

Also available in: Unified diff