當前位置: 首頁>>代碼示例>>Java>>正文


Java PersonalName類代碼示例

本文整理匯總了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;
}
 
開發者ID:frizbog,項目名稱:gedantic,代碼行數:29,代碼來源:AAnalyzer.java

示例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);
}
 
開發者ID:dhemery,項目名稱:ancestors-java8,代碼行數:11,代碼來源:GedcomName.java

示例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;
}
 
開發者ID:frizbog,項目名稱:gedantic,代碼行數:53,代碼來源:ChildrenWithSameFirstNamesAnalyzer.java

示例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;
}
 
開發者ID:frizbog,項目名稱:gedantic,代碼行數:50,代碼來源:PeopleWithOnlySurnamesAnalyzer.java


注:本文中的org.gedcom4j.model.PersonalName類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。