@Test public void testFactoryFailures() { try { Appt.fromString(null); fail("did not throw expected NullPointerException"); } catch (NullPointerException e) { } try { Appt.fromString("random garbage"); fail("did not throw expected IllegalArumentException"); } catch (IllegalArgumentException e) { } try { Appt.fromString("1951 foo 24 6 0 birthday"); fail("did not throw expected IllegalArumentException"); } catch (IllegalArgumentException e) { } }
public static Appt fromString(String s) { System.out.println("Appt.fromString(): " + s); StringTokenizer st = new StringTokenizer(s.replaceAll("[-:]", " ")); if (st.countTokens() < 6) throw new IllegalArgumentException("Too few fields in " + s); int y = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int h = Integer.parseInt(st.nextToken()); int i = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); while (st.hasMoreElements()) { sb.append(st.nextToken()); if (st.hasMoreElements()) sb.append(' '); } return new Appt(y, m, d, h, i, sb.toString()); }
Appt implements Comparable<Appt> { public static Appt fromString(String s) { System.out.println("Appt.fromString(): " + s); StringTokenizer st = new StringTokenizer(s.replaceAll("[-:]", " ")); if (st.countTokens() < 6) throw new IllegalArgumentException("Too few fields in " + s); int y = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int h = Integer.parseInt(st.nextToken()); int i = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); while (st.hasMoreElements()) { sb.append(st.nextToken()); if (st.hasMoreElements()) sb.append(' '); } return new Appt(y, m, d, h, i, sb.toString()); } }
Appt implements Comparable<Appt> { public static Appt fromString(String s) { System.out.println("Appt.fromString(): " + s); StringTokenizer st = new StringTokenizer(s.replaceAll("[-:]", " ")); if (st.countTokens() < 6) throw new IllegalArgumentException("Too few fields in " + s); int y = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int h = Integer.parseInt(st.nextToken()); int i = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); while (st.hasMoreElements()) { sb.append(st.nextToken()); if (st.hasMoreElements()) sb.append(' '); } return new Appt(y, m, d, h, i, sb.toString()); } Appt(int y, int mo, int d, int h, int min, String text);  Appt(LocalDateTime datetime, String text);  Appt(LocalDate date, LocalTime time, String text); }
Appt implements Comparable<Appt> { public static Appt fromString(String s) { System.out.println("Appt.fromString(): " + s); StringTokenizer st = new StringTokenizer(s.replaceAll("[-:]", " ")); if (st.countTokens() < 6) throw new IllegalArgumentException("Too few fields in " + s); int y = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int h = Integer.parseInt(st.nextToken()); int i = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); while (st.hasMoreElements()) { sb.append(st.nextToken()); if (st.hasMoreElements()) sb.append(' '); } return new Appt(y, m, d, h, i, sb.toString()); } Appt(int y, int mo, int d, int h, int min, String text);  Appt(LocalDateTime datetime, String text);  Appt(LocalDate date, LocalTime time, String text); void setRep(int typ, int intv, int count); boolean matches(int y, int m, int d); @Override int compareTo(Appt a2); @Override int hashCode(); @Override boolean equals(Object o2); @Override String toString(); static Appt fromString(String s); int getDay(); int getHour(); int getMinute(); int getMonth(); String getText(); int getYear(); }
Appt implements Comparable<Appt> { public static Appt fromString(String s) { System.out.println("Appt.fromString(): " + s); StringTokenizer st = new StringTokenizer(s.replaceAll("[-:]", " ")); if (st.countTokens() < 6) throw new IllegalArgumentException("Too few fields in " + s); int y = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int h = Integer.parseInt(st.nextToken()); int i = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); while (st.hasMoreElements()) { sb.append(st.nextToken()); if (st.hasMoreElements()) sb.append(' '); } return new Appt(y, m, d, h, i, sb.toString()); } Appt(int y, int mo, int d, int h, int min, String text);  Appt(LocalDateTime datetime, String text);  Appt(LocalDate date, LocalTime time, String text); void setRep(int typ, int intv, int count); boolean matches(int y, int m, int d); @Override int compareTo(Appt a2); @Override int hashCode(); @Override boolean equals(Object o2); @Override String toString(); static Appt fromString(String s); int getDay(); int getHour(); int getMinute(); int getMonth(); String getText(); int getYear(); static final int NONE; static final int HOURLY; static final int DAILY; static final int WEEKLY; static final int MONTHLY_NUMDAY_OF_M; static final int MONTHLY_WEEKDAY_OF_M; static final int YEARLY; static final int FOREVER; }