code: synchronized PersistentIndex getOrCreateIndex(String indexName) throws IOException
     {
        // check existing
        for (Iterator<PersistentIndex> it = indexes.iterator(); it.hasNext();)
        {
           PersistentIndex idx = it.next();
           if (idx.getName().equals(indexName))
           {
              return idx;
           }
        }
  
        if (modeHandler.getMode() == IndexerIoMode.READ_ONLY)
        {
           throw new UnsupportedOperationException("Can't create index in READ_ONLY mode.");
        }
  
        // otherwise open / create it
        if (indexName == null)
        {
           do
           {
              indexName = indexNames.newName();
           }
           while (directoryManager.hasDirectory(indexName));
        }
        PersistentIndex index;
        try
        {
           index =
              new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager,
                 modeHandler);
        }
        catch (IOException e)
        {
           // do some clean up
           if (!directoryManager.delete(indexName))
           {
              deletable.add(indexName);
           }
           throw e;
        }
        index.setMaxFieldLength(handler.getMaxFieldLength());
        index.setUseCompoundFile(handler.getUseCompoundFile());
        index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
  
        // add to list of open indexes and return it
        indexes.add(index);
        return index;
     }
docs: Creates a new Persistent index. The new index is not registered with this
  <code>MultiIndex</code>.
  
  @param indexName
  the name of the index to open, or <code>null</code> if an
  index with a new name should be created.
  @return a new <code>PersistentIndex</code>.
  @throws IOException
  if a new index cannot be created.