@SuppressWarnings("unchecked") public List<Object> splitByLists(String text,boolean recurse){
  List<Object> textList=new ArrayList<>();
  String remainText=text;
  msgHandler.logDebug("====================================\n" + "splitByLists\n" + "====================================");
  while (true) {
    Map<String,Object> listInfo=findParseBulletList(remainText,false);
    if (listInfo == null) {
      break;
    }
    int startIndex=(int)listInfo.get("startIndex");
    int endIndex=(int)listInfo.get("endIndex");
    if (startIndex > 0) {
      textList.add(remainText.substring(0,startIndex));
    }
    if (recurse) {
      List<Object> parsedItems=new ArrayList<>();
      List<Object> itemTexts=(List<Object>)listInfo.get("items");
      if (itemTexts != null && !itemTexts.isEmpty()) {
        for (        Object itemEntry : itemTexts) {
          String itemText=(String)itemEntry;
          List<Object> parsedItemList=splitByStructuralElems(itemText);
          parsedItems.add(parsedItemList);
        }
      }
      listInfo.put("items",parsedItems);
    }
    textList.add(listInfo);
    remainText=remainText.substring(endIndex);
  }
  if (!remainText.isEmpty()) {
    textList.add(remainText);
  }
  msgHandler.logDebug("textList size: " + textList.size());
  return textList;
}

@ SuppressWarnings ( "unchecked" ) public List < Object > splitByLists ( String text , boolean recurse ) { List < Object > textList = new ArrayList < > ( ) ; String remainText = text ; msgHandler . logDebug ( "====================================\n" + "splitByLists\n" + "====================================" ) ; while ( true ) { Map < String , Object > listInfo = findParseBulletList ( remainText , false ) ; if ( listInfo == null ) { break ; } int startIndex = ( int ) listInfo . get ( "startIndex" ) ; int endIndex = ( int ) listInfo . get ( "endIndex" ) ; if ( startIndex > 0 ) { textList . add ( remainText . substring ( 0 , startIndex ) ) ; } if ( recurse ) { List < Object > parsedItems = new ArrayList < > ( ) ; List < Object > itemTexts = ( List < Object > ) listInfo . get ( "items" ) ; if ( itemTexts != null && ! itemTexts . isEmpty ( ) ) { for ( Object itemEntry : itemTexts ) { String itemText = ( String ) itemEntry ; List < Object > parsedItemList = splitByStructuralElems ( itemText ) ; parsedItems . add ( parsedItemList ) ; } } listInfo . put ( "items" , parsedItems ) ; } textList . add ( listInfo ) ; remainText = remainText . substring ( endIndex ) ; } if ( ! remainText . isEmpty ( ) ) { textList . add ( remainText ) ; } msgHandler . logDebug ( "textList size: " + textList . size ( ) ) ; return textList ; }
returns list of maps and strings . string is piece of text , while each map describes a list . < p > if recurse , the list elems are passed through splitbymarkupelems
