Package com.cardence.lawshelf.cfr.adapters

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

package com.cardence.lawshelf.cfr.adapters;

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.SUBTITLE;

public class CfrSubTitleSectionAdapter extends CfrBaseSection {

  public CfrSubTitleSectionAdapter(SUBTITLE subTitle) {
    super(findHeading(subTitle), null);
  }

  public CfrSubTitleSectionAdapter(SUBTITLE subTitle, String parentReference) {
    super(findHeading(subTitle), parentReference);
  }

  private static String findHeading(SUBTITLE subTitle) {
    final CfrContentContainer content = new CfrContentContainer();
    final HD hd = subTitle.getHD();
    if (hd == null) {
      final String alternativeText = subTitle.getRESERVED();
      if (alternativeText == null) {
        throw new RuntimeException("Could not find a header text for subtitle");
      }
      content.addContent(alternativeText);
    } else {
      content.addContent(hd);
    }

    return content.getContentText();
  }

}
TOP

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

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.