AssigneeNode extends DOMFragmentReader<List<Assignee>> { @Override public List<Assignee> read() { Map<String, Assignee> assigneeList = new LinkedHashMap<String, Assignee>(); List<Node> applicantAssignees = document.selectNodes(APPLICANT_ASSIGNEE_PATH); if (!applicantAssignees.isEmpty()) { for (Assignee assign : readEntityNodes(applicantAssignees)) { assigneeList.put(assign.getName().getName().toLowerCase(), assign); } } List<Node> assignees = document.selectNodes(FRAGMENT_PATH); if (!assignees.isEmpty()) { for (Assignee assign : readEntityNodes(assignees)) { assigneeList.put(assign.getName().getName().toLowerCase(), assign); } } return new ArrayList<Assignee>(assigneeList.values()); } AssigneeNode(Document document); @Override List<Assignee> read();  }
@Test public void AssigneeOrg() throws DocumentException { String xml ="<us-patent-grant><us-bibliographic-data-grant><assignees>\r\n" + "<assignee>\r\n" + "<addressbook>\r\n" + "<orgname>Company, Incorporated</orgname>\r\n" + "<role>02</role>\r\n" + "<address>\r\n" + "<city>McLean</city>\r\n" + "<state>VA</state>\r\n" + "<country>US</country>\r\n" + "</address>\r\n" + "</addressbook>\r\n" + "</assignee>\r\n" + "</assignees></us-bibliographic-data-grant></us-patent-grant>"; Document doc = DocumentHelper.parseText(xml); List<Assignee> assignees = new AssigneeNode(doc).read(); assertEquals(1, assignees.size()); assertEquals(Assignee.RoleType.T2, assignees.get(0).getRole()); assertEquals("U.S. company or corporation", assignees.get(0).getRoleDesc()); assertEquals("Company, Incorporated", ((NameOrg) assignees.get(0).getName()).getName()); assertEquals(CountryCode.US, assignees.get(0).getAddress().getCountry()); assertEquals("McLean", assignees.get(0).getAddress().getCity()); assertEquals("VA", assignees.get(0).getAddress().getState()); }
@Test public void AssigneePerson() throws DocumentException { String xml ="<us-patent-grant><us-bibliographic-data-grant><assignees>\r\n" + "<assignee>\r\n" + "<addressbook>\r\n" + "<last-name>Doe</last-name>\r\n" + "<first-name>John</first-name>\r\n" + "<role>04</role>\r\n" + "<address>\r\n" + "<city>Orlando</city>\r\n" + "<state>FL</state>\r\n" + "<country>US</country>\r\n" + "</address>\r\n" + "</addressbook>\r\n" + "</assignee>\r\n" + "</assignees></us-bibliographic-data-grant></us-patent-grant>"; Document doc = DocumentHelper.parseText(xml); List<Assignee> assignees = new AssigneeNode(doc).read(); assertEquals(1, assignees.size()); assertEquals(Assignee.RoleType.T4, assignees.get(0).getRole()); assertEquals("U.S individual", assignees.get(0).getRoleDesc()); assertEquals("John", ((NamePerson) assignees.get(0).getName()).getFirstName()); assertEquals("Doe", ((NamePerson) assignees.get(0).getName()).getLastName()); assertEquals(CountryCode.US, assignees.get(0).getAddress().getCountry()); assertEquals("Orlando", assignees.get(0).getAddress().getCity()); assertEquals("FL", assignees.get(0).getAddress().getState()); }