The following document contains the results of PMD's CPD 3.7.
File | Line |
---|---|
org\apache\shale\validator\converter\DoubleConverter.java | 42 |
org\apache\shale\validator\converter\IntegerConverter.java | 42 |
ShortValidator.getInstance(); // -------------------------------------------------------------- Properties /** * <p>The <code>Locale</code> to apply to this conversion, if any.</p> */ private Locale locale = null; /** * <p>Return the <code>Locale</code> to apply to this conversion, or * <code>null</code> to use the <code>Locale</code> for the current view.</p> */ public Locale getLocale() { return this.locale; } /** * <p>Set the <code>Locale</code> to apply to this conversion, or * <code>null</code> to use the <code>Locale</code> for the current view.</p> * * @param locale The new Locale */ public void setLocale(Locale locale) { this.locale = locale; } /** * <p>The formatting pattern to apply to this conversion, if any.</p> */ private String pattern = null; /** * <p>Return the <code>java.text.NumberFormat</code> pattern to apply * to this conversion, or <code>null</code> for using no pattern.</p> */ public String getPattern() { return this.pattern; } /** * <p>Set the <code>java.text.NumberFormat</code> pattern to apply to * this conversion, or <code>null</code> for using no pattern.</p> * * @param pattern The new formatting pattern */ public void setPattern(String pattern) { this.pattern = null; } // ------------------------------------------------------- Converter Methods /** {@inheritDoc} */ public Object getAsObject(FacesContext context, UIComponent component, String value) { if ((context == null) || (component == null)) { throw new NullPointerException(message(context, "common.null")); } try { if (locale == null) { return INSTANCE.validate(value, pattern, context.getViewRoot().getLocale()); } else { return INSTANCE.validate(value, pattern, locale); } } catch (Exception e) { throw new ConverterException(e); } } /** {@inheritDoc} */ public String getAsString(FacesContext context, UIComponent component, Object value) { if ((context == null) || (component == null)) { throw new NullPointerException(message(context, "common.null")); } try { if (locale == null) { return INSTANCE.format(value, pattern, context.getViewRoot().getLocale()); } else { return INSTANCE.format(value, pattern, locale); } } catch (Exception e) { throw new ConverterException(e); } } // ----------------------------------------------------- StateHolder Methods /** {@inheritDoc} */ public void restoreState(FacesContext context, Object state) { Object[] values = (Object[]) state; super.restoreState(context, values[0]); this.locale = (Locale) values[1]; this.pattern = (String) values[2]; } /** {@inheritDoc} */ public Object saveState(FacesContext context) { Object[] values = new Object[3]; values[0] = super.saveState(context); values[1] = this.locale; values[2] = this.pattern; return values; } } |