ContentElement conElement = new ContentElement(); conElement.setPubDate(pubDate); // won't overwrite dates conElement.setConChannel(conChannel); // and channels now conList.setConElement(conElement); // every list has its own copy of element
/** * Returns getTitleElement().getText() without NullPointerException */ public String getTitle(){ if( title!=null ) return title.getText(); else return null; }
private static void checkRange( ContentElement ce ){ List<SrcSpan> eil = new ArrayList<SrcSpan>(); for( Span s: ce.getFormatSpans( FormatType.BOLD ) ) eil.add( s.getSrcSpan() ); for( Span s: ce.getFormatSpans( FormatType.ITALIC ) ) eil.add( s.getSrcSpan() ); for( Span s: ce.getFormatSpans( FormatType.MATH ) ) eil.add( s.getSrcSpan() ); for( Span s: ce.getFormatSpans( FormatType.TAG ) ) eil.add( s.getSrcSpan() ); for( Span s: ce.getFormatSpans( FormatType.NOWIKI ) ) eil.add( s.getSrcSpan() ); for( Link l: ce.getLinks()) eil.add( l.getSrcSpan() ); for( Template t: ce.getTemplates() ) eil.add( t.getSrcSpan() ); ce.setSrcSpan( getEvalInfo( ce.getSrcSpan(), eil) ); }
"<tr><th class=\""+cssClass+"\">" +headline+"</th></tr>\n"+ "<tr><td class=\""+cssClass+"\">\n" + "\"" + convertTags( ce.getText() )+ "\"\n" + "</td></tr>\n" ); String BoldWords = ce.getText( ce.getFormatSpans( FormatType.BOLD )); if( BoldWords.length() > 0 ) { result.append("<tr><td class=\""+cssClass+"\">BoldWords: "+convertTags(BoldWords)+"</td></tr>\n"); String ItalicWords = ce.getText( ce.getFormatSpans( FormatType.ITALIC )); if( ItalicWords.length() > 0 ) { result.append("<tr><td class=\""+cssClass+"\">italicWords: "+convertTags(ItalicWords)+"</td></tr>\n"); if( ce.getFormatSpans( FormatType.MATH ).size() != 0 ){ result.append("<tr><td class=\""+cssClass+"\">MathTags\n"); for( Span s: ce.getFormatSpans( FormatType.MATH ) ) { result.append( s.toString() +"\n"); if( ce.getFormatSpans( FormatType.TAG ).size()!=0 ){ result.append("<tr><td class=\""+cssClass+"\">Tags:\n"); for( Span s: ce.getFormatSpans( FormatType.TAG ) ) { result.append( s.toString() +"\n"); if( ce.getLinks().size()!=0 ){ result.append("<tr><td class=\""+cssClass+"\">\n"); for( Link l: ce.getLinks() ) { result.append( linkToHtml( l ) ); if( ce.getTemplates().size()!=0 ){
List<String> identifers) ContentElement result = new ContentElement(); StringBuilder text = new StringBuilder(); List<Link> localLinks = new ArrayList<Link>(); result.setText(text.toString()); result.setLinks(localLinks); if (result.empty())
result.setSrcSpan(new SrcSpan(sm.getSrcPos(contentElementRange .getStart()), sm.getSrcPos(contentElementRange.getEnd()))); result.setText(sm.substring(contentElementRange)); result.setFormatSpans(FormatType.BOLD, boldSpans); result.setFormatSpans(FormatType.ITALIC, italicSpans); result.setFormatSpans(FormatType.TAG, tags); result.setFormatSpans(FormatType.MATH, mathSpans); result.setFormatSpans(FormatType.NOWIKI, localNoWikiSpans); result.setLinks(sortLinks(localLinks)); result.setTemplates(sortTemplates(localTemplates));
/** * Building a ContentElement from a single line. */ private ContentElement parseContentElement(SpanManager sm, ContentElementParsingParameters cepp, Span lineSpan) { LinkedList<Span> lineSpans = new LinkedList<Span>(); lineSpans.add(lineSpan); return parseContentElement(sm, cepp, lineSpans, new ContentElement()); }
/** * Returns a list of language Link objects. * This is a shortcut for writing getLanguagesElement().getLinks(); */ public List<Link> getLanguages(){ return languages.getLinks(); }
/** * Returns all the Spans of the Format type t in the Range of the Span s */ public List<Span> getFormatSpans(FormatType t, Span s){ List<Span> result = new ArrayList<Span>(); for( Span s2: getFormatSpans(t) ) if( s2.hits(s) )result.add( s2 ); return result; }
.get(content.size() - 1).getSrcSpan().getEnd()));
/** * Returns the Formats wich are used in this ContentElement, in the Range from start to end, in a List. */ public List<FormatType> getFormats(int start, int end){ return getFormats(new Span(start, end)); }
/** * Returns a List of the Templates of this ContentElement in the Range from start to end */ public List<Template> getTemplates(int start, int end){ return getTemplates( new Span(start, end) ); }
/** * Removes all empty Structures from a DefinitionList and all substructures. */ public static DefinitionList eliminateEmptyStructures( DefinitionList dl ){ ContentElement dt = dl.getDefinedTerm(); if( dt!=null && dt.empty() ) dl.setDefinedTerm( null ); for(int i=dl.nrOfDefinitions()-1; i>=0; i-- ){ ContentElement ce = dl.getDefinition(i); if( ce.empty() )dl.removeDefinition( ce ); } return dl; } }
/** * Building a ContentElement from a String */ @Override public ContentElement parseContentElement(String src) { SpanManager sm = new SpanManager(src); ContentElementParsingParameters cepp = new ContentElementParsingParameters(); parseImagesAndInternalLinks(sm, cepp.linkSpans, cepp.links); LinkedList<Span> lineSpans = new LinkedList<Span>(); getLineSpans(sm, lineSpans); sm.removeManagedList(lineSpans); return (parseContentElement(sm, cepp, lineSpans, new ContentElement())); }
/** * Returns a list of category Link objects. * This is a shortcut for writing getCategoryElemement.getLinks(); * @return A list of category links. */ public List<Link> getCategories(){ if (categories == null) { return new ArrayList<Link>(); } return categories.getLinks(); }
/** * Returns all the Spans of the Format type t in the Range of start to end */ public List<Span> getFormatSpans(FormatType t, int start, int end ){ return getFormatSpans( t, new Span(start, end)); }
private static void checkRange( SectionContent s ){ List<SrcSpan> eil = new ArrayList<SrcSpan>(); if( s.getTitleElement()!= null ){ checkRange( s.getTitleElement() ); eil.add( s.getTitleElement().getSrcSpan() ); } for( Paragraph p: s.getParagraphs() ){ checkRange( p ); eil.add( p.getSrcSpan() ); } for( DefinitionList dl: s.getDefinitionLists() ){ checkRange( dl ); eil.add( dl.getSrcSpan() ); } for( NestedListContainer nl: s.getNestedLists() ){ checkRange( nl ); eil.add( nl.getSrcSpan() ); } for( Table t: s.getTables() ){ checkRange( t ); eil.add( t.getSrcSpan() ); } s.setSrcSpan( getEvalInfo( s.getSrcSpan(), eil)); }
private void setLists(Article article, ParsedPage page) { List<List<String>> lists = new ArrayList<List<String>>(); for (DefinitionList dl : page.getDefinitionLists()) { List<String> l = new ArrayList<String>(); for (ContentElement c : dl.getDefinitions()) { l.add(c.getText()); } lists.add(l); } for (NestedListContainer dl : page.getNestedLists()) { List<String> l = new ArrayList<String>(); for (NestedList nl : dl.getNestedLists()) { l.add(nl.getText()); } lists.add(l); } article.setLists(lists); }
/** * Returns a List of the Links of this ContentElement of the Specified Link.type t in the Range of start to end */ public List<Link> getLinks( Link.type t, int begin, int end){ return getLinks( t, new Span(begin, end) ); }
String title = ""; if (t.getTitleElement() != null) { title = t.getTitleElement().getText(); if (title == null) { title = "";