List of usage examples for java.util LinkedList getFirst
public E getFirst()
From source file:net.firejack.platform.core.store.AbstractStore.java
protected Criteria prepareCriteria(Session session, LinkedList<Criterion> criterionList, Map<String, String> aliases, Paging paging, boolean isOr, boolean isLeft) { Criteria criteria = session.createCriteria(clazz); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (aliases != null && !aliases.isEmpty()) { for (Map.Entry<String, String> alias : aliases.entrySet()) { criteria.createAlias(alias.getKey(), alias.getValue(), isLeft ? CriteriaSpecification.LEFT_JOIN : CriteriaSpecification.INNER_JOIN); }// w ww .ja v a2 s . c o m } if (criterionList != null) { Criterion left = null; for (Criterion criterion : criterionList) { left = criterionList.getFirst() == criterion ? criterion : isOr ? Restrictions.or(left, criterion) : Restrictions.and(left, criterion); } if (left != null) criteria.add(left); } if (paging != null) { if (paging.getLimit() != null && paging.getLimit() > -1) { criteria.setMaxResults(paging.getLimit()); } if (paging.getOffset() != null && paging.getOffset() > -1) { criteria.setFirstResult(paging.getOffset()); } if (paging.getSortFields() != null) { for (SortField sortField : paging.getSortFields()) { if (sortField.getSortDirection().equals(SortOrder.ASC)) { criteria.addOrder(Order.asc(sortField.getSortColumn())); } else { criteria.addOrder(Order.desc(sortField.getSortColumn())); } } } } return criteria; }
From source file:org.archive.util.FileUtils.java
/** * Retrieve a number of lines from the file around the given * position, as when paging forward or backward through a file. * /* w w w . ja va 2 s . c o m*/ * @param file File to retrieve lines * @param position offset to anchor lines * @param signedDesiredLineCount lines requested; if negative, * want this number of lines ending with a line containing * the position; if positive, want this number of lines, * all starting at or after position. * @param lines List<String> to insert found lines * @param lineEstimate int estimate of line size, 0 means use default * of 128 * @return LongRange indicating the file offsets corresponding to * the beginning of the first line returned, and the point * after the end of the last line returned * @throws IOException */ @SuppressWarnings("unchecked") public static LongRange pagedLines(File file, long position, int signedDesiredLineCount, List<String> lines, int lineEstimate) throws IOException { // consider negative positions as from end of file; -1 = last byte if (position < 0) { position = file.length() + position; } // calculate a reasonably sized chunk likely to have all desired lines if (lineEstimate == 0) { lineEstimate = 128; } int desiredLineCount = Math.abs(signedDesiredLineCount); long startPosition; long fileEnd = file.length(); int bufferSize = (desiredLineCount + 5) * lineEstimate; if (signedDesiredLineCount > 0) { // reading forward; include previous char in case line-end startPosition = position - 1; } else { // reading backward startPosition = position - bufferSize + (2 * lineEstimate); } if (startPosition < 0) { startPosition = 0; } if (startPosition + bufferSize > fileEnd) { bufferSize = (int) (fileEnd - startPosition); } // read that reasonable chunk FileInputStream fis = new FileInputStream(file); fis.getChannel().position(startPosition); byte[] buf = new byte[bufferSize]; ArchiveUtils.readFully(fis, buf); IOUtils.closeQuietly(fis); // find all line starts fully in buffer // (positions after a line-end, per line-end definition in // BufferedReader.readLine) LinkedList<Integer> lineStarts = new LinkedList<Integer>(); if (startPosition == 0) { lineStarts.add(0); } boolean atLineEnd = false; boolean eatLF = false; int i; for (i = 0; i < bufferSize; i++) { if ((char) buf[i] == '\n' && eatLF) { eatLF = false; continue; } if (atLineEnd) { atLineEnd = false; lineStarts.add(i); if (signedDesiredLineCount < 0 && startPosition + i > position) { // reached next line past position, read no more break; } } if ((char) buf[i] == '\r') { atLineEnd = true; eatLF = true; continue; } if ((char) buf[i] == '\n') { atLineEnd = true; } } if (startPosition + i == fileEnd) { // add phantom lineStart after end lineStarts.add(bufferSize); } int foundFullLines = lineStarts.size() - 1; // if found no lines if (foundFullLines < 1) { if (signedDesiredLineCount > 0) { if (startPosition + bufferSize == fileEnd) { // nothing more to read: return nothing return new LongRange(fileEnd, fileEnd); } else { // retry with larger lineEstimate return pagedLines(file, position, signedDesiredLineCount, lines, Math.max(bufferSize, lineEstimate)); } } else { // try again with much larger line estimate // TODO: fail gracefully before growing to multi-MB buffers return pagedLines(file, position, signedDesiredLineCount, lines, bufferSize); } } // trim unneeded lines while (signedDesiredLineCount > 0 && startPosition + lineStarts.getFirst() < position) { // discard lines starting before desired position lineStarts.removeFirst(); } while (lineStarts.size() > desiredLineCount + 1) { if (signedDesiredLineCount < 0 && (startPosition + lineStarts.get(1) <= position)) { // discard from front until reach line containing target position lineStarts.removeFirst(); } else { lineStarts.removeLast(); } } int firstLine = lineStarts.getFirst(); int partialLine = lineStarts.getLast(); LongRange range = new LongRange(startPosition + firstLine, startPosition + partialLine); List<String> foundLines = IOUtils .readLines(new ByteArrayInputStream(buf, firstLine, partialLine - firstLine)); if (foundFullLines < desiredLineCount && signedDesiredLineCount < 0 && startPosition > 0) { // if needed and reading backward, read more lines from earlier range = expandRange(range, pagedLines(file, range.getMinimumLong() - 1, signedDesiredLineCount + foundFullLines, lines, bufferSize / foundFullLines)); } lines.addAll(foundLines); if (signedDesiredLineCount < 0 && range.getMaximumLong() < position) { // did not get line containining start position range = expandRange(range, pagedLines(file, partialLine, 1, lines, bufferSize / foundFullLines)); } if (signedDesiredLineCount > 0 && foundFullLines < desiredLineCount && range.getMaximumLong() < fileEnd) { // need more forward lines range = expandRange(range, pagedLines(file, range.getMaximumLong(), desiredLineCount - foundFullLines, lines, bufferSize / foundFullLines)); } return range; }
From source file:io.apptik.widget.MultiSlider.java
@Override public boolean onTouchEvent(MotionEvent event) { if (!mIsUserSeekable || !isEnabled()) { return false; }/* w w w . java2s . c om*/ int pointerIdx = event.getActionIndex(); Thumb currThumb = null; if (mDraggingThumbs.size() > pointerIdx) { currThumb = mDraggingThumbs.get(pointerIdx); } else { LinkedList<Thumb> closestOnes = getClosestThumb((int) event.getX(event.getActionIndex())); if (closestOnes != null && !closestOnes.isEmpty()) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) { if (closestOnes.size() == 1) { currThumb = closestOnes.getFirst(); onStartTrackingTouch(currThumb); drawableStateChanged(); } else { //we have more than one thumb at the same place and we touched there exactTouched = closestOnes; } } else if (exactTouched != null && !exactTouched.isEmpty() && event.getActionMasked() == MotionEvent.ACTION_MOVE) { //we have thumbs waiting to be selected to move currThumb = getMostMovable(exactTouched, event); //check if move actually changed value if (currThumb == null) return false; exactTouched = null; onStartTrackingTouch(currThumb); drawableStateChanged(); } else { currThumb = closestOnes.getFirst(); onStartTrackingTouch(currThumb); drawableStateChanged(); } } } switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: if (isInScrollingContainer()) { mTouchDownX = event.getX(); } else { //currThumb = getClosestThumb(newValue); //onStartTrackingTouch(currThumb); setPressed(true); if (currThumb != null && currThumb.getThumb() != null) { invalidate(currThumb.getThumb().getBounds()); // This may be within the padding region } int value = getValue(event, currThumb); setThumbValue(currThumb, value, true); attemptClaimDrag(); } break; case MotionEvent.ACTION_POINTER_DOWN: if (isInScrollingContainer()) { mTouchDownX = event.getX(); } else { //currThumb = getClosestThumb(newValue); //onStartTrackingTouch(currThumb); setPressed(true); if (currThumb != null && currThumb.getThumb() != null) { invalidate(currThumb.getThumb().getBounds()); // This may be within the padding region } setThumbValue(currThumb, getValue(event, currThumb), true); attemptClaimDrag(); } invalidate(); break; //with move we dont have pointer action so set them all case MotionEvent.ACTION_MOVE: if (!mDraggingThumbs.isEmpty()) { //need the index for (int i = 0; i < mDraggingThumbs.size(); i++) { setPressed(true); if (mDraggingThumbs.get(i) != null && mDraggingThumbs.get(i).getThumb() != null) { invalidate(mDraggingThumbs.get(i).getThumb().getBounds()); // This may be within the padding region } setThumbValue(mDraggingThumbs.get(i), getValue(event, i, mDraggingThumbs.get(i)), true); attemptClaimDrag(); } } else { final float x = event.getX(); if (Math.abs(x - mTouchDownX) > mScaledTouchSlop) { //currThumb = getClosestThumb(newValue); //onStartTrackingTouch(currThumb); setPressed(true); if (currThumb != null && currThumb.getThumb() != null) { invalidate(currThumb.getThumb().getBounds()); // This may be within the padding region } setThumbValue(currThumb, getValue(event, currThumb), true); attemptClaimDrag(); } } break; //there are other pointers left case MotionEvent.ACTION_POINTER_UP: if (currThumb != null) { setThumbValue(currThumb, getValue(event, currThumb), true); onStopTrackingTouch(currThumb); } else { // currThumb = getClosestThumb(newValue); // // Touch up when we never crossed the touch slop threshold should // // be interpreted as a tap-seek to that location. // onStartTrackingTouch(currThumb); // setThumbValue(currThumb, newValue, true); // onStopTrackingTouch(currThumb); } // ProgressBar doesn't know to repaint the thumb drawable // in its inactive state when the touch stops (because the // value has not apparently changed) invalidate(); break; //we normally have one single pointer here and its gone now case MotionEvent.ACTION_UP: if (currThumb != null) { int value = getValue(event, currThumb); setThumbValue(currThumb, value, true); onStopTrackingTouch(currThumb); } else { // currThumb = getClosestThumb(newValue); // // Touch up when we never crossed the touch slop threshold should // // be interpreted as a tap-seek to that location. // onStartTrackingTouch(currThumb); // setThumbValue(currThumb, newValue, true); // onStopTrackingTouch(); } setPressed(false); // ProgressBar doesn't know to repaint the thumb drawable // in its inactive state when the touch stops (because the // value has not apparently changed) invalidate(); break; case MotionEvent.ACTION_CANCEL: if (mDraggingThumbs != null) { onStopTrackingTouch(); setPressed(false); } invalidate(); // see above explanation break; } return true; }
From source file:net.firejack.platform.core.store.AbstractStore.java
protected Integer searchCount(final LinkedList<Criterion> criterions, final Map<String, String> aliases, final boolean isOr, final boolean isLeft) { return getHibernateTemplate().execute(new HibernateCallback<Integer>() { @Override/* w w w .j a v a 2 s.co m*/ public Integer doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(clazz); if (aliases != null && !aliases.isEmpty()) { for (Map.Entry<String, String> alias : aliases.entrySet()) { criteria.createAlias(alias.getKey(), alias.getValue(), isLeft ? CriteriaSpecification.LEFT_JOIN : CriteriaSpecification.INNER_JOIN); } } if (criterions != null) { Criterion left = null; for (Criterion criterion : criterions) { left = criterions.getFirst() == criterion ? criterion : isOr ? Restrictions.or(left, criterion) : Restrictions.and(left, criterion); } if (left != null) criteria.add(left); } return ((Long) criteria.setProjection(Projections.rowCount()).uniqueResult()).intValue(); } }); }
From source file:se.trixon.pacoma.ui.MainFrame.java
private void initListeners() { mActionManager.addAppListener(new ActionManager.AppListener() { @Override/*w w w . j a v a2 s. com*/ public void onCancel(ActionEvent actionEvent) { } @Override public void onMenu(ActionEvent actionEvent) { if (actionEvent.getSource() != menuButton) { menuButtonMousePressed(null); } } @Override public void onOptions(ActionEvent actionEvent) { showOptions(); } @Override public void onQuit(ActionEvent actionEvent) { quit(); } @Override public void onRedo(ActionEvent actionEvent) { mCollage.nextHistory(); updateToolButtons(); } @Override public void onStart(ActionEvent actionEvent) { } @Override public void onUndo(ActionEvent actionEvent) { mCollage.prevHistory(); updateToolButtons(); } }); mActionManager.addProfileListener(new ActionManager.ProfileListener() { @Override public void onAdd(ActionEvent actionEvent) { addImages(); } @Override public void onClear(ActionEvent actionEvent) { mCollage.clearFiles(); } @Override public void onClose(ActionEvent actionEvent) { setTitle("pacoma"); mActionManager.setEnabledDocumentActions(false); canvasPanel.close(); } @Override public void onEdit(ActionEvent actionEvent) { editCollage(mCollage); } @Override public void onRegenerate(ActionEvent actionEvent) { //TODO } @Override public void onNew(ActionEvent actionEvent) { editCollage(null); if (mCollage != null && mCollage.getName() != null) { setTitle(mCollage); canvasPanel.open(mCollage); mActionManager.getAction(ActionManager.CLEAR).setEnabled(false); mActionManager.getAction(ActionManager.REGENERATE).setEnabled(false); } } @Override public void onOpen(ActionEvent actionEvent) { initFileDialog(mCollageFileNameExtensionFilter); if (SimpleDialog.openFile()) { try { open(SimpleDialog.getPath()); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } } @Override public void onSave(ActionEvent actionEvent) { save(); } @Override public void onSaveAs(ActionEvent actionEvent) { saveAs(); } }); mCollagePropertyChangeListener = () -> { if (mCollage != null) { setTitle(mCollage); mActionManager.getAction(ActionManager.SAVE).setEnabled(true); mActionManager.getAction(ActionManager.CLEAR).setEnabled(mCollage.hasImages()); mActionManager.getAction(ActionManager.REGENERATE).setEnabled(mCollage.hasImages()); } }; mDropTarget = new DropTarget() { @Override public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); LinkedList<File> droppedFiles = new LinkedList<>( (List<File>) evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)); List<File> invalidFiles = new LinkedList<>(); droppedFiles.forEach((droppedFile) -> { if (droppedFile.isFile() && FilenameUtils.isExtension( droppedFile.getName().toLowerCase(Locale.getDefault()), Collage.FILE_EXT)) { //all ok } else { invalidFiles.add(droppedFile); } }); invalidFiles.forEach((invalidFile) -> { droppedFiles.remove(invalidFile); }); switch (droppedFiles.size()) { case 0: Message.error(MainFrame.this, Dict.Dialog.TITLE_IO_ERROR.toString(), "Not a valid collage file."); break; case 1: open(droppedFiles.getFirst()); break; default: Message.error(MainFrame.this, Dict.Dialog.TITLE_IO_ERROR.toString(), "Too many files dropped."); break; } } catch (UnsupportedFlavorException | IOException ex) { System.err.println(ex.getMessage()); } } }; canvasPanel.setDropTarget(mDropTarget); }
From source file:cnedu.ustcjd.widget.MultiSlider.java
private Thumb getMostMovable(LinkedList<Thumb> thumbs, MotionEvent event) { Thumb res = null;/* www . j a va 2 s . co m*/ int maxChange = 0; if (thumbs != null && !thumbs.isEmpty()) { if (thumbs.getFirst().getValue() == getValue(event, thumbs.getFirst())) return null; for (Thumb thumb : thumbs) { if (thumb.getThumb() == null || !thumb.isEnabled() || mDraggingThumbs.contains(thumb)) continue; int optValue = (getValue(event, thumbs.getFirst()) > thumb.getValue()) ? mScaleMax : mScaleMin; int currChange = Math.abs(thumb.getValue() - optThumbValue(thumb, optValue)); if (currChange > maxChange) { maxChange = currChange; res = thumb; } } } return res; }
From source file:de.tudarmstadt.ukp.wikipedia.parser.mediawiki.ModularParser.java
private NestedListContainer buildNestedList(SpanManager sm, ContentElementParsingParameters cepp, LinkedList<Span> lineSpans, lineType listType) { boolean numbered = listType == lineType.NESTEDLIST_NR; NestedListContainer result = new NestedListContainer(numbered); if (calculateSrcSpans) { result.setSrcSpan(new SrcSpan(sm.getSrcPos(lineSpans.getFirst().getStart()), -1)); }/*from ww w. j ava 2s .co m*/ LinkedList<Span> nestedListSpans = new LinkedList<Span>(); while (!lineSpans.isEmpty()) { Span s = lineSpans.getFirst(); if (listType != getLineType(sm, s)) { break; } nestedListSpans.add(new Span(s.getStart() + 1, s.getEnd()).trim(sm)); lineSpans.removeFirst(); } sm.manageList(nestedListSpans); if (calculateSrcSpans) { result.getSrcSpan().setEnd(sm.getSrcPos(nestedListSpans.getLast().getEnd())); } while (!nestedListSpans.isEmpty()) { Span s = nestedListSpans.getFirst(); lineType t = getLineType(sm, s); if (t == lineType.NESTEDLIST || t == lineType.NESTEDLIST_NR) { result.add(buildNestedList(sm, cepp, nestedListSpans, t)); } else { nestedListSpans.removeFirst(); result.add((NestedListElement) parseContentElement(sm, cepp, s, new NestedListElement())); } } sm.removeManagedList(nestedListSpans); return result; }
From source file:de.tudarmstadt.ukp.wikipedia.parser.mediawiki.ModularParser.java
private SectionContainer parseSections(SpanManager sm, ContentElementParsingParameters cepp, LinkedList<Span> lineSpans) { List<SectionContent> contentSections = new ArrayList<SectionContent>(); SectionContent sc = new SectionContent(1); if (calculateSrcSpans) { sc.setSrcSpan(new SrcSpan(sm.getSrcPos(lineSpans.getFirst().getStart()), -1)); }//from ww w .ja v a 2s . c o m // Identify the Line Type and call the necessary Function for the // further handling... while (!lineSpans.isEmpty()) { Span s = lineSpans.getFirst(); lineType t = getLineType(sm, s); switch (t) { case SECTION: contentSections.add(sc); int level = getSectionLevel(sm, s); sc = new SectionContent( parseContentElement(sm, cepp, new Span(s.getStart() + level, s.getEnd() - level).trim(sm)), level); lineSpans.removeFirst(); if (calculateSrcSpans) { sc.setSrcSpan(new SrcSpan(sm.getSrcPos(s.getStart()), -1)); } break; case HR: // remove the HR (----) and handle the rest as a parapraph line removeHr(sm, s); t = lineType.PARAGRAPH; case PARAGRAPH: case PARAGRAPH_BOXED: case PARAGRAPH_INDENTED: sc.addParagraph(buildParagraph(sm, cepp, lineSpans, t)); break; case NESTEDLIST: case NESTEDLIST_NR: sc.addNestedList(buildNestedList(sm, cepp, lineSpans, t)); break; case DEFINITIONLIST: sc.addDefinitionList(buildDefinitionList(sm, cepp, lineSpans)); break; case TABLE: sc.addTable(buildTable(sm, cepp, lineSpans)); break; case EMPTYLINE: lineSpans.removeFirst(); break; default: logger.error("unknown lineStart!: \"" + sm.substring(s) + "\""); lineSpans.removeFirst(); } } // add the remaining Section to the list. contentSections.add(sc); return buildSectionStructure(contentSections); }
From source file:com.bluros.updater.service.UpdateCheckService.java
private void recordAvailableUpdates(LinkedList<UpdateInfo> availableUpdates, Intent finishedIntent) { if (availableUpdates == null) { sendBroadcast(finishedIntent);/*from w w w . ja va 2 s . c o m*/ return; } // Store the last update check time and ensure boot check completed is true Date d = new Date(); PreferenceManager.getDefaultSharedPreferences(UpdateCheckService.this).edit() .putLong(Constants.LAST_UPDATE_CHECK_PREF, d.getTime()) .putBoolean(Constants.BOOT_CHECK_COMPLETED, true).apply(); int realUpdateCount = finishedIntent.getIntExtra(EXTRA_REAL_UPDATE_COUNT, 0); UpdateApplication app = (UpdateApplication) getApplicationContext(); // Write to log Log.i(TAG, "The update check successfully completed at " + d + " and found " + availableUpdates.size() + " updates (" + realUpdateCount + " newer than installed)"); if (realUpdateCount != 0 && !app.isMainActivityActive()) { // There are updates available // The notification should launch the main app Intent i = new Intent(this, UpdatesSettings.class); i.putExtra(UpdatesSettings.EXTRA_UPDATE_LIST_UPDATED, true); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT); Resources res = getResources(); String text = res.getQuantityString(R.plurals.not_new_updates_found_body, realUpdateCount, realUpdateCount); // Get the notification ready NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_system_update).setWhen(System.currentTimeMillis()) .setTicker(res.getString(R.string.not_new_updates_found_ticker)) .setContentTitle(res.getString(R.string.not_new_updates_found_title)).setContentText(text) .setContentIntent(contentIntent).setLocalOnly(true).setAutoCancel(true); LinkedList<UpdateInfo> realUpdates = new LinkedList<UpdateInfo>(); for (UpdateInfo ui : availableUpdates) { if (ui.isNewerThanInstalled()) { realUpdates.add(ui); } } Collections.sort(realUpdates, new Comparator<UpdateInfo>() { @Override public int compare(UpdateInfo lhs, UpdateInfo rhs) { /* sort by date descending */ long lhsDate = lhs.getDate(); long rhsDate = rhs.getDate(); if (lhsDate == rhsDate) { return 0; } return lhsDate < rhsDate ? 1 : -1; } }); NotificationCompat.InboxStyle inbox = new NotificationCompat.InboxStyle(builder) .setBigContentTitle(text); int added = 0, count = realUpdates.size(); for (UpdateInfo ui : realUpdates) { if (added < EXPANDED_NOTIF_UPDATE_COUNT) { inbox.addLine(ui.getName()); added++; } } if (added != count) { inbox.setSummaryText( res.getQuantityString(R.plurals.not_additional_count, count - added, count - added)); } builder.setStyle(inbox); builder.setNumber(availableUpdates.size()); if (count == 1) { i = new Intent(this, DownloadReceiver.class); i.setAction(DownloadReceiver.ACTION_START_DOWNLOAD); i.putExtra(DownloadReceiver.EXTRA_UPDATE_INFO, (Parcelable) realUpdates.getFirst()); PendingIntent downloadIntent = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_tab_download, res.getString(R.string.not_action_download), downloadIntent); } // Trigger the notification NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.notify(R.string.not_new_updates_found_title, builder.build()); } sendBroadcast(finishedIntent); }
From source file:org.dbpedia.spotlight.mediawiki.ModularParser.java
private SectionContainer parseSections(SpanManager sm, ContentElementParsingParameters cepp, LinkedList<Span> lineSpans) { List<SectionContent> contentSections = new ArrayList<SectionContent>(); SectionContent sc = new SectionContent(1); if (calculateSrcSpans) { try {//w w w . j a v a 2 s . co m sc.setSrcSpan(new SrcSpan(sm.getSrcPos(lineSpans.getFirst().getStart()), -1)); } catch (Exception e) { System.out.println("Parse error :" + sm.toString()); } } // Identify the Line Type and call the necessary Function for the // further handling... while (!lineSpans.isEmpty()) { Span s = lineSpans.getFirst(); lineType t = getLineType(sm, s); switch (t) { case SECTION: contentSections.add(sc); int level = getSectionLevel(sm, s); sc = new SectionContent( parseContentElement(sm, cepp, new Span(s.getStart() + level, s.getEnd() - level).trim(sm)), level); lineSpans.removeFirst(); if (calculateSrcSpans) { sc.setSrcSpan(new SrcSpan(sm.getSrcPos(s.getStart()), -1)); } break; case HR: // remove the HR (----) and handle the rest as a parapraph line removeHr(sm, s); t = lineType.PARAGRAPH; case PARAGRAPH: case PARAGRAPH_BOXED: case PARAGRAPH_INDENTED: sc.addParagraph(buildParagraph(sm, cepp, lineSpans, t)); break; case NESTEDLIST: case NESTEDLIST_NR: sc.addNestedList(buildNestedList(sm, cepp, lineSpans, t)); break; case DEFINITIONLIST: sc.addDefinitionList(buildDefinitionList(sm, cepp, lineSpans)); break; case TABLE: sc.addTable(buildTable(sm, cepp, lineSpans)); break; case EMPTYLINE: lineSpans.removeFirst(); break; default: logger.error("unknown lineStart!: \"" + sm.substring(s) + "\""); lineSpans.removeFirst(); } } // add the remaining Section to the list. contentSections.add(sc); return buildSectionStructure(contentSections); }