MCPcopy Create free account
hub / github.com/GateNLP/gate-core / get

Method get

src/main/java/gate/corpora/SerialCorpusImpl.java:814–846  ·  view source on GitHub ↗
(int index)

Source from the content-addressed store, hash-verified

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) {

Callers 2

removeMethod · 0.95
syncMethod · 0.95

Calls 11

prlnMethod · 0.95
newFeatureMapMethod · 0.95
createResourceMethod · 0.95
prlnMethod · 0.95
getPersistentIDMethod · 0.80
getClassTypeMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
getNameMethod · 0.65
putMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected