本文整理汇总了Java中org.gedcom4j.model.PersonalName类的典型用法代码示例。如果您正苦于以下问题:Java PersonalName类的具体用法?Java PersonalName怎么用?Java PersonalName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersonalName类属于org.gedcom4j.model包,在下文中一共展示了PersonalName类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSurnamesFromIndividual
import org.gedcom4j.model.PersonalName; //导入依赖的package包/类
/**
* Get all the surnames for an individual
*
* @param i
* the individual
* @return a Set of all the surnames (as Strings)
*/
protected Set<String> getSurnamesFromIndividual(Individual i) {
TreeSet<String> result = new TreeSet<>();
Pattern pattern = Pattern.compile(".*\\/(.*)\\/.*");
for (PersonalName pn : i.getNames()) {
if ("<No /name>/".equals(pn.getBasic())) {
result.add("");
continue;
}
;
if (pn.getSurname() != null) {
result.add(pn.getSurname().getValue());
}
if (pn.getBasic() != null) {
Matcher matcher = pattern.matcher(pn.getBasic());
while (matcher.find()) {
result.add(matcher.group(1));
}
}
}
return result;
}
示例2: GedcomName
import org.gedcom4j.model.PersonalName; //导入依赖的package包/类
public GedcomName(PersonalName name) {
prefix = Optional.ofNullable(name.prefix).map(Object::toString);
Map<Boolean, List<String>> nameParts = NAME_PARTS.splitAsStream(name.basic)
.collect(partitioningBy(IS_SURNAME));
given = nameParts.get(false);
surname = nameParts.get(true).stream()
.findFirst()
.map(s -> s.substring(1, s.length()-1));
suffix = Optional.ofNullable(name.suffix).map(Object::toString);
}
示例3: analyze
import org.gedcom4j.model.PersonalName; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<AnalysisResult> analyze(Gedcom g) {
List<AnalysisResult> result = new ArrayList<>();
for (Family f : g.getFamilies().values()) {
if (f.getChildren() == null) {
continue;
}
// Build a map of each first name and all the kids who have that first name
Map<String, Set<Individual>> kidsByFirstName = new HashMap<>();
for (IndividualReference iRef : f.getChildren()) {
Individual kid = iRef.getIndividual();
for (PersonalName pn : kid.getNames(true)) {
String gn = null;
if (pn.getGivenName() != null && isSpecified(pn.getGivenName().getValue())) {
gn = pn.getGivenName().getValue();
} else if (isSpecified(pn.getBasic())) {
gn = pn.getBasic().trim();
int firstSlash = gn.indexOf('/');
if (firstSlash > 0) {
gn = gn.substring(0, firstSlash).trim();
} else {
gn = null;
}
}
if (isSpecified(gn)) {
Set<Individual> kidsWithThisFirstName = kidsByFirstName.get(gn);
if (kidsWithThisFirstName == null) {
kidsWithThisFirstName = new HashSet<>();
kidsByFirstName.put(gn, kidsWithThisFirstName);
}
kidsWithThisFirstName.add(kid);
}
}
}
// Check the map for any names with more than one kid in the family who has it
for (Entry<String, Set<Individual>> e : kidsByFirstName.entrySet()) {
if (e.getValue().size() > 1 && isSpecified(e.getKey())) {
result.add(new AnalysisResult("Family", getFamilyDescriptor(f), "Children", e.getKey(), e.getValue().size()
+ " children with same name"));
}
}
}
return result;
}
示例4: analyze
import org.gedcom4j.model.PersonalName; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<AnalysisResult> analyze(Gedcom g) {
List<AnalysisResult> result = new ArrayList<>();
for (Individual i : g.getIndividuals().values()) {
if (i.getNames() == null || i.getNames().isEmpty()) {
continue;
}
boolean hadSurname = false;
boolean somethingOtherThanSurname = false;
for (PersonalName pn : i.getNames()) {
if (isSpecified(pn.getSurname())) {
// Don't count empty surnames
hadSurname = true;
}
if (pn.getBasic() != null) {
if (pn.getBasic().contains("/") && !pn.getBasic().contains("//")) {
hadSurname = true;
}
// Characters before a slash would be something other than a surname
int firstSlash = pn.getBasic().indexOf('/');
if (firstSlash > 0) {
somethingOtherThanSurname = true;
break; // Don't need to check any more names
}
}
// Check the name components too
if (isSpecified(pn.getGivenName()) || isSpecified(pn.getNickname())) {
somethingOtherThanSurname = true;
break; // Don't need to check any more names
}
}
if (somethingOtherThanSurname || !hadSurname) {
// Next person
continue;
}
result.add(new AnalysisResult("Individual", i.getFormattedName(), null, null, "No name other than surname available."));
}
return result;
}