本文整理汇总了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;
}