当前位置: 首页>>代码示例>>Java>>正文


Java FamilySpouse类代码示例

本文整理汇总了Java中org.gedcom4j.model.FamilySpouse的典型用法代码示例。如果您正苦于以下问题:Java FamilySpouse类的具体用法?Java FamilySpouse怎么用?Java FamilySpouse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FamilySpouse类属于org.gedcom4j.model包,在下文中一共展示了FamilySpouse类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: analyze

import org.gedcom4j.model.FamilySpouse; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public List<AnalysisResult> analyze(Gedcom g) {

    List<AnalysisResult> result = new ArrayList<>();

    for (Individual i : g.getIndividuals().values()) {
        boolean foundSpouse = false;
        if (i.getFamiliesWhereSpouse() != null) {
            // Having FAMS records is not proof of actually having a spouse - there could have just been a note saying "did not
            // marry" or something like that
            for (FamilySpouse fs : i.getFamiliesWhereSpouse()) {
                Family f = fs.getFamily();
                Individual w = f.getWife() == null ? null : f.getWife().getIndividual();
                Individual h = f.getHusband() == null ? null : f.getHusband().getIndividual();
                boolean someoneElseIsTheWife = w != null && !i.equals(w);
                boolean someoneElseIsTheHusband = h != null && !i.equals(h);
                if (someoneElseIsTheWife || someoneElseIsTheHusband) {
                    foundSpouse = true;
                    break;
                }
            }
        }
        if (foundSpouse) {
            continue;
        }

        DateAndString birthDate = getBirthDate(i, ImpreciseDatePreference.FAVOR_EARLIEST);
        if (birthDate == null || birthDate.getDate() == null) {
            // can't tell how old they are/were without a parseable birth date
            continue;
        }

        /*
         * Make sure they survived into adulthood by comparing their birth date to their latest death date (if they have one) or
         * the current date
         */
        DateAndString deathDate = getDeathDate(i, ImpreciseDatePreference.FAVOR_LATEST);
        Date endDate = (deathDate == null || deathDate.getDate() == null ? new Date() : deathDate.getDate());

        long difference = endDate.getTime() - birthDate.getDate().getTime();
        long yearsOld = difference / (365L * 24 * 60 * 60 * 1000); // approximate
        if (yearsOld >= 18) {
            String problemDescription = (deathDate == null || deathDate.getDate() == null ? "Born " + yearsOld
                    + " years ago with no death date available" : "Lived to " + yearsOld) + ", but no spouses";
            result.add(new AnalysisResult("Individual", i.getFormattedName(), null, null, problemDescription));
        }

    }

    return result;
}
 
开发者ID:frizbog,项目名称:gedantic,代码行数:55,代码来源:AdultsWithoutSpousesAnalyzer.java


注:本文中的org.gedcom4j.model.FamilySpouse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。