Exemple #1
0
 /**
  * Gets the names of the documents in this corpus.
  *
  * @return a {@link List} of Strings representing the names of the documents in this corpus.
  */
 @Override
 public List<String> getDocumentNames() {
   List<String> docsNames = new ArrayList<String>();
   if (docDataList == null) return docsNames;
   for (Object aDocDataList : docDataList) {
     DocumentData data = (DocumentData) aDocDataList;
     docsNames.add(data.getDocumentName());
   }
   return docsNames;
 }
Exemple #2
0
  public int findDocument(Document doc) {
    boolean found = false;
    DocumentData docData = null;

    // first try finding the document in memory
    int index = documents.indexOf(doc);
    if (index > -1 && index < docDataList.size()) return index;

    // else try finding a document with the same name and persistent ID
    Iterator<DocumentData> iter = docDataList.iterator();
    for (index = 0; iter.hasNext(); index++) {
      docData = iter.next();
      if (docData.getDocumentName().equals(doc.getName())
          && docData.getPersistentID().equals(doc.getLRPersistenceId())
          && docData.getClassType().equals(doc.getClass().getName())) {
        found = true;
        break;
      }
    }
    if (found && index < docDataList.size()) return index;
    else return -1;
  } // findDocument