package cn.edu.bjut.chapter6; 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(); } }