*/
public abstract void output(PrintWriter out);
+ /**
+ * @see Name#toInitialsString()
+ */
+ public abstract String toInitialsString();
+
}
private static class SingleName extends SchemedName {
return singlePart.getValue();
}
+ @Override
+ public String toInitialsString() {
+ return singlePart.getValue().substring(0, 1);
+ }
+
@Override
public NameSchemaType getSchemeName() {
return NameSchemaType.SINGLE;
public void output(PrintWriter out) {
out.print("<span class='sname'>");
out.print(HTMLEncoder.encodeHTML(singlePart.getValue()));
- out.println("</span>");
+ out.print("</span>");
}
}
@Override
public void output(PrintWriter out) {
- outputNameParts(out, "fname", firstNames);
- outputNameParts(out, "lname", lastNames);
- outputNameParts(out, "suffix", suffixes);
+ outputNameParts(out, "fname", firstNames, false);
+ outputNameParts(out, "lname", lastNames, true);
+ outputNameParts(out, "suffix", suffixes, true);
}
- private void outputNameParts(PrintWriter out, String type, NamePart[] input) {
+ private void outputNameParts(PrintWriter out, String type, NamePart[] input, boolean leadingSpace) {
StringBuilder res;
res = new StringBuilder();
appendArray(res, input);
if (res.length() > 0) {
res.deleteCharAt(res.length() - 1);
+ if (leadingSpace) {
+ out.print(" ");
+ }
out.print("<span class='" + type + "'>");
out.print(HTMLEncoder.encodeHTML(res.toString()));
- out.println("</span>");
+ out.print("</span>");
}
}
public String toAbbreviatedString() {
return firstNames[0].getValue() + " " + lastNames[0].getValue().charAt(0) + ".";
}
+
+ @Override
+ public String toInitialsString() {
+
+ String initals = getInitialByNamePart(firstNames, lastNames, suffixes);
+
+ return initals;
+ }
}
private int id;
public void output(PrintWriter out, Language l, Map<String, Object> vars) {
out.print("<span class=\"names\">");
scheme.output(out);
- out.print("</span> ");
+ out.print("</span>");
}
/**
/**
* Transforms this String into a short form. This short form should not be
- * unique. (For "western" names this would be
- * "firstName firstCharOfLastName.".)
+ * unique. (For "western" names this would be "firstName
+ * firstCharOfLastName.".)
*
* @return the short form of the name
*/
return scheme.toAbbreviatedString();
}
- public int getAssurancePoints() {
+ /**
+ * Transforms this Name object into a short form. This short form might not
+ * be unique. (For "western" names this would be all first letters of each
+ * name part)
+ *
+ * @return the short form of the name
+ */
+ public String toInitialsString() {
+ return scheme.toInitialsString();
+ }
+
+ public int getVerificationPoints() {
try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT SUM(`points`) FROM (SELECT DISTINCT ON (`from`, `method`) `points` FROM `notary` WHERE `to`=? AND `deleted` IS NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP) ORDER BY `from`, `method`, `when` DESC) AS p")) {
query.setInt(1, getId());
}
return owner;
}
+
+ private static String getInitialByNamePart(NamePart[]... npa) {
+ StringBuilder initals = new StringBuilder();
+ for (NamePart[] np : npa) {
+ initals.append(getInitialByNamePart(np));
+ }
+ return initals.toString();
+ }
+
+ private static String getInitialByNamePart(NamePart[] np) {
+ StringBuilder initals = new StringBuilder();
+ for (NamePart p : np) {
+ switch (p.getValue()) {
+ case "-":
+ case "/":
+ break;
+ default:
+ initals.append(p.getValue().substring(0, 1).toUpperCase());
+ break;
+ }
+ }
+ return initals.toString();
+ }
}