Author: ivaynberg Date: Sun May 25 14:22:37 2008 New Revision: 660041 URL: http://svn.apache.org/viewvc?rev=660041&view=rev Log: iconverterlocator cleanup
Modified: wicket/trunk/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.java wicket/trunk/wicket-quickstart/jetty-quickstart.launch wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java wicket/trunk/wicket/src/main/java/org/apache/wicket/IConverterLocator.java wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java Modified: wicket/trunk/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java URL: http://svn.apache.org/viewvc/wicket/trunk/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java (original) +++ wicket/trunk/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java Sun May 25 14:22:37 2008 @@ -174,9 +174,9 @@ private static final long serialVersionUID = 1L; @Override - public IConverter<URL> getConverter(Class<URL> clazz) + public <X> IConverter<X> getConverter(Class<X> clazz) { - return new IConverter<URL>() + return (IConverter<X>)new IConverter<URL>() { private static final long serialVersionUID = 1L; @@ -213,9 +213,10 @@ private static final long serialVersionUID = 1L; @Override - public IConverter<UsPhoneNumber> getConverter(Class<UsPhoneNumber> clazz) + public <X> IConverter<X> getConverter(Class<X> clazz) { - return new MaskConverter<UsPhoneNumber>("(###) ###-####", UsPhoneNumber.class); + return (IConverter<X>)new MaskConverter<UsPhoneNumber>("(###) ###-####", + UsPhoneNumber.class); } }); Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java (original) +++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java Sun May 25 14:22:37 2008 @@ -144,39 +144,57 @@ // TextField using a custom converter. add(new TextField<URL>("urlProperty", URL.class) { + @SuppressWarnings("unchecked") @Override - public IConverter<URL> getConverter(final Class<URL> type) + public <X> IConverter<X> getConverter(final Class<X> type) { - return new IConverter<URL>() + if (URL.class.isAssignableFrom(type)) { - public URL convertToObject(String value, Locale locale) + return (IConverter<X>)new IConverter<URL>() { - try + public URL convertToObject(String value, Locale locale) { - return new URL(value.toString()); + try + { + return new URL(value.toString()); + } + catch (MalformedURLException e) + { + throw new ConversionException("'" + value + + "' is not a valid URL"); + } } - catch (MalformedURLException e) + + public String convertToString(URL value, Locale locale) { - throw new ConversionException("'" + value + "' is not a valid URL"); + return value != null ? value.toString() : null; } - } - - public String convertToString(URL value, Locale locale) - { - return value != null ? value.toString() : null; - } - }; + }; + } + else + { + return super.getConverter(type); + } } }); // TextField using a mask converter add(new TextField<UsPhoneNumber>("phoneNumberUS", UsPhoneNumber.class) { + @SuppressWarnings("unchecked") @Override - public IConverter<UsPhoneNumber> getConverter(final Class<UsPhoneNumber> type) + public <X> IConverter<X> getConverter(final Class<X> type) { - // US telephone number mask - return new MaskConverter<UsPhoneNumber>("(###) ###-####", UsPhoneNumber.class); + if (UsPhoneNumber.class.isAssignableFrom(type)) + { + // US telephone number mask + return (IConverter<X>)new MaskConverter<UsPhoneNumber>("(###) ###-####", + UsPhoneNumber.class); + } + else + { + return super.getConverter(type); + } } }); Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java (original) +++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableChoiceLabel.java Sun May 25 14:22:37 2008 @@ -47,7 +47,7 @@ private static final long serialVersionUID = 1L; /** The list of objects. */ - private IModel< ? extends List< ? extends T>> choices; + private IModel<? extends List<? extends T>> choices; /** The renderer used to generate display/id values for the objects. */ private IChoiceRenderer<T> renderer; @@ -84,7 +84,7 @@ * @param choices * The collection of choices in the dropdown */ - public AjaxEditableChoiceLabel(String id, List< ? extends T> choices) + public AjaxEditableChoiceLabel(String id, List<? extends T> choices) { this(id, null, choices); } @@ -100,7 +100,7 @@ * The collection of choices in the dropdown */ public AjaxEditableChoiceLabel(String id, IModel<T> model, - IModel< ? extends List< ? extends T>> choices) + IModel<? extends List<? extends T>> choices) { super(id, model); this.choices = choices; @@ -119,7 +119,7 @@ * The rendering engine */ public AjaxEditableChoiceLabel(String id, IModel<T> model, - IModel< ? extends List< ? extends T>> choices, IChoiceRenderer<T> renderer) + IModel<? extends List<? extends T>> choices, IChoiceRenderer<T> renderer) { super(id, model); this.choices = choices; @@ -137,7 +137,7 @@ * The collection of choices in the dropdown */ @SuppressWarnings("unchecked") - public AjaxEditableChoiceLabel(String id, IModel<T> model, List< ? extends T> choices) + public AjaxEditableChoiceLabel(String id, IModel<T> model, List<? extends T> choices) { this(id, model, Model.valueOf(choices)); } @@ -155,7 +155,7 @@ * The rendering engine */ @SuppressWarnings("unchecked") - public AjaxEditableChoiceLabel(String id, IModel<T> model, List< ? extends T> choices, + public AjaxEditableChoiceLabel(String id, IModel<T> model, List<? extends T> choices, IChoiceRenderer<T> renderer) { this(id, model, Model.valueOf(choices), renderer); @@ -167,16 +167,16 @@ * java.lang.String, org.apache.wicket.model.IModel) */ @Override - protected FormComponent<T> newEditor(MarkupContainer< ? > parent, String componentId, + protected FormComponent<T> newEditor(MarkupContainer<?> parent, String componentId, IModel<T> model) { - IModel<List< ? extends T>> choiceModel = new AbstractReadOnlyModel<List< ? extends T>>() + IModel<List<? extends T>> choiceModel = new AbstractReadOnlyModel<List<? extends T>>() { private static final long serialVersionUID = 1L; @Override - public List< ? extends T> getObject() + public List<? extends T> getObject() { return choices.getObject(); } @@ -222,7 +222,7 @@ } @Override - protected WebComponent<T> newLabel(MarkupContainer< ? > parent, String componentId, + protected WebComponent<T> newLabel(MarkupContainer<?> parent, String componentId, IModel<T> model) { Label<T> label = new Label<T>(componentId, model) @@ -230,9 +230,9 @@ private static final long serialVersionUID = 1L; @Override - public IConverter<T> getConverter(Class<T> type) + public <X> IConverter<X> getConverter(Class<X> type) { - IConverter<T> c = AjaxEditableChoiceLabel.this.getConverter(type); + IConverter<X> c = AjaxEditableChoiceLabel.this.getConverter(type); return c != null ? c : super.getConverter(type); } @@ -243,8 +243,7 @@ if (renderer != null) { Object displayObject = renderer.getDisplayValue(getModelObject()); - Class< ? > objectClass = (displayObject == null ? null - : displayObject.getClass()); + Class<?> objectClass = (displayObject == null ? null : displayObject.getClass()); if (objectClass != null && objectClass != String.class) Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java (original) +++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java Sun May 25 14:22:37 2008 @@ -214,7 +214,7 @@ * @see org.apache.wicket.Component#getConverter(java.lang.Class) */ @Override - public IConverter<T> getConverter(Class<T> type) + public <X> IConverter<X> getConverter(Class<X> type) { return null; } @@ -280,7 +280,7 @@ * The model * @return The editor */ - protected FormComponent<T> newEditor(MarkupContainer< ? > parent, String componentId, + protected FormComponent<T> newEditor(MarkupContainer<?> parent, String componentId, IModel<T> model) { TextField<T> editor = new TextField<T>(componentId, model) @@ -288,9 +288,9 @@ private static final long serialVersionUID = 1L; @Override - public IConverter<T> getConverter(Class<T> type) + public <X> IConverter<X> getConverter(Class<X> type) { - IConverter<T> c = AjaxEditableLabel.this.getConverter(type); + IConverter<X> c = AjaxEditableLabel.this.getConverter(type); return c != null ? c : super.getConverter(type); } @@ -325,7 +325,7 @@ * The model * @return The editor */ - protected WebComponent<T> newLabel(MarkupContainer< ? > parent, String componentId, + protected WebComponent<T> newLabel(MarkupContainer<?> parent, String componentId, IModel<T> model) { Label<T> label = new Label<T>(componentId, model) @@ -333,9 +333,9 @@ private static final long serialVersionUID = 1L; @Override - public IConverter<T> getConverter(Class<T> type) + public <X> IConverter<X> getConverter(Class<X> type) { - IConverter<T> c = AjaxEditableLabel.this.getConverter(type); + IConverter<X> c = AjaxEditableLabel.this.getConverter(type); return c != null ? c : super.getConverter(type); } @@ -512,7 +512,7 @@ // check that a model was found if (m == null) { - Component< ? > parent = getParent(); + Component<?> parent = getParent(); String msg = "No model found for this component, either pass one explicitly or " + "make sure an inheritable model is available."; if (parent == null) Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.java (original) +++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/IColumn.java Sun May 25 14:22:37 2008 @@ -38,7 +38,7 @@ * * @return component that will be used as the header for the column */ - Component< ? > getHeader(String componentId); + Component<?> getHeader(String componentId); /** * Returns the name of the property that this header sorts. If null is returned the header will Modified: wicket/trunk/wicket-quickstart/jetty-quickstart.launch URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-quickstart/jetty-quickstart.launch?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket-quickstart/jetty-quickstart.launch (original) +++ wicket/trunk/wicket-quickstart/jetty-quickstart.launch Sun May 25 14:22:37 2008 @@ -1,18 +1,17 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.mortbay.jetty.Server"/> -<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/wicket-quickstart"/> +</listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="4"/> </listAttribute> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/main/resources/jetty-config.xml"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="wicket-quickstart"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> </listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/wicket-quickstart"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.mortbay.jetty.Server"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/main/resources/jetty-config.xml"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="wicket-quickstart"/> </launchConfiguration> Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Sun May 25 14:22:37 2008 @@ -202,7 +202,7 @@ * @param <T> * Model object type */ -public abstract class Component<T> implements IClusterable, IConverterLocator<T> +public abstract class Component<T> implements IClusterable, IConverterLocator { /** * Change record of a model. @@ -1320,7 +1320,7 @@ * * @return The converter that should be used by this component */ - public IConverter<T> getConverter(Class<T> type) + public <X> IConverter<X> getConverter(Class<X> type) { return getApplication().getConverterLocator().getConverter(type); } Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/IConverterLocator.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/IConverterLocator.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/IConverterLocator.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/IConverterLocator.java Sun May 25 14:22:37 2008 @@ -30,17 +30,19 @@ * * @author jcompagner * - * @param <T> - * The converter object type + * The converter object type */ -public interface IConverterLocator<T> extends IClusterable +public interface IConverterLocator extends IClusterable { /** * Returns the Converter for the class that is given. * + * @param <T> + * converter type + * * @param type * @return The converter for the given type. */ - public IConverter<T> getConverter(Class<T> type); + public <T> IConverter<T> getConverter(Class<T> type); } Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java Sun May 25 14:22:37 2008 @@ -128,9 +128,14 @@ * * @see org.apache.wicket.Component#getConverter(java.lang.Class) */ - public IConverter<Boolean> getConverter(Class<Boolean> type) + @Override + public <X> IConverter<X> getConverter(Class<X> type) { - return BooleanConverter.INSTANCE; + /* + * FIXME johan: why is this override here? it doesnt make any sense. if i say + * checkbox.getconverter(Integer.class) why is it still giving me a boolean converter??? + */ + return (IConverter<X>)BooleanConverter.INSTANCE; } /** @@ -173,7 +178,7 @@ { CharSequence url = urlFor(IOnChangeListener.INTERFACE); - Form< ? > form = findParent(Form.class); + Form<?> form = findParent(Form.class); if (form != null) { RequestContext rc = RequestContext.get(); Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java?rev=660041&r1=660040&r2=660041&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java Sun May 25 14:22:37 2008 @@ -49,10 +49,8 @@ * @author Eelco Hillenius * @author Jonathan Locke * - * @param <T> - * The converter object type */ -public class ConverterLocator<T> implements IConverterLocator<T> +public class ConverterLocator implements IConverterLocator { /** * CoverterLocator that is to be used when no registered converter is found. @@ -124,7 +122,7 @@ private static final long serialVersionUID = 1L; /** Maps Classes to ITypeConverters. */ - private final Map<String, IConverter< ? >> classToConverter = new HashMap<String, IConverter< ? >>(); + private final Map<String, IConverter<?>> classToConverter = new HashMap<String, IConverter<?>>(); /** * Constructor @@ -157,13 +155,16 @@ /** * Gets the type converter that is registered for class c. * + * @param <T> + * converter type + * * @param c * The class to get the type converter for * @return The type converter that is registered for class c or null if no type converter was * registered for class c */ @SuppressWarnings("unchecked") - public final IConverter<T> get(Class<T> c) + public final <T> IConverter<T> get(Class<T> c) { return (IConverter<T>)classToConverter.get(c.getName()); } @@ -179,7 +180,7 @@ * @see org.apache.wicket.util.convert.IConverter#convertToObject(String, java.util.Locale) */ @SuppressWarnings("unchecked") - public final IConverter<T> getConverter(Class<T> type) + public final <T> IConverter<T> getConverter(Class<T> type) { // Null is always converted to null if (type == null)