package cn.edu.bjut.chapter5; public class Patent { private String applicationNo; private Date applicationDate; private Ipc[] ipcs; private Cpc[] cpcs; private final static String SEPERATOR = ","; public Patent(String applicationNo, Date applicationDate, Ipc[] ipcs, Cpc[] cpcs) { this.applicationNo = applicationNo; this.applicationDate = applicationDate; this.ipcs = ipcs; this.cpcs = cpcs; } public Patent(String applicationNo, String applicationDate, String multiIpcs, String multiCpcs, char position, char value) { this.applicationNo = applicationNo; this.applicationDate = new Date(applicationDate); String[] ipcSymbols = multiIpcs.split(SEPERATOR); this.ipcs = new Ipc[ipcSymbols.length]; for (int i = 0; i < ipcSymbols.length; i++) { ipcs[i] = new Ipc(ipcSymbols[i].trim()); } String[] cpcSymbols = multiCpcs.split(SEPERATOR); this.cpcs = new Cpc[cpcSymbols.length]; for (int i = 0; i < cpcSymbols.length; i++) { cpcs[i] = new Cpc(cpcSymbols[i].trim(), position, value); } } public String getApplicationNo() { return applicationNo; } public void setApplicationNo(String applicationNo) { this.applicationNo = applicationNo; } public Date getApplicationDate() { return applicationDate; } public void setApplicationDate(Date applicationDate) { this.applicationDate = applicationDate; } public Ipc[] getIpcs() { return ipcs; } public void setIpcs(Ipc[] ipcs) { this.ipcs = ipcs; } public Cpc[] getCpcs() { return cpcs; } public void setCpcs(Cpc[] cpcs) { this.cpcs = cpcs; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(applicationNo + "\t" + applicationDate + "\t"); sb.append("["); for (int i = 0; i < ipcs.length - 1; i++) { sb.append(ipcs[i] + SEPERATOR); } sb.append(ipcs[ipcs.length - 1] + "]\t"); sb.append("["); for (int i = 0; i < cpcs.length - 1; i++) { sb.append(cpcs[i] + SEPERATOR); } sb.append(cpcs[cpcs.length - 1] + "]"); return sb.toString(); } public static void main(String[] args) { Patent[] patents = new Patent[5]; patents[0] = new Patent("14725838", "2015-05-29", "A23B 5/04, A23B 5/045", "A23B 5/04, A23B 5/45, A23L 15/20", 'F', 'I'); patents[1] = new Patent("14814205", "2015-07-30", "A61H 33/00, C01B 33/107, E04B 1/84", "A61H 33/6063, A61H 33/6042", 'F', 'I'); patents[2] = new Patent("15189723", "2016-06-22", "D04B 1/00", "B65H2301/44514, C01B 33/1071, F16F 15/2, H01L 27/14641", 'L', 'A'); patents[3] = new Patent("14711011", "2015-05-13", "B32B 17/10, B32B 27/32", "G06F 3/485", 'L', 'A'); patents[4] = new Patent("14515267", "2014-10-15", "F16F 15/02, G09G 5/34, G06F 3/0485", "A01B 15/06, A01B 15/06", 'L', 'I'); for (Patent patent: patents) { System.out.println(patent); } } }