@Test public void testSetAsTextString() { editor.setAsText("month"); Assert.assertEquals(Precision.MONTH, editor.getValue()); editor.setAsText(" month"); Assert.assertEquals(Precision.MONTH, editor.getValue()); editor.setAsText("month "); Assert.assertEquals(Precision.MONTH, editor.getValue()); editor.setAsText("Month"); Assert.assertEquals(Precision.MONTH, editor.getValue()); editor.setAsText("MONTH"); Assert.assertEquals(Precision.MONTH, editor.getValue()); editor.setAsText("YEAR"); Assert.assertEquals(Precision.YEAR, editor.getValue()); editor.setAsText("date"); Assert.assertEquals(Precision.DATE, editor.getValue()); editor.setAsText("hour"); Assert.assertEquals(Precision.HOUR, editor.getValue()); editor.setAsText("minute"); Assert.assertEquals(Precision.MINUTE, editor.getValue()); editor.setAsText("Second"); Assert.assertEquals(Precision.SECOND, editor.getValue()); editor.setAsText("milliseconD"); Assert.assertEquals(Precision.MILLISECOND, editor.getValue()); editor.setAsText("fred"); Assert.assertNull(editor.getValue()); }
public void setAsText(String text) throws IllegalArgumentException { if (text == null) { throw new IllegalArgumentException("String is 'null'"); } text = text.trim().toUpperCase(); if (text.equals("YEAR")) { setValue(Precision.YEAR); } else if (text.equals("MONTH")) { setValue(Precision.MONTH); } else if (text.equals("DATE")) { setValue(Precision.DATE); } else if (text.equals("HOUR")) { setValue(Precision.HOUR); } else if (text.equals("MINUTE")) { setValue(Precision.MINUTE); } else if (text.equals("SECOND")) { setValue(Precision.SECOND); } else if (text.equals("MILLISECOND")) { setValue(Precision.MILLISECOND); } else { setValue(null); } }
PrecisionEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { if (text == null) { throw new IllegalArgumentException("String is 'null'"); } text = text.trim().toUpperCase(); if (text.equals("YEAR")) { setValue(Precision.YEAR); } else if (text.equals("MONTH")) { setValue(Precision.MONTH); } else if (text.equals("DATE")) { setValue(Precision.DATE); } else if (text.equals("HOUR")) { setValue(Precision.HOUR); } else if (text.equals("MINUTE")) { setValue(Precision.MINUTE); } else if (text.equals("SECOND")) { setValue(Precision.SECOND); } else if (text.equals("MILLISECOND")) { setValue(Precision.MILLISECOND); } else { setValue(null); } } }
PrecisionEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { if (text == null) { throw new IllegalArgumentException("String is 'null'"); } text = text.trim().toUpperCase(); if (text.equals("YEAR")) { setValue(Precision.YEAR); } else if (text.equals("MONTH")) { setValue(Precision.MONTH); } else if (text.equals("DATE")) { setValue(Precision.DATE); } else if (text.equals("HOUR")) { setValue(Precision.HOUR); } else if (text.equals("MINUTE")) { setValue(Precision.MINUTE); } else if (text.equals("SECOND")) { setValue(Precision.SECOND); } else if (text.equals("MILLISECOND")) { setValue(Precision.MILLISECOND); } else { setValue(null); } } PrecisionEditor();  PrecisionEditor(Object source); }
PrecisionEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { if (text == null) { throw new IllegalArgumentException("String is 'null'"); } text = text.trim().toUpperCase(); if (text.equals("YEAR")) { setValue(Precision.YEAR); } else if (text.equals("MONTH")) { setValue(Precision.MONTH); } else if (text.equals("DATE")) { setValue(Precision.DATE); } else if (text.equals("HOUR")) { setValue(Precision.HOUR); } else if (text.equals("MINUTE")) { setValue(Precision.MINUTE); } else if (text.equals("SECOND")) { setValue(Precision.SECOND); } else if (text.equals("MILLISECOND")) { setValue(Precision.MILLISECOND); } else { setValue(null); } } PrecisionEditor();  PrecisionEditor(Object source); String getAsText(); void setAsText(String text); }
PrecisionEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { if (text == null) { throw new IllegalArgumentException("String is 'null'"); } text = text.trim().toUpperCase(); if (text.equals("YEAR")) { setValue(Precision.YEAR); } else if (text.equals("MONTH")) { setValue(Precision.MONTH); } else if (text.equals("DATE")) { setValue(Precision.DATE); } else if (text.equals("HOUR")) { setValue(Precision.HOUR); } else if (text.equals("MINUTE")) { setValue(Precision.MINUTE); } else if (text.equals("SECOND")) { setValue(Precision.SECOND); } else if (text.equals("MILLISECOND")) { setValue(Precision.MILLISECOND); } else { setValue(null); } } PrecisionEditor();  PrecisionEditor(Object source); String getAsText(); void setAsText(String text);  }