public List<Span> getFormatSpans(FormatType t){ List<Span> result = new ArrayList<Span>(); int offset = 0; for( Content c: ccl ){ for( Span b : c.getFormatSpans(t) ) result.add( b.clone().adjust( offset )); offset += 1 + c.length(); } return result; }
private static void handleContent( Content c, EnumMap<CIT, Boolean> hp, StringBuilder sb ){ if( hp != null ){ if( hp.get( CIT.TEXT )) sb.append( c.getText()+" " ); else{ if( hp.get( CIT.BOLD ) ) handleSpans( c.getFormatSpans( FormatType.BOLD), c.getText(), sb ); if( hp.get( CIT.ITALIC )) handleSpans( c.getFormatSpans( FormatType.ITALIC), c.getText(), sb ); } if( hp.get( CIT.LINK )) handleLinks( c.getLinks(), !hp.get( CIT.TEXT ), sb ); } }
public List<Span> getFormatSpans(FormatType t, Span s){ List<Span> result = new ArrayList<Span>(); Span a = new Span( -1, -1 ); for( Content c: ccl ){ int offset = a.getEnd()+1; a = new Span( offset, offset+ c.length() ); if( a.hits(s) ){ for( Span b: c.getFormatSpans( t, s.clone().adjust( -offset ) ) ) result.add( b.clone().adjust( offset ) ); } } return result; }