Package com.cardence.lawshelf.cfr.adapters

Source Code of com.cardence.lawshelf.cfr.adapters.CfrSubChapterSectionAdapter

package com.cardence.lawshelf.cfr.adapters;

import java.util.List;

import com.cardence.lawshelf.cfr.CfrBaseSection;
import com.cardence.lawshelf.cfr.CfrContentContainer;
import com.cardence.lawshelf.cfr.jaxb.HD;
import com.cardence.lawshelf.cfr.jaxb.SUBCHAP;

public class CfrSubChapterSectionAdapter extends CfrBaseSection {

  public CfrSubChapterSectionAdapter(SUBCHAP subChapter) {
    super(findHeading(subChapter), null);
  }

  private static String findHeading(SUBCHAP subChapter) {
    final CfrContentContainer content = new CfrContentContainer();
    final List<Object> unknownObjects = subChapter.getPRTPAGEOrRESERVEDOrHD();
    final HD hd = findHD(unknownObjects);
    if (hd == null) {
      final String alternativeText = findAlternativeToHD(unknownObjects);
      if (alternativeText == null) {
        throw new RuntimeException("Could not find a header text for subchapter");
      }
      content.addContent(alternativeText);
    } else {
      content.addContent(hd);
    }

    return content.getContentText();
  }
}
TOP

Related Classes of com.cardence.lawshelf.cfr.adapters.CfrSubChapterSectionAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.