(int index)
| 812 | } |
| 813 | |
| 814 | @Override |
| 815 | public Document get(int index) { |
| 816 | if(index >= docDataList.size()) return null; |
| 817 | |
| 818 | Document res = documents.get(index); |
| 819 | |
| 820 | if(DEBUG) |
| 821 | Out.prln("SerialCorpusImpl: get(): index " + index + "result: " + res); |
| 822 | |
| 823 | // if the document is null, then I must get it from the DS |
| 824 | if(res == null) { |
| 825 | FeatureMap parameters = Factory.newFeatureMap(); |
| 826 | parameters.put(DataStore.DATASTORE_FEATURE_NAME, this.dataStore); |
| 827 | try { |
| 828 | parameters.put(DataStore.LR_ID_FEATURE_NAME, docDataList |
| 829 | .get(index).getPersistentID()); |
| 830 | Document lr = (Document) Factory.createResource(docDataList |
| 831 | .get(index).getClassType(), parameters); |
| 832 | if(DEBUG) Out.prln("Loaded document :" + lr.getName()); |
| 833 | // change the result to the newly loaded doc |
| 834 | res = lr; |
| 835 | |
| 836 | // finally replace the doc with the instantiated version |
| 837 | documents.set(index, lr); |
| 838 | } |
| 839 | catch(ResourceInstantiationException ex) { |
| 840 | Err.prln("Error reading document inside a serialised corpus."); |
| 841 | throw new GateRuntimeException(ex); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | return res; |
| 846 | } |
| 847 | |
| 848 | @Override |
| 849 | public Document set(int index, Document element) { |
no test coverage detected