Revision 47665 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.gml/src/main/java/org/gvsig/fmap/dal/store/gml/virtualrows/XMLFileAsList.java

View differences:

XMLFileAsList.java
27 27
import org.apache.commons.io.IOUtils;
28 28
import org.apache.commons.io.input.CloseShieldReader;
29 29
import org.apache.commons.lang3.StringUtils;
30
import static org.gvsig.fmap.dal.store.simplereader.SimpleReaderUtils.isFileNewer;
30 31
import org.gvsig.fmap.dal.store.simplereader.virtualrows.LimitedReader;
31 32
import org.gvsig.fmap.dal.store.simplereader.virtualrows.RandomAccessFileReader;
32 33
import org.gvsig.fmap.dal.store.simplereader.virtualrows.RecordsFile;
......
80 81
    private List<String> fieldPaths;
81 82
    private final List<String> geomPaths;
82 83
    private int combineMode;
84
    private long lastModified;
83 85

  
84 86
    
85
    //                                                         ruta   recordnum                       ruta   recordnum
86
 // public XMLFileAsList(File text, Charset charset, List<Pair<String,Integer>> recordPath, List<Pair<String,Integer>> fieldPaths) throws IOException {
87 87
    public XMLFileAsList(File text, Charset charset, String recordPath, List<String> geomPath, List<String> fieldPaths) throws IOException {
88 88
        this.reader = new RandomAccessFileReader(text, charset);
89 89
        this.index = null;
90 90
        this.recordPath = recordPath;
91 91
        this.geomPaths = geomPath;
92 92
        this.fieldPaths = fieldPaths;
93
        this.lastModified = text.lastModified();
93 94
    }
94 95

  
95
//    public XMLFileAsList(File text, File index, Charset charset, String recordPath, List<String> geomPath, List<String> fieldPaths, SimpleTaskStatus status) throws IOException {
96
//        this.reader = new RandomAccessFileReader(text, charset);
97
//        this.recordPath = recordPath;
98
//        this.geomPaths = geomPath;
99
//        this.fieldPaths = fieldPaths;
100
//        if (index.exists()) {
101
//            // TODO: Force to create index if text newer than index
102
//            this.index = new RecordsFileImpl(index);
103
//        } else {
104
//            this.createIndex(index, status);
105
//        }
106
//    }
107

  
108 96
    public XMLFileAsList(RandomAccessFileReader reader, RecordsFile index, String recordPath, List<String> geomPath, List<String> fieldPaths) throws IOException {
109 97
        this.reader = reader;
110 98
        this.index = index;
111 99
        this.recordPath = recordPath;
112 100
        this.geomPaths = geomPath;
113 101
        this.fieldPaths = fieldPaths;
102
        this.lastModified = -1;
114 103
    }
115 104

  
116 105
    @Override
......
294 283
        this.combineMode = combineMode;
295 284
    }
296 285
    
286
    public boolean loadIndex(File fileIndex, SimpleTaskStatus status) throws IOException{
287
        if (!fileIndex.exists()) {
288
            return false;
289
        }
290
        if(this.lastModified > 0 && isFileNewer(fileIndex, this.lastModified)){
291
            this.index = new RecordsFileImpl(fileIndex);
292
            return true;
293
        }
294
        return false;
295
    }
296
    
297 297
    final public void createIndex(File indexFile, SimpleTaskStatus status) throws IOException {
298 298
        try {
299 299
            // 1. Creamos el indice vacio
......
331 331
            if (status != null) {
332 332
                I18nManager i18n = ToolsLocator.getI18nManager();
333 333
                status.push();
334
                status.message(i18n.getTranslation("_Creating_the_index_of_the_lines"));
334
                status.message(i18n.getTranslation("_Creating_record_index"));
335 335
                status.setIndeterminate();
336 336
            }
337 337

  

Also available in: Unified diff