Revision 44304 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/raster/impl/DefaultCoverageStore.java

View differences:

DefaultCoverageStore.java
24 24
package org.gvsig.fmap.dal.raster.impl;
25 25

  
26 26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.Map;
29 27
import java.util.Set;
28
import org.gvsig.fmap.dal.BaseStoresRepository;
30 29

  
31 30
import org.gvsig.fmap.dal.DataCache;
32 31
import org.gvsig.fmap.dal.DataManager;
......
72 71
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
73 72
import org.gvsig.tools.undo.command.Command;
74 73
import org.gvsig.tools.util.UnmodifiableBasicMap;
75
import org.gvsig.tools.util.UnmodifiableBasicSet;
76
import org.gvsig.tools.util.UnmodifiableBasicSetChained;
77 74
import org.gvsig.tools.visitor.Visitor;
78 75
import org.slf4j.Logger;
79 76
import org.slf4j.LoggerFactory;
......
548 545
    @Override
549 546
    public StoresRepository getStoresRepository() {
550 547
        final StoresRepository mainRepository = this.dataManager.getStoresRepository();
551
        StoresRepository repository = new StoresRepository() {
548
        StoresRepository repository = new BaseStoresRepository(this.getName()) {
549
            
552 550
            @Override
553
            public void add(String name, DataStoreParameters parameters) {
554
                mainRepository.add(name, parameters);
551
            protected DataStoreParameters getMyParameters(String name) {
552
                // Uff, esta implementacion no es nada buena
553
                DataStore store = getChildren().get(name);
554
                if( store==null ) {
555
                    return null;
556
                }
557
                return store.getParameters();
555 558
            }
556 559

  
557 560
            @Override
558
            public void remove(String name) {
559
                mainRepository.remove(name);
561
            protected boolean isEmptyMyRepository() {
562
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
563
                return children==null || children.isEmpty();
560 564
            }
561 565

  
562 566
            @Override
563
            public DataStore get(String key) {
564
                DataStore store = getChildren().get(key);
565
                if( store != null ) {
566
                    return store;
567
            protected int getMySize() {
568
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
569
                if( children==null ) {
570
                    return 0;
567 571
                }
568
                return mainRepository.get(key);
572
                return children.size();
569 573
            }
570 574

  
571 575
            @Override
572
            public boolean isEmpty() {
573
                return getChildren().isEmpty() && mainRepository.isEmpty();
576
            public void add(String name, DataStoreParameters parameters) {
577
                mainRepository.add(name, parameters);
574 578
            }
575 579

  
576 580
            @Override
577
            public boolean containsKey(String key) {
578
                return getChildren().containsKey(key) || mainRepository.containsKey(key);
581
            public void remove(String name) {
582
                mainRepository.remove(name);
579 583
            }
580 584

  
581
            @Override
582
            public Map<String, DataStore> toMap() {
583
                return null;
584
            }
585

  
586
            @Override
587
            public int size() {
588
                return getChildren().size()+mainRepository.size();
589
            }
590

  
591
            @Override
592
            public UnmodifiableBasicSet<String> keySet() {
593
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
594
                if( children.isEmpty() ) {
595
                    return mainRepository.keySet();
596
                }
597
                return new UnmodifiableBasicSetChained<>(
598
                        children.keySet(), 
599
                        mainRepository.keySet()
600
                );
601
            }
602

  
603
            @Override
604
            public Iterator<DataStore> iterator() {
605
                final Iterator<String> it = this.keySet().iterator();
606
                return new Iterator<DataStore>() {
607
                    @Override
608
                    public boolean hasNext() {
609
                        return it.hasNext();
610
                    }
611

  
612
                    @Override
613
                    public DataStore next() {
614
                        String name = it.next();
615
                        return get(name);
616
                    }
617
                };
618
            }
619 585
        };
620 586
        return repository;
621 587
    }

Also available in: Unified diff