@Test public void initials() { CSLName[] names = NameParser.parse("S. C. Johnson"); assertEquals(1, names.length); assertEquals("S. C.", names[0].getGiven()); assertEquals("Johnson", names[0].getFamily()); }
public static CSLName[] parse(String names) { CharStream cs = CharStreams.fromString(names); InternalNameLexer lexer = new InternalNameLexer(cs); lexer.removeErrorListeners(); CommonTokenStream tokens = new CommonTokenStream(lexer); InternalNameParser parser = new InternalNameParser(tokens); parser.removeErrorListeners(); NamesContext ctx = parser.names(); if (ctx.result.isEmpty() || ctx.exception != null || parser.getNumberOfSyntaxErrors() > 0) { return new CSLName[] { new CSLNameBuilder().literal(names).build() }; } return ctx.result.toArray(new CSLName[0]); }
NameParser { public static CSLName[] parse(String names) { CharStream cs = CharStreams.fromString(names); InternalNameLexer lexer = new InternalNameLexer(cs); lexer.removeErrorListeners(); CommonTokenStream tokens = new CommonTokenStream(lexer); InternalNameParser parser = new InternalNameParser(tokens); parser.removeErrorListeners(); NamesContext ctx = parser.names(); if (ctx.result.isEmpty() || ctx.exception != null || parser.getNumberOfSyntaxErrors() > 0) { return new CSLName[] { new CSLNameBuilder().literal(names).build() }; } return ctx.result.toArray(new CSLName[0]); } }
NameParser { public static CSLName[] parse(String names) { CharStream cs = CharStreams.fromString(names); InternalNameLexer lexer = new InternalNameLexer(cs); lexer.removeErrorListeners(); CommonTokenStream tokens = new CommonTokenStream(lexer); InternalNameParser parser = new InternalNameParser(tokens); parser.removeErrorListeners(); NamesContext ctx = parser.names(); if (ctx.result.isEmpty() || ctx.exception != null || parser.getNumberOfSyntaxErrors() > 0) { return new CSLName[] { new CSLNameBuilder().literal(names).build() }; } return ctx.result.toArray(new CSLName[0]); }  }
NameParser { public static CSLName[] parse(String names) { CharStream cs = CharStreams.fromString(names); InternalNameLexer lexer = new InternalNameLexer(cs); lexer.removeErrorListeners(); CommonTokenStream tokens = new CommonTokenStream(lexer); InternalNameParser parser = new InternalNameParser(tokens); parser.removeErrorListeners(); NamesContext ctx = parser.names(); if (ctx.result.isEmpty() || ctx.exception != null || parser.getNumberOfSyntaxErrors() > 0) { return new CSLName[] { new CSLNameBuilder().literal(names).build() }; } return ctx.result.toArray(new CSLName[0]); }  static CSLName[] parse(String names); }
NameParser { public static CSLName[] parse(String names) { CharStream cs = CharStreams.fromString(names); InternalNameLexer lexer = new InternalNameLexer(cs); lexer.removeErrorListeners(); CommonTokenStream tokens = new CommonTokenStream(lexer); InternalNameParser parser = new InternalNameParser(tokens); parser.removeErrorListeners(); NamesContext ctx = parser.names(); if (ctx.result.isEmpty() || ctx.exception != null || parser.getNumberOfSyntaxErrors() > 0) { return new CSLName[] { new CSLNameBuilder().literal(names).build() }; } return ctx.result.toArray(new CSLName[0]); }  static CSLName[] parse(String names);  }