String (final int index, final Object[] documents) { final Object document = documents[index]; if (document instanceof PlainDocument) { try { return ((PlainDocument)document).getText(0, ((PlainDocument)document).getLength()); } catch (BadLocationException e) { throw new RuntimeException(e); } } return ((Document)document).getText(); }