/** * Build up this name form with a field. * * @param field The field. * @return this. */ public NameForm field(Field field) { addField(field); return this; }
/** * Build up this name form with a part. * * @param part The part. * @return this. */ public NameForm part(NamePart part) { addPart(part); return this; }
/** * Build up this name form with full text. * * @param fullText The full text. * @return this */ public NameForm fullText(String fullText) { setFullText(fullText); return this; }
@Override public void visitNameForm(NameForm form) { this.contextStack.push(form); List<NamePart> parts = form.getParts(); if (parts != null) { for (NamePart part : parts) { if (part != null) { part.accept(this); } } } List<Field> fields = form.getFields(); if (fields != null) { for (Field field : fields) { if (field != null) { field.accept(this); } } } this.contextStack.pop(); }
NameForm nameForm = person.getName().getNameForm(); if (nameForm != null) { if (nameForm.getFullText() != null) { return nameForm.getFullText(); if (nameForm.getParts() != null) { StringBuilder fullName = new StringBuilder(); boolean isFirst = true; for (NamePart namePart : nameForm.getParts()) { if (namePart.getValue() != null && namePart.getValue().length() > 0) { fullName.append(namePart.getValue());
@Override public String toString() { return "type=" + getKnownType() + ",nameForms[0]=" + (nameForms == null ? "null" : nameForms.get(0).getFullText()) + ",pref=" + getPreferred(); }
/** * Build up this name form with a lang. * * @param lang The lang. * @return this. */ public NameForm lang(String lang) { setLang(lang); return this; }
public Name(String fullText, NamePart... parts) { addNameForm(new NameForm(fullText, parts)); }
/** * Gets a specific part of the name * @param namePartType specific part of the name to retrieve * @return the specific part of the name that matches the given NamePartType */ public String getPart(NamePartType namePartType) { if(this.nameForms == null || this.nameForms.isEmpty() || this.nameForms.get(0) == null || this.nameForms.get(0).getParts() == null) { return null; } for(NamePart namePart : this.nameForms.get(0).getParts()) { if(namePart.getKnownType() == namePartType) { return namePart.getValue(); } } return null; }
@Override public void visitName(Name name) { this.contextStack.push(name); visitConclusion(name); List<NameForm> forms = name.getNameForms(); if (forms != null) { for (NameForm form : forms) { if (form != null) { form.accept(this); } } } this.contextStack.pop(); }
name = person.getNames().get(0).getNameForms().get(0).getFullText();
public NameForm(String fullText, NamePart... parts) { this.fullText = fullText; for (NamePart part : parts) { addPart(part); } }
/** * Build up this name form with a part. * * @param partType The part type. * @param value The value. * @return this. */ public NameForm part(NamePartType partType, String value) { addPart(new NamePart(partType, value)); return this; }