You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2008/04/08 20:10:43 UTC
svn commit: r646020 [2/5] - in /wicket/trunk/jdk-1.4:
wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/
wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/
wicket-extensions/src/main/...
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java Tue Apr 8 11:10:20 2008
@@ -198,8 +198,11 @@
* @author Johan Compagner
* @author Juergen Donnerstag
* @author Igor Vaynberg (ivaynberg)
+ *
+ * @param <T>
+ * Model object type
*/
-public abstract class Component implements IClusterable, IConverterLocator
+public abstract class Component<T> implements IClusterable, IConverterLocator
{
/**
* Change record of a model.
@@ -209,14 +212,14 @@
private static final long serialVersionUID = 1L;
/** Former model. */
- private final IModel model;
+ private final IModel<T> model;
/**
* Construct.
*
* @param model
*/
- public ComponentModelChange(IModel model)
+ public ComponentModelChange(IModel<T> model)
{
super();
this.model = model;
@@ -225,6 +228,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return "ComponentModelChange[component: " + getPath() + "]";
@@ -233,6 +237,7 @@
/**
* @see org.apache.wicket.version.undo.Change#undo()
*/
+ @Override
public void undo()
{
setModel(model);
@@ -241,8 +246,11 @@
/**
* Generic component visitor interface for component traversals.
+ *
+ * @param <T>
+ * The component
*/
- public static interface IVisitor
+ public static interface IVisitor<T extends Component< ? >>
{
/**
* Value to return to continue a traversal.
@@ -269,7 +277,7 @@
* value for the traversal method if it should stop. If no return value is useful,
* the generic non-null value STOP_TRAVERSAL can be used.
*/
- public Object component(Component component);
+ public Object component(T component);
}
/**
@@ -294,11 +302,13 @@
this.behavior = behavior;
}
+ @Override
public String toString()
{
return "[" + getClass().getName() + " behavior=" + behavior.toString() + "]";
}
+ @Override
public void undo()
{
removeBehavior(behavior);
@@ -317,6 +327,7 @@
private final IComponentBorder old = getComponentBorder();
+ @Override
public void undo()
{
setComponentBorder(old);
@@ -346,11 +357,13 @@
this.behavior = behavior;
}
+ @Override
public String toString()
{
return "[" + getClass().getName() + " behavior=" + behavior.toString() + "]";
}
+ @Override
public void undo()
{
addBehavior(behavior);
@@ -367,7 +380,7 @@
private static final long serialVersionUID = 1L;
/** Subject. */
- private final Component component;
+ private final Component< ? > component;
/** Former value. */
private final boolean enabled;
@@ -377,7 +390,7 @@
*
* @param component
*/
- EnabledChange(final Component component)
+ EnabledChange(final Component< ? > component)
{
this.component = component;
enabled = component.getFlag(FLAG_ENABLED);
@@ -386,6 +399,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return "EnabledChange[component: " + component.getPath() + ",enabled: " + enabled + "]";
@@ -394,6 +408,7 @@
/**
* @see org.apache.wicket.version.undo.Change#undo()
*/
+ @Override
public void undo()
{
component.setEnabled(enabled);
@@ -408,7 +423,7 @@
private static final long serialVersionUID = 1L;
/** Subject. */
- private final Component component;
+ private final Component< ? > component;
/** Former value. */
private final boolean visible;
@@ -418,7 +433,7 @@
*
* @param component
*/
- VisibilityChange(final Component component)
+ VisibilityChange(final Component< ? > component)
{
this.component = component;
visible = component.getFlag(FLAG_VISIBLE);
@@ -427,6 +442,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return "VisibilityChange[component: " + component.getPath() + ", visible: " + visible +
@@ -436,6 +452,7 @@
/**
* @see org.apache.wicket.version.undo.Change#undo()
*/
+ @Override
public void undo()
{
component.setVisible(visible);
@@ -490,23 +507,24 @@
public static final Action RENDER = new Action(Action.RENDER);
/** meta data key for missing body tags logging. */
- private static final MetaDataKey BORDER_KEY = new MetaDataKey(IComponentBorder.class)
+ private static final MetaDataKey<IComponentBorder> BORDER_KEY = new MetaDataKey<IComponentBorder>(
+ IComponentBorder.class)
{
private static final long serialVersionUID = 1L;
};
/* meta data for user specified markup id */
- private static final MetaDataKey MARKUP_ID_KEY = new MetaDataKey(String.class)
+ private static final MetaDataKey<String> MARKUP_ID_KEY = new MetaDataKey<String>(String.class)
{
private static final long serialVersionUID = 1L;
};
/** Basic model IModelComparator implementation for normal object models */
- private static final IModelComparator defaultModelComparator = new IModelComparator()
+ private static final IModelComparator<Object> defaultModelComparator = new IModelComparator<Object>()
{
private static final long serialVersionUID = 1L;
- public boolean compare(Component component, Object b)
+ public boolean compare(Component<Object> component, Object b)
{
final Object a = component.getModelObject();
if (a == null && b == null)
@@ -633,7 +651,7 @@
* Meta data key for line precise error logging for the moment of addition. Made package private
* for access in {@link MarkupContainer} and {@link Page}
*/
- static final MetaDataKey ADDED_AT_KEY = new MetaDataKey(String.class)
+ static final MetaDataKey<String> ADDED_AT_KEY = new MetaDataKey<String>(String.class)
{
private static final long serialVersionUID = 1L;
};
@@ -642,7 +660,7 @@
* meta data key for line precise error logging for the moment of construction. Made package
* private for access in {@link Page}
*/
- static final MetaDataKey CONSTRUCTED_AT_KEY = new MetaDataKey(String.class)
+ static final MetaDataKey<String> CONSTRUCTED_AT_KEY = new MetaDataKey<String>(String.class)
{
private static final long serialVersionUID = 1L;
};
@@ -893,7 +911,7 @@
* @throws WicketRuntimeException
* Thrown if the component has been given a null id.
*/
- public Component(final String id, final IModel model)
+ public Component(final String id, final IModel<T> model)
{
this(id);
setModelImpl(wrap(model));
@@ -912,7 +930,7 @@
* The behavior modifier to be added
* @return this (to allow method call chaining)
*/
- public Component add(final IBehavior behavior)
+ public Component<T> add(final IBehavior behavior)
{
if (behavior == null)
{
@@ -937,7 +955,7 @@
data_add(behavior);
}
- private List getBehaviorsImpl()
+ private List<IBehavior> getBehaviorsImpl()
{
if (data != null)
{
@@ -947,13 +965,13 @@
if (length > startIndex)
{
- final ArrayList result = new ArrayList();
+ final ArrayList<IBehavior> result = new ArrayList<IBehavior>();
for (int i = startIndex; i < length; ++i)
{
Object o = data_get(i);
if (o instanceof IBehavior)
{
- result.add(o);
+ result.add((IBehavior)o);
}
}
return result;
@@ -1019,7 +1037,8 @@
* request cycle metadata. The List is then iterated over in {@link #prepareForRender()} after
* calling {@link #beforeRender()}, to initialize postponed components.
*/
- private static final MetaDataKey FEEDBACK_LIST = new MetaDataKey(List.class)
+ private static final MetaDataKey<List<Component< ? >>> FEEDBACK_LIST = new MetaDataKey<List<Component< ? >>>(
+ List.class)
{
private static final long serialVersionUID = 1L;
};
@@ -1038,11 +1057,11 @@
{
// this component is a feedback. Feedback must be initialized last, so that
// they can collect messages from other components
- List feedbacks = (List)getRequestCycle().getMetaData(FEEDBACK_LIST);
+ List<Component< ? >> feedbacks = getRequestCycle().getMetaData(FEEDBACK_LIST);
if (feedbacks == null)
{
- feedbacks = new ArrayList();
- getRequestCycle().setMetaData(FEEDBACK_LIST, (Serializable)feedbacks);
+ feedbacks = new ArrayList<Component< ? >>();
+ getRequestCycle().setMetaData(FEEDBACK_LIST, feedbacks);
}
feedbacks.add(this);
}
@@ -1119,12 +1138,12 @@
*/
public final void detachBehaviors()
{
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors != null)
{
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
- IBehavior behavior = (IBehavior)i.next();
+ IBehavior behavior = i.next();
// Always detach models, 'accepted' or not. Otherwise, if they
// are accepted during render, but not here - something can go
@@ -1185,7 +1204,7 @@
* @return First container parent that is an instance of the given class, or null if none can be
* found
*/
- public final MarkupContainer findParent(final Class c)
+ public final MarkupContainer findParent(final Class< ? extends MarkupContainer> c)
{
// Start with immediate parent
MarkupContainer current = parent;
@@ -1243,7 +1262,7 @@
*
* @return The currently coupled behaviors as a unmodifiable list
*/
- public final List/* <IBehavior> */getBehaviors()
+ public final List<IBehavior> getBehaviors()
{
return getBehaviors(null);
}
@@ -1262,13 +1281,14 @@
*/
public final IComponentBorder getComponentBorder()
{
- return (IComponentBorder)getMetaData(BORDER_KEY);
+ return getMetaData(BORDER_KEY);
}
/**
* @return nothing, will always throw an exception. Use {@link #getConverter(Class)} instead.
* @deprecated To be removed. Please use/ override {@link #getConverter(Class)} instead.
*/
+ @Deprecated
public final IConverter getConverter()
{
throw new UnsupportedOperationException("use #getConverter(Class) instead");
@@ -1282,7 +1302,7 @@
*
* @return The converter that should be used by this component
*/
- public IConverter getConverter(Class/* <?> */type)
+ public IConverter getConverter(Class< ? > type)
{
return getApplication().getConverterLocator().getConverter(type);
}
@@ -1318,7 +1338,7 @@
/**
* @return Innermost model for this component
*/
- public final IModel getInnermostModel()
+ public final IModel< ? > getInnermostModel()
{
return getInnermostModel(getModel());
}
@@ -1491,14 +1511,17 @@
/**
* Gets metadata for this component using the given key.
*
+ * @param <M>
+ * The type of the metadata.
+ *
* @param key
* The key for the data
* @return The metadata or null of no metadata was found for the given key
* @see MetaDataKey
*/
- public final Serializable getMetaData(final MetaDataKey key)
+ public final <M extends Serializable> M getMetaData(final MetaDataKey<M> key)
{
- return (Serializable)key.get(getMetaData());
+ return key.get(getMetaData());
}
private MetaDataEntry[] getMetaData()
@@ -1531,9 +1554,9 @@
*
* @return The model
*/
- public final IModel getModel()
+ public final IModel<T> getModel()
{
- IModel model = getModelImpl();
+ IModel<T> model = getModelImpl();
// If model is null
if (model == null)
{
@@ -1550,9 +1573,9 @@
*
* @return The backing model object
*/
- public final Object getModelObject()
+ public final T getModelObject()
{
- final IModel model = getModel();
+ final IModel<T> model = getModel();
if (model != null)
{
// Get model value for this component.
@@ -1698,7 +1721,7 @@
public final String getPath()
{
final PrependingStringBuffer buffer = new PrependingStringBuffer(32);
- for (Component c = this; c != null; c = c.getParent())
+ for (Component< ? > c = this; c != null; c = c.getParent())
{
if (buffer.length() > 0)
{
@@ -1802,7 +1825,7 @@
* @return The formatted string
* @see Localizer
*/
- public final String getString(final String key, final IModel model)
+ public final String getString(final String key, final IModel< ? > model)
{
return getLocalizer().getString(key, this, model);
}
@@ -1817,7 +1840,8 @@
* @return The formatted string
* @see Localizer
*/
- public final String getString(final String key, final IModel model, final String defaultValue)
+ public final String getString(final String key, final IModel< ? > model,
+ final String defaultValue)
{
return getLocalizer().getString(key, this, model, defaultValue);
}
@@ -1907,6 +1931,7 @@
* @deprecated
*/
// TODO remove after deprecation release
+ @Deprecated
public final void internalAttach()
{
throw new UnsupportedOperationException();
@@ -1916,6 +1941,7 @@
* @deprecated
*/
// TODO remove after deprecation release
+ @Deprecated
public final void internalDetach()
{
throw new UnsupportedOperationException();
@@ -1948,7 +1974,8 @@
* @return True if the given component has this component as an ancestor
* @deprecated use getParent().contains(component, false)
*/
- public final boolean isAncestorOf(final Component component)
+ @Deprecated
+ public final boolean isAncestorOf(final Component< ? > component)
{
return getParent().contains(component, false);
// // Walk up containment hierarchy
@@ -2012,11 +2039,11 @@
return false;
}
- final Iterator behaviors = getBehaviors().iterator();
+ final Iterator<IBehavior> behaviors = getBehaviors().iterator();
while (behaviors.hasNext())
{
- IBehavior behavior = (IBehavior)behaviors.next();
+ IBehavior behavior = behaviors.next();
if (!behavior.getStatelessHint(this))
{
return false;
@@ -2073,7 +2100,7 @@
*/
public final boolean isVisibleInHierarchy()
{
- Component component = this;
+ Component< ? > component = this;
while (component != null)
{
if (component.determineVisibility())
@@ -2131,7 +2158,7 @@
* The class of page to create
* @return The new page
*/
- public final Page newPage(final Class c)
+ public final Page newPage(final Class< ? extends Page> c)
{
return getPageFactory().newPage(c);
}
@@ -2145,7 +2172,7 @@
* Any parameters to pass to the constructor
* @return The new page
*/
- public final Page newPage(final Class c, final PageParameters parameters)
+ public final Page newPage(final Class< ? extends Page> c, final PageParameters parameters)
{
return getPageFactory().newPage(c, parameters);
}
@@ -2157,12 +2184,12 @@
public void prepareForRender()
{
beforeRender();
- List feedbacks = (List)getRequestCycle().getMetaData(FEEDBACK_LIST);
+ List<Component< ? >> feedbacks = getRequestCycle().getMetaData(FEEDBACK_LIST);
if (feedbacks != null)
{
- for (Iterator i = feedbacks.iterator(); i.hasNext();)
+ for (Iterator<Component< ? >> i = feedbacks.iterator(); i.hasNext();)
{
- Component feedback = (Component)i.next();
+ Component< ? > feedback = i.next();
feedback.internalBeforeRender();
}
}
@@ -2213,7 +2240,7 @@
*
* @return this (to allow method call chaining)
*/
- public Component remove(final IBehavior behavior)
+ public Component<T> remove(final IBehavior behavior)
{
if (behavior == null)
{
@@ -2325,12 +2352,12 @@
{
// Call each behaviors onException() to allow the
// behavior to clean up
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors != null)
{
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
- IBehavior behavior = (IBehavior)i.next();
+ IBehavior behavior = i.next();
if (isBehaviorAccepted(behavior))
{
try
@@ -2555,13 +2582,13 @@
// Ask all behaviors if they have something to contribute to the
// header or body onLoad tag.
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors != null)
{
- final Iterator iter = behaviors.iterator();
+ final Iterator<IBehavior> iter = behaviors.iterator();
while (iter.hasNext())
{
- IBehavior behavior = (IBehavior)iter.next();
+ IBehavior behavior = iter.next();
if (behavior instanceof IHeaderContributor && isBehaviorAccepted(behavior))
{
((IHeaderContributor)behavior).renderHead(container.getHeaderResponse());
@@ -2582,7 +2609,7 @@
* @param replacement
* component to replace this one
*/
- public void replaceWith(Component replacement)
+ public void replaceWith(Component< ? > replacement)
{
if (replacement == null)
{
@@ -2607,7 +2634,7 @@
* The component to compare with
* @return True if the given component's model is the same as this component's model.
*/
- public final boolean sameInnermostModel(final Component component)
+ public final boolean sameInnermostModel(final Component< ? > component)
{
return sameInnermostModel(component.getModel());
}
@@ -2617,11 +2644,11 @@
* The model to compare with
* @return True if the given component's model is the same as this component's model.
*/
- public final boolean sameInnermostModel(final IModel model)
+ public final boolean sameInnermostModel(final IModel< ? > model)
{
// Get the two models
- IModel thisModel = getModel();
- IModel thatModel = model;
+ IModel< ? > thisModel = getModel();
+ IModel< ? > thatModel = model;
// If both models are non-null they could be the same
if (thisModel != null && thatModel != null)
@@ -2640,7 +2667,7 @@
* component border to assign, or <code>null</code> to clear any previous
* @return component for chaining
*/
- public final Component setComponentBorder(final IComponentBorder border)
+ public final Component<T> setComponentBorder(final IComponentBorder border)
{
if (!Objects.equal(getComponentBorder(), border))
{
@@ -2661,7 +2688,7 @@
* whether this component is enabled
* @return This
*/
- public final Component setEnabled(final boolean enabled)
+ public final Component<T> setEnabled(final boolean enabled)
{
// Is new enabled state a change?
if (enabled != getFlag(FLAG_ENABLED))
@@ -2689,7 +2716,7 @@
* True is model strings should be escaped
* @return This
*/
- public final Component setEscapeModelStrings(final boolean escapeMarkup)
+ public final Component<T> setEscapeModelStrings(final boolean escapeMarkup)
{
setFlag(FLAG_ESCAPE_MODEL_STRINGS, escapeMarkup);
return this;
@@ -2709,7 +2736,7 @@
return;
}
generatedMarkupId = -1;
- setMetaData(MARKUP_ID_KEY, (Serializable)markupId);
+ setMetaData(MARKUP_ID_KEY, (String)markupId);
}
/**
@@ -2746,6 +2773,9 @@
* the correct type for the metadata key, an IllegalArgumentException will be thrown. For
* information on creating MetaDataKeys, see {@link MetaDataKey}.
*
+ * @param <M>
+ * The type of the metadata
+ *
* @param key
* The singleton key for the metadata
* @param object
@@ -2753,7 +2783,7 @@
* @throws IllegalArgumentException
* @see MetaDataKey
*/
- public final void setMetaData(final MetaDataKey key, final Serializable object)
+ public final <M> void setMetaData(final MetaDataKey<M> key, final M object)
{
MetaDataEntry[] old = getMetaData();
@@ -2791,26 +2821,27 @@
* The model
* @return This
*/
- public Component setModel(final IModel model)
+ public Component<T> setModel(final IModel<T> model)
{
- IModel prevModel = getModelImpl();
+ IModel<T> prevModel = getModelImpl();
// Detach current model
if (prevModel != null)
{
prevModel.detach();
}
+ IModel wrappedModel = prevModel;
if (prevModel instanceof IWrapModel)
{
- prevModel = ((IWrapModel)prevModel).getWrappedModel();
+ wrappedModel = ((IWrapModel<T>)prevModel).getWrappedModel();
}
// Change model
- if (prevModel != model)
+ if (wrappedModel != model)
{
- if (prevModel != null)
+ if (wrappedModel != null)
{
- addStateChange(new ComponentModelChange(prevModel));
+ addStateChange(new ComponentModelChange(wrappedModel));
}
setModelImpl(wrap(model));
@@ -2820,11 +2851,12 @@
return this;
}
- IModel getModelImpl()
+ @SuppressWarnings("unchecked")
+ IModel<T> getModelImpl()
{
if (getFlag(FLAG_MODEL_SET))
{
- return (IModel)data_get(0);
+ return (IModel<T>)data_get(0);
}
else
{
@@ -2832,7 +2864,7 @@
}
}
- void setModelImpl(IModel model)
+ void setModelImpl(IModel<T> model)
{
if (getFlag(FLAG_MODEL_SET))
{
@@ -2865,9 +2897,9 @@
* The object to set
* @return This
*/
- public final Component setModelObject(final Object object)
+ public final Component<T> setModelObject(final T object)
{
- final IModel model = getModel();
+ final IModel<T> model = getModel();
// Check whether anything can be set at all
if (model == null)
@@ -2905,7 +2937,7 @@
*
* @return this for chaining
*/
- public final Component setOutputMarkupId(final boolean output)
+ public final Component<T> setOutputMarkupId(final boolean output)
{
setFlag(FLAG_OUTPUT_MARKUP_ID, output);
return this;
@@ -2927,7 +2959,7 @@
* @param outputTag
* @return this for chaining
*/
- public final Component setOutputMarkupPlaceholderTag(final boolean outputTag)
+ public final Component<T> setOutputMarkupPlaceholderTag(final boolean outputTag)
{
if (outputTag != getFlag(FLAG_PLACEHOLDER))
{
@@ -2964,7 +2996,7 @@
* If true, the component tag will not be printed
* @return This
*/
- public final Component setRenderBodyOnly(final boolean renderTag)
+ public final Component<T> setRenderBodyOnly(final boolean renderTag)
{
this.setFlag(FLAG_RENDER_BODY_ONLY, renderTag);
return this;
@@ -2977,7 +3009,7 @@
* The response page class
* @see RequestCycle#setResponsePage(Class)
*/
- public final void setResponsePage(final Class cls)
+ public final void setResponsePage(final Class< ? extends Page> cls)
{
getRequestCycle().setResponsePage(cls);
}
@@ -2992,7 +3024,7 @@
* The parameters for this bookmarkable page.
* @see RequestCycle#setResponsePage(Class, PageParameters)
*/
- public final void setResponsePage(final Class cls, PageParameters parameters)
+ public final void setResponsePage(final Class< ? extends Page> cls, PageParameters parameters)
{
getRequestCycle().setResponsePage(cls, parameters);
}
@@ -3015,7 +3047,7 @@
* component and any children.
* @return This
*/
- public Component setVersioned(boolean versioned)
+ public Component<T> setVersioned(boolean versioned)
{
setFlag(FLAG_VERSIONED, versioned);
return this;
@@ -3028,7 +3060,7 @@
* True if this component and any children should be visible
* @return This
*/
- public final Component setVisible(final boolean visible)
+ public final Component<T> setVisible(final boolean visible)
{
// Is new visibility state a change?
if (visible != getFlag(FLAG_VISIBLE))
@@ -3047,6 +3079,7 @@
*
* @return The path to this component
*/
+ @Override
public String toString()
{
return toString(true);
@@ -3104,7 +3137,8 @@
* Parameters to page
* @return Bookmarkable URL to page
*/
- public final CharSequence urlFor(final Class pageClass, final PageParameters parameters)
+ public final CharSequence urlFor(final Class< ? extends Page> pageClass,
+ final PageParameters parameters)
{
return getRequestCycle().urlFor(getPage().getPageMap(), pageClass, parameters);
}
@@ -3142,8 +3176,8 @@
*
* @return Bookmarkable URL to page
*/
- public final CharSequence urlFor(final IPageMap pageMap, final Class pageClass,
- final PageParameters parameters)
+ public final CharSequence urlFor(final IPageMap pageMap,
+ final Class< ? extends Page> pageClass, final PageParameters parameters)
{
return getRequestCycle().urlFor(pageMap, pageClass, parameters);
}
@@ -3199,10 +3233,11 @@
* The visitor to call at each parent of the given type
* @return First non-null value returned by visitor callback
*/
- public final Object visitParents(final Class c, final IVisitor visitor)
+ public final Object visitParents(final Class< ? extends MarkupContainer> c,
+ final IVisitor<Component< ? >> visitor)
{
// Start here
- Component current = this;
+ Component< ? > current = this;
// Walk up containment hierarchy
while (current != null)
@@ -3241,12 +3276,12 @@
*/
private void notifyBehaviorsComponentBeforeRender()
{
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors != null)
{
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
- IBehavior behavior = (IBehavior)i.next();
+ IBehavior behavior = i.next();
if (isBehaviorAccepted(behavior))
{
behavior.beforeRender(this);
@@ -3262,12 +3297,12 @@
private void notifyBehaviorsComponentRendered()
{
// notify the behaviors that component has been rendered
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors != null)
{
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
- IBehavior behavior = (IBehavior)i.next();
+ IBehavior behavior = i.next();
if (isBehaviorAccepted(behavior))
{
behavior.afterRender(this);
@@ -3346,7 +3381,7 @@
* @param component
* the component which is about to be added or removed
*/
- protected void checkHierarchyChange(final Component component)
+ protected void checkHierarchyChange(final Component< ? > component)
{
// Throw exception if modification is attempted during rendering
if (!component.isAuto() && getFlag(FLAG_RENDERING))
@@ -3361,7 +3396,7 @@
*/
protected void detachModel()
{
- IModel model = getModelImpl();
+ IModel<T> model = getModelImpl();
if (model != null)
{
model.detach();
@@ -3370,7 +3405,7 @@
// inherited)
if (model instanceof IWrapModel && !getFlag(FLAG_INHERITABLE_MODEL))
{
- ((IWrapModel)model).getWrappedModel().detach();
+ ((IWrapModel<T>)model).getWrappedModel().detach();
}
}
@@ -3426,21 +3461,21 @@
* @return The subset of the currently coupled behaviors that are of the provided type as a
* unmodifiable list or null
*/
- protected List/* <IBehavior> */getBehaviors(Class type)
+ protected List<IBehavior> getBehaviors(Class< ? extends IBehavior> type)
{
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if (behaviors == null)
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- List subset = new ArrayList(behaviors.size()); // avoid growing
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ List<IBehavior> subset = new ArrayList<IBehavior>(behaviors.size()); // avoid growing
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
Object behavior = i.next();
if (type == null || type.isAssignableFrom(behavior.getClass()))
{
- subset.add(behavior);
+ subset.add((IBehavior)behavior);
}
}
return Collections.unmodifiableList(subset);
@@ -3477,12 +3512,12 @@
* The model
* @return The innermost (most nested) model
*/
- protected final IModel getInnermostModel(final IModel model)
+ protected final IModel< ? > getInnermostModel(final IModel< ? > model)
{
- IModel nested = model;
+ IModel< ? > nested = model;
while (nested != null && nested instanceof IWrapModel)
{
- final IModel next = ((IWrapModel)nested).getWrappedModel();
+ final IModel< ? > next = ((IWrapModel< ? >)nested).getWrappedModel();
if (nested == next)
{
throw new WicketRuntimeException("Model for " + nested + " is self-referential");
@@ -3499,9 +3534,9 @@
*
* @return the value defaultModelComparator
*/
- protected IModelComparator getModelComparator()
+ protected IModelComparator<T> getModelComparator()
{
- return defaultModelComparator;
+ return (IModelComparator<T>)defaultModelComparator;
}
/**
@@ -3524,33 +3559,35 @@
*
* @return The model
*/
- protected IModel initModel()
+ @SuppressWarnings("unchecked")
+ protected IModel<T> initModel()
{
+ IModel<T> foundModel = null;
// Search parents for CompoundPropertyModel
- for (Component current = getParent(); current != null; current = current.getParent())
+ for (Component< ? > current = getParent(); current != null; current = current.getParent())
{
// Get model
// Don't call the getModel() that could initialize many inbetween
// completely useless models.
// IModel model = current.getModel();
- IModel model = current.getModelImpl();
+ IModel< ? > model = current.getModelImpl();
if (model instanceof IWrapModel && !(model instanceof IComponentInheritedModel))
{
- model = ((IWrapModel)model).getWrappedModel();
+ model = ((IWrapModel< ? >)model).getWrappedModel();
}
if (model instanceof IComponentInheritedModel)
{
// return the shared inherited
- model = ((IComponentInheritedModel)model).wrapOnInheritance(this);
+ foundModel = ((IComponentInheritedModel)model).wrapOnInheritance(this);
setFlag(FLAG_INHERITABLE_MODEL, true);
- return model;
+ break;
}
}
// No model for this component!
- return null;
+ return foundModel;
}
/**
@@ -3659,6 +3696,7 @@
*
* @deprecated
*/
+ @Deprecated
protected final void onAttach()
{
@@ -3701,6 +3739,7 @@
* @deprecated use onAttach() instead
*/
// TODO remove after the deprecation release
+ @Deprecated
protected final void onBeginRequest()
{
throw new UnsupportedOperationException();
@@ -3754,6 +3793,7 @@
* @deprecated use onDetach() instead
*/
// TODO remove after the deprecation release
+ @Deprecated
protected final void onEndRequest()
{
throw new UnsupportedOperationException();
@@ -3800,15 +3840,15 @@
if (!(tag instanceof WicketTag) || !stripWicketTags)
{
// Apply behavior modifiers
- List behaviors = getBehaviorsImpl();
+ List<IBehavior> behaviors = getBehaviorsImpl();
if ((behaviors != null) && !behaviors.isEmpty() && !tag.isClose() &&
(isIgnoreAttributeModifier() == false))
{
tag = tag.mutable();
- for (Iterator i = behaviors.iterator(); i.hasNext();)
+ for (Iterator<IBehavior> i = behaviors.iterator(); i.hasNext();)
{
- IBehavior behavior = (IBehavior)i.next();
+ IBehavior behavior = i.next();
// Components may reject some behavior components
if (isBehaviorAccepted(behavior))
@@ -3821,10 +3861,10 @@
// apply behaviors that are attached to the component tag.
if (tag.hasBehaviors())
{
- Iterator tagBehaviors = tag.getBehaviors();
+ Iterator<IBehavior> tagBehaviors = tag.getBehaviors();
while (tagBehaviors.hasNext())
{
- final IBehavior behavior = (IBehavior)tagBehaviors.next();
+ final IBehavior behavior = tagBehaviors.next();
behavior.onComponentTag(this, tag);
}
}
@@ -3939,7 +3979,7 @@
* If true, all attribute modifiers will be ignored
* @return This
*/
- protected final Component setIgnoreAttributeModifier(final boolean ignore)
+ protected final Component<T> setIgnoreAttributeModifier(final boolean ignore)
{
this.setFlag(FLAG_IGNORE_ATTRIBUTE_MODIFIER, ignore);
return this;
@@ -3965,6 +4005,7 @@
* The model to wrap if need be
* @return The wrapped model
*/
+ @SuppressWarnings("unchecked")
protected final IModel wrap(final IModel model)
{
if (model instanceof IComponentAssignedModel)
@@ -3991,7 +4032,7 @@
* Path to component
* @return The component at the path
*/
- Component get(final String path)
+ Component<T> get(final String path)
{
// Path to this component is an empty path
if (path.equals(""))
@@ -4026,7 +4067,7 @@
final boolean isAuto()
{
// Search up hierarchy for FLAG_AUTO
- for (Component current = this; current != null; current = current.getParent())
+ for (Component< ? > current = this; current != null; current = current.getParent())
{
if (current.getFlag(FLAG_AUTO))
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/IConverterLocator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/IConverterLocator.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/IConverterLocator.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/IConverterLocator.java Tue Apr 8 11:10:20 2008
@@ -39,5 +39,5 @@
* @param type
* @return The converter for the given type.
*/
- public IConverter getConverter(Class/* <?> */type);
+ public IConverter getConverter(Class< ? > type);
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java Tue Apr 8 11:10:20 2008
@@ -20,11 +20,11 @@
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.model.IModel;
import org.apache.wicket.resource.loader.IStringResourceLoader;
import org.apache.wicket.settings.IResourceSettings;
-import org.apache.wicket.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.interpolator.PropertyVariableInterpolator;
import org.slf4j.Logger;
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MarkupContainer.java Tue Apr 8 11:10:20 2008
@@ -80,8 +80,11 @@
*
* @see MarkupStream
* @author Jonathan Locke
+ *
+ * @param <T>
+ * The model object type
*/
-public abstract class MarkupContainer extends Component
+public abstract class MarkupContainer<T> extends Component<T>
{
private static final long serialVersionUID = 1L;
@@ -238,6 +241,7 @@
*
* @deprecated since 1.3 Please use {@link #autoAdd(Component, MarkupStream)} instead
*/
+ @Deprecated
public final boolean autoAdd(final Component component)
{
return autoAdd(component, null);
@@ -294,6 +298,7 @@
* Path to component
* @return The component at the path
*/
+ @Override
public final Component get(final String path)
{
// Reference to this container
@@ -425,9 +430,9 @@
/**
* @return Iterator that iterates through children in the order they were added
*/
- public final Iterator iterator()
+ public final Iterator<Component> iterator()
{
- return new Iterator()
+ return new Iterator<Component>()
{
int index = 0;
@@ -436,7 +441,7 @@
return index < children_size();
}
- public Object next()
+ public Component next()
{
return children_get(index++);
}
@@ -455,19 +460,19 @@
* The comparator
* @return Iterator that iterates over children in the order specified by comparator
*/
- public final Iterator iterator(Comparator comparator)
+ public final Iterator<Component> iterator(Comparator comparator)
{
- final List sorted;
+ final List<Component> sorted;
if (children == null)
{
- sorted = Collections.EMPTY_LIST;
+ sorted = Collections.emptyList();
}
else
{
if (children instanceof Component)
{
- sorted = new ArrayList(1);
- sorted.add(children);
+ sorted = new ArrayList<Component>(1);
+ sorted.add((Component)children);
}
else if (children instanceof ChildList)
{
@@ -555,12 +560,14 @@
final Object removedChildren = children;
+ @Override
public String toString()
{
return "RemoveAllChange[component: " + getPath() + ", removed Children: " +
removedChildren + "]";
}
+ @Override
public void undo()
{
children = removedChildren;
@@ -709,7 +716,8 @@
/**
* @see org.apache.wicket.Component#setModel(org.apache.wicket.model.IModel)
*/
- public Component setModel(final IModel model)
+ @Override
+ public MarkupContainer<T> setModel(final IModel<T> model)
{
final IModel previous = getModelImpl();
super.setModel(model);
@@ -753,6 +761,7 @@
/**
* @see org.apache.wicket.Component#toString()
*/
+ @Override
public String toString()
{
return toString(false);
@@ -763,6 +772,7 @@
* True if a detailed string is desired
* @return String representation of this container
*/
+ @Override
public String toString(final boolean detailed)
{
final StringBuffer buffer = new StringBuffer();
@@ -1365,6 +1375,7 @@
* @return The markup stream for this component, or if it doesn't have one, the markup stream
* for the nearest parent which does have one
*/
+ @Override
protected final MarkupStream findMarkupStream()
{
// Start here
@@ -1396,6 +1407,7 @@
* @param openTag
* The open tag for the body
*/
+ @Override
protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag)
{
renderComponentTagBody(markupStream, openTag);
@@ -1406,6 +1418,7 @@
*
* @param markupStream
*/
+ @Override
protected void onRender(final MarkupStream markupStream)
{
renderComponent(markupStream);
@@ -1489,6 +1502,7 @@
* @param markupStream
* The markup stream
*/
+ @Override
protected final void setMarkupStream(final MarkupStream markupStream)
{
this.markupStream = markupStream;
@@ -1504,12 +1518,14 @@
private static final long serialVersionUID = 1L;
+ @Override
protected void setChild(MarkupContainer parent, int index, Component child)
{
parent.children_set(index, child, false);
}
}
+ @Override
void detachChildren()
{
super.detachChildren();
@@ -1543,6 +1559,7 @@
}
}
+ @Override
void internalMarkRendering()
{
super.internalMarkRendering();
@@ -1565,6 +1582,7 @@
return result;
}
+ @Override
void onBeforeRenderChildren()
{
super.onBeforeRenderChildren();
@@ -1604,6 +1622,7 @@
}
}
+ @Override
void onAfterRenderChildren()
{
// Loop through child components
@@ -1630,6 +1649,7 @@
/**
* @see org.apache.wicket.Component#setRenderAllowed()
*/
+ @Override
void setRenderAllowed()
{
super.setRenderAllowed();
@@ -1647,7 +1667,7 @@
});
}
- private static class ChildList extends AbstractList implements IClusterable
+ private static class ChildList extends AbstractList<Object> implements IClusterable
{
private static final long serialVersionUID = -7861580911447631127L;
private int size;
@@ -1672,16 +1692,19 @@
}
}
+ @Override
public Object get(int index)
{
return childs[index];
}
+ @Override
public int size()
{
return size;
}
+ @Override
public boolean add(Object o)
{
ensureCapacity(size + 1);
@@ -1689,6 +1712,7 @@
return true;
}
+ @Override
public void add(int index, Object element)
{
if (index > size || index < 0)
@@ -1700,6 +1724,7 @@
size++;
}
+ @Override
public Object set(int index, Object element)
{
if (index >= size)
@@ -1710,6 +1735,7 @@
return oldValue;
}
+ @Override
public Object remove(int index)
{
if (index >= size)
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MetaDataKey.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MetaDataKey.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MetaDataKey.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/MetaDataKey.java Tue Apr 8 11:10:20 2008
@@ -25,10 +25,13 @@
* subtype. That subtype is used to test for identity when looking for the metadata because actual
* object identity would suffer from problems under serialization. So, the correct way to declare a
* MetaDataKey is like this: public static MetaDataKey ROLE = new MetaDataKey(Role.class) { }
- *
+ *
* @author Jonathan Locke
+ *
+ * @param <T>
+ * The object that is stored
*/
-public abstract class MetaDataKey implements IClusterable
+public abstract class MetaDataKey<T> implements IClusterable
{
private static final long serialVersionUID = 1L;
@@ -37,11 +40,11 @@
/**
* Constructor.
- *
+ *
* @param type
* The type of value stored under this key
*/
- public MetaDataKey(final Class type)
+ public MetaDataKey(final Class< ? super T> type)
{
typeName = type.getName();
}
@@ -49,6 +52,7 @@
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals(Object obj)
{
return obj != null && getClass().isInstance(obj);
@@ -59,7 +63,8 @@
* Array of metadata to search
* @return The entry value
*/
- Object get(MetaDataEntry[] metaData)
+ @SuppressWarnings("unchecked")
+ T get(MetaDataEntry[] metaData)
{
if (metaData != null)
{
@@ -68,7 +73,7 @@
MetaDataEntry m = metaData[i];
if (equals(m.key))
{
- return m.object;
+ return (T)m.object;
}
}
}
@@ -140,15 +145,16 @@
/**
* Checks the type of the given object against the type for this metadata key.
- *
+ *
* @param object
* The object to check
* @throws IllegalArgumentException
* Thrown if the type of the given object does not match the type for this key.
*/
+ @SuppressWarnings("unchecked")
void checkType(final Object object)
{
- Class clazz = Classes.resolveClass(typeName);
+ Class<T> clazz = Classes.resolveClass(typeName);
if (object != null && !clazz.isAssignableFrom(object.getClass()))
{
throw new IllegalArgumentException("MetaDataKey " + getClass() +
@@ -159,6 +165,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return getClass() + "[type=" + typeName + "]";
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java Tue Apr 8 11:10:20 2008
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.authorization.UnauthorizedActionException;
@@ -39,7 +40,6 @@
import org.apache.wicket.session.ISessionStore;
import org.apache.wicket.session.pagemap.IPageMapEntry;
import org.apache.wicket.settings.IDebugSettings;
-import org.apache.wicket.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.util.string.StringValue;
@@ -397,6 +397,7 @@
/**
* Detaches any attached models referenced by this page.
*/
+ @Override
public void detachModels()
{
// // visit all this page's children to detach the models
@@ -495,6 +496,7 @@
/**
* @see org.apache.wicket.Component#getId()
*/
+ @Override
public final String getId()
{
return Integer.toString(numericId);
@@ -551,6 +553,7 @@
/**
* @return Size of this page in bytes
*/
+ @Override
public final long getSizeInBytes()
{
pageMap = null;
@@ -564,6 +567,7 @@
*
* @see org.apache.wicket.Component#getStatelessHint()
*/
+ @Override
public final boolean getStatelessHint()
{
return getFlag(FLAG_STATELESS_HINT);
@@ -1003,6 +1007,7 @@
*
* @return String representation of this container
*/
+ @Override
public String toString()
{
if (versionManager != null)
@@ -1369,6 +1374,7 @@
*
* @see org.apache.wicket.Component#internalOnModelChanged()
*/
+ @Override
protected final void internalOnModelChanged()
{
visitChildren(new Component.IVisitor()
@@ -1405,11 +1411,13 @@
* @return Factory method that creates a version manager for this Page
* @deprecated TODO Remove in 1.4
*/
+ @Deprecated
protected final IPageVersionManager newVersionManager()
{
return null;
}
+ @Override
protected void onBeforeRender()
{
super.onBeforeRender();
@@ -1425,6 +1433,7 @@
/**
* @see org.apache.wicket.Component#onDetach()
*/
+ @Override
protected void onDetach()
{
if (log.isDebugEnabled())
@@ -1446,6 +1455,7 @@
*
* @param markupStream
*/
+ @Override
protected void onRender(final MarkupStream markupStream)
{
// Set page's associated markup stream
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java Tue Apr 8 11:10:20 2008
@@ -16,7 +16,6 @@
*/
package org.apache.wicket;
-import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
@@ -350,6 +349,7 @@
* @return whether the page for this request should be redirected
* @deprecated Use {@link #isRedirect()} instead
*/
+ @Deprecated
public final boolean getRedirect()
{
return isRedirect();
@@ -713,6 +713,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return "[RequestCycle" + "@" + Integer.toHexString(hashCode()) + " thread=" +
@@ -1458,8 +1459,7 @@
* @throws IllegalArgumentException
* @see MetaDataKey
*/
- // TODO: Replace the Serializable type with Object for next wicket version
- public final void setMetaData(final MetaDataKey key, final Serializable object)
+ public final <T> void setMetaData(final MetaDataKey<T> key, final T object)
{
metaData = key.set(metaData, object);
}
@@ -1467,13 +1467,16 @@
/**
* Gets metadata for this request cycle using the given key.
*
+ * @param <T>
+ * The type of the metadata
+ *
* @param key
* The key for the data
* @return The metadata or null if no metadata was found for the given key
* @see MetaDataKey
*/
- public final Serializable getMetaData(final MetaDataKey key)
+ public final <T> T getMetaData(final MetaDataKey<T> key)
{
- return (Serializable)key.get(metaData);
+ return key.get(metaData);
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java Tue Apr 8 11:10:20 2008
@@ -134,7 +134,7 @@
{
private static final long serialVersionUID = 1L;
- Set pageMapNames = new HashSet(2);
+ Set<String> pageMapNames = new HashSet<String>(2);
/**
* @param pagemap
@@ -151,7 +151,7 @@
private int sequence = 1;
/** meta data key for missing body tags logging. */
- public static final MetaDataKey PAGEMAP_ACCESS_MDK = new MetaDataKey(
+ public static final MetaDataKey<PageMapAccessMetaData> PAGEMAP_ACCESS_MDK = new MetaDataKey<PageMapAccessMetaData>(
PageMapAccessMetaData.class)
{
private static final long serialVersionUID = 1L;
@@ -161,10 +161,10 @@
public static final String SESSION_ATTRIBUTE_NAME = "session";
/** Thread-local current session. */
- private static final ThreadLocal current = new ThreadLocal();
+ private static final ThreadLocal<Session> current = new ThreadLocal<Session>();
/** A store for dirty objects for one request */
- private static final ThreadLocal dirtyObjects = new ThreadLocal();
+ private static final ThreadLocal<List> dirtyObjects = new ThreadLocal<List>();
/** Logging object */
private static final Logger log = LoggerFactory.getLogger(Session.class);
@@ -175,7 +175,7 @@
private static final long serialVersionUID = 1L;
/** A store for touched pages for one request */
- private static final ThreadLocal touchedPages = new ThreadLocal();
+ private static final ThreadLocal<List> touchedPages = new ThreadLocal<List>();
/** Prefix for attributes holding page map entries */
static final String pageMapEntryAttributePrefix = "p:";
@@ -244,7 +244,7 @@
*/
public static Session get()
{
- Session session = (Session)current.get();
+ Session session = current.get();
if (session == null)
{
session = findOrCreate();
@@ -317,7 +317,7 @@
RequestCycle requestCycle;
};
- private transient Map pageMapsUsedInRequest;
+ private transient Map<IPageMap, PageMapsUsedInRequestEntry> pageMapsUsedInRequest;
/** True, if session has been invalidated */
private transient boolean sessionInvalidated = false;
@@ -340,10 +340,10 @@
* instance).
* </p>
*/
- private transient Map temporarySessionAttributes;
+ private transient Map<String, Object> temporarySessionAttributes;
/** A linked list for last used pagemap queue */
- private final LinkedList/* <IPageMap> */usedPageMaps = new LinkedList();
+ private final LinkedList/* <IPageMap> */<IPageMap>usedPageMaps = new LinkedList<IPageMap>();
/**
* Constructor. Note that {@link RequestCycle} is not available until this constructor returns.
@@ -370,6 +370,7 @@
* @param request
* The current request
*/
+ @Deprecated
protected Session(Application application, Request request)
{
this(request);
@@ -614,9 +615,9 @@
* @return The metadata
* @see MetaDataKey
*/
- public final Serializable getMetaData(final MetaDataKey key)
+ public final Serializable getMetaData(final MetaDataKey<PageMapAccessMetaData> key)
{
- return (Serializable)key.get(metaData);
+ return key.get(metaData);
}
/**
@@ -649,9 +650,9 @@
"To call this method ISessionSettings.setPageIdUniquePerSession must be set to true");
}
- List pageMaps = getPageMaps();
+ List<Object> pageMaps = getPageMaps();
- for (Iterator i = pageMaps.iterator(); i.hasNext();)
+ for (Iterator<Object> i = pageMaps.iterator(); i.hasNext();)
{
IPageMap pm = (IPageMap)i.next();
if (pm.containsPage(pageId, versionNumber))
@@ -693,7 +694,7 @@
{
if (pageMapsUsedInRequest == null)
{
- pageMapsUsedInRequest = new HashMap(3);
+ pageMapsUsedInRequest = new HashMap<IPageMap, PageMapsUsedInRequestEntry>(3);
}
}
synchronized (pageMapsUsedInRequest)
@@ -705,7 +706,7 @@
// later
Duration timeout = Application.get().getRequestCycleSettings().getTimeout();
- PageMapsUsedInRequestEntry entry = (PageMapsUsedInRequestEntry)pageMapsUsedInRequest.get(pageMap);
+ PageMapsUsedInRequestEntry entry = pageMapsUsedInRequest.get(pageMap);
// Get page entry for id and version
Thread t = entry != null ? entry.thread : null;
@@ -728,7 +729,7 @@
throw new WicketRuntimeException(ex);
}
- entry = (PageMapsUsedInRequestEntry)pageMapsUsedInRequest.get(pageMap);
+ entry = pageMapsUsedInRequest.get(pageMap);
t = entry != null ? entry.thread : null;
if (t != null && t != Thread.currentThread() &&
@@ -791,12 +792,12 @@
/**
* @return A list of all PageMaps in this session.
*/
- public final List getPageMaps()
+ public final List<Object> getPageMaps()
{
- final List list = new ArrayList();
- for (final Iterator iterator = getAttributeNames().iterator(); iterator.hasNext();)
+ final List<Object> list = new ArrayList<Object>();
+ for (final Iterator<String> iterator = getAttributeNames().iterator(); iterator.hasNext();)
{
- final String attribute = (String)iterator.next();
+ final String attribute = iterator.next();
if (attribute.startsWith(pageMapAttributePrefix))
{
list.add(getAttribute(attribute));
@@ -811,7 +812,7 @@
public final long getSizeInBytes()
{
long size = Objects.sizeof(this);
- for (final Iterator iterator = getPageMaps().iterator(); iterator.hasNext();)
+ for (final Iterator<Object> iterator = getPageMaps().iterator(); iterator.hasNext();)
{
final IPageMap pageMap = (IPageMap)iterator.next();
size += pageMap.getSizeInBytes();
@@ -902,7 +903,7 @@
{
if (usedPageMaps.size() >= maxPageMaps)
{
- IPageMap pm = (IPageMap)usedPageMaps.getFirst();
+ IPageMap pm = usedPageMaps.getFirst();
pm.remove();
}
}
@@ -1044,10 +1045,10 @@
// store it in a list, so that the pages are really pushed
// to the pagemap when the session does it update/detaches.
// all the pages are then detached
- List lst = (List)touchedPages.get();
+ List<Page> lst = touchedPages.get();
if (lst == null)
{
- lst = new ArrayList();
+ lst = new ArrayList<Page>();
touchedPages.set(lst);
lst.add(page);
}
@@ -1066,7 +1067,7 @@
*/
public final void untouch(Page page)
{
- List lst = (List)touchedPages.get();
+ List lst = touchedPages.get();
if (lst != null)
{
lst.remove(page);
@@ -1079,9 +1080,9 @@
*/
public final void visitPageMaps(final IPageMapVisitor visitor)
{
- for (final Iterator iterator = getAttributeNames().iterator(); iterator.hasNext();)
+ for (final Iterator<String> iterator = getAttributeNames().iterator(); iterator.hasNext();)
{
- final String attribute = (String)iterator.next();
+ final String attribute = iterator.next();
if (attribute.startsWith(pageMapAttributePrefix))
{
visitor.pageMap((IPageMap)getAttribute(attribute));
@@ -1180,7 +1181,7 @@
/**
* @return List of attributes for this session
*/
- protected final List getAttributeNames()
+ protected final List<String> getAttributeNames()
{
if (!isTemporary())
{
@@ -1194,7 +1195,7 @@
{
if (temporarySessionAttributes != null)
{
- return new ArrayList(temporarySessionAttributes.keySet());
+ return new ArrayList<String>(temporarySessionAttributes.keySet());
}
}
return Collections.EMPTY_LIST;
@@ -1286,7 +1287,7 @@
// session instance gets shared across threads
if (temporarySessionAttributes == null)
{
- temporarySessionAttributes = new HashMap(3);
+ temporarySessionAttributes = new HashMap<String, Object>(3);
}
temporarySessionAttributes.put(name, value);
}
@@ -1298,6 +1299,7 @@
* @deprecated obsolete method (was meant for internal book keeping really). Clients should
* override {@link #detach()} instead.
*/
+ @Deprecated
protected final void update()
{
throw new UnsupportedOperationException();
@@ -1310,7 +1312,7 @@
*/
void dirtyPage(final Page page)
{
- List dirtyObjects = getDirtyObjectsList();
+ List<IClusterable> dirtyObjects = getDirtyObjectsList();
if (!dirtyObjects.contains(page))
{
dirtyObjects.add(page);
@@ -1331,7 +1333,7 @@
usedPageMaps.addLast(map);
}
}
- List dirtyObjects = getDirtyObjectsList();
+ List<IClusterable> dirtyObjects = getDirtyObjectsList();
if (!dirtyObjects.contains(map))
{
dirtyObjects.add(map);
@@ -1341,12 +1343,12 @@
/**
* @return The current thread dirty objects list
*/
- List getDirtyObjectsList()
+ List<IClusterable> getDirtyObjectsList()
{
- List list = (List)dirtyObjects.get();
+ List<IClusterable> list = dirtyObjects.get();
if (list == null)
{
- list = new ArrayList(4);
+ list = new ArrayList<IClusterable>(4);
dirtyObjects.set(list);
}
return list;
@@ -1360,7 +1362,7 @@
*/
final void requestDetached()
{
- List touchedPages = (List)Session.touchedPages.get();
+ List touchedPages = Session.touchedPages.get();
Session.touchedPages.set(null);
if (touchedPages != null)
{
@@ -1388,10 +1390,10 @@
}
}
- List dirtyObjects = (List)Session.dirtyObjects.get();
+ List dirtyObjects = Session.dirtyObjects.get();
Session.dirtyObjects.set(null);
- Map tempMap = new HashMap();
+ Map<String, Object> tempMap = new HashMap<String, Object>();
// Go through all dirty entries, replicating any dirty objects
if (dirtyObjects != null)
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java Tue Apr 8 11:10:20 2008
@@ -31,8 +31,10 @@
*
* @author Igor Vaynberg (ivaynberg)
*
+ * @param <T>
+ * The model object type
*/
-public abstract class AjaxLink extends AbstractLink implements IAjaxLink
+public abstract class AjaxLink<T> extends AbstractLink<T> implements IAjaxLink
{
private static final long serialVersionUID = 1L;
@@ -52,7 +54,7 @@
* @param id
* @param model
*/
- public AjaxLink(final String id, final IModel model)
+ public AjaxLink(final String id, final IModel<T> model)
{
super(id, model);
@@ -60,16 +62,19 @@
{
private static final long serialVersionUID = 1L;
+ @Override
protected void onEvent(AjaxRequestTarget target)
{
onClick(target);
}
+ @Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return new CancelEventIfNoAjaxDecorator(AjaxLink.this.getAjaxCallDecorator());
}
+ @Override
protected void onComponentTag(ComponentTag tag)
{
// add the onclick handler only if link is enabled
@@ -81,6 +86,7 @@
});
}
+ @Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
@@ -89,7 +95,7 @@
{
// disable any href attr in markup
if (tag.getName().equalsIgnoreCase("a") || tag.getName().equalsIgnoreCase("link") ||
- tag.getName().equalsIgnoreCase("area"))
+ tag.getName().equalsIgnoreCase("area"))
{
tag.put("href", "#");
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java Tue Apr 8 11:10:20 2008
@@ -30,8 +30,11 @@
* @since 1.3
*
* @author Igor Vaynberg (ivaynberg)
+ *
+ * @param <T>
+ * The model object type
*/
-public abstract class AjaxButton extends Button
+public abstract class AjaxButton<T> extends Button<T>
{
private static final long serialVersionUID = 1L;
@@ -53,6 +56,7 @@
*
* @see org.apache.wicket.markup.html.form.FormComponent#getForm()
*/
+ @Override
public Form getForm()
{
if (form != null)
@@ -81,21 +85,25 @@
private static final long serialVersionUID = 1L;
+ @Override
protected void onSubmit(AjaxRequestTarget target)
{
AjaxButton.this.onSubmit(target, AjaxButton.this.getForm());
}
+ @Override
protected void onError(AjaxRequestTarget target)
{
AjaxButton.this.onError(target, AjaxButton.this.getForm());
}
+ @Override
protected CharSequence getEventHandler()
{
return new AppendingStringBuffer(super.getEventHandler()).append("; return false;");
}
+ @Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return AjaxButton.this.getAjaxCallDecorator();
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java Tue Apr 8 11:10:20 2008
@@ -27,13 +27,16 @@
/**
* An ajax submit button that will degrade to a normal request if ajax is not available or
* javascript is disabled.
- *
+ *
* @since 1.3
- *
+ *
* @author Jeremy Thomerson (jthomerson)
* @author Alastair Maw
+ *
+ * @param <T>
+ * The model object type
*/
-public abstract class AjaxFallbackButton extends Button
+public abstract class AjaxFallbackButton<T> extends Button<T>
{
private static final long serialVersionUID = 1L;
@@ -42,7 +45,7 @@
/**
* Construct.
- *
+ *
* @param id
* @param form
*/
@@ -53,12 +56,12 @@
/**
* Construct.
- *
+ *
* @param id
* @param model
* @param form
*/
- public AjaxFallbackButton(String id, IModel model, Form form)
+ public AjaxFallbackButton(String id, IModel<T> model, Form form)
{
super(id, model);
mForm = form;
@@ -67,21 +70,25 @@
{
private static final long serialVersionUID = 1L;
+ @Override
protected void onSubmit(AjaxRequestTarget target)
{
AjaxFallbackButton.this.onSubmit(target, AjaxFallbackButton.this.getForm());
}
+ @Override
protected void onError(AjaxRequestTarget target)
{
AjaxFallbackButton.this.onError(target, AjaxFallbackButton.this.getForm());
}
+ @Override
protected CharSequence getEventHandler()
{
return new AppendingStringBuffer(super.getEventHandler()).append("; return false;");
}
+ @Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return AjaxFallbackButton.this.getAjaxCallDecorator();
@@ -92,10 +99,10 @@
/**
* Listener method invoked on form submit with errors
- *
+ *
* @param target
* @param form
- *
+ *
* TODO 1.3: Make abstract to be consistent with onsubmit()
*/
protected void onError(AjaxRequestTarget target, Form form)
@@ -106,6 +113,7 @@
/**
* @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#onSubmit()
*/
+ @Override
public final void onSubmit()
{
if (!(getRequestCycle().getRequestTarget() instanceof AjaxRequestTarget))
@@ -114,6 +122,7 @@
}
}
+ @Override
public Form getForm()
{
return mForm == null ? super.getForm() : mForm;
@@ -122,7 +131,7 @@
/**
* Callback for the onClick event. If ajax failed and this event was generated via a normal
* submission, the target argument will be null
- *
+ *
* @param target
* ajax target if this linked was invoked using ajax, null otherwise
* @param form
@@ -137,7 +146,7 @@
/**
* Helper methods that both checks whether the link is enabled and whether the action ENABLE is
* allowed.
- *
+ *
* @return whether the link should be rendered as enabled
*/
protected final boolean isButtonEnabled()
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java Tue Apr 8 11:10:20 2008
@@ -27,46 +27,49 @@
/**
* A link that submits a form via ajax. Since this link takes the form as a constructor argument it
* does not need to be inside form's component hierarchy.
- *
+ *
* <p/> It works by splitting the javascript/Ajax calls from the normal non-ajax requests by
* generating:
- *
+ *
* <pre>
* <a href="normal action url" onclick="ajax javascript script; return
* false;">link</a>
* </pre>
- *
+ *
* If/when javascript is turned off in the browser, or it doesn't support javascript, then the
* browser will not respond to the onclick event, using the href directly. Wicket will then use a
* normal request target, and call the serverside onClick with a null {@link AjaxRequestTarget}.
- *
+ *
* If javascript is enabled, Wicket will send an ajax request, and process it serverside with an
* {@link AjaxRequestTarget} that is supplied to the server-side onClick method. The "return false"
* in the <a href> onclick handler ensures the browser doesn't perform the normal request too.
- *
+ *
* The latter is nicely illustrated with this:
- *
+ *
* <pre>
* <a href="javascript:alert('href event handler');"
* onclick="alert('onclick event handler');">clicking me gives two
* alerts</a>
- *
+ *
* <a href="javascript:alert('href event handler');"
* onclick="alert('onclick event handler');return false;">clicking me
* gives only one alert</a>
* </pre>
- *
+ *
* @since 1.2
- *
+ *
* @author Igor Vaynberg (ivaynberg)
+ *
+ * @param <T>
+ * The model object type
*/
-public abstract class AjaxSubmitLink extends AbstractSubmitLink
+public abstract class AjaxSubmitLink<T> extends AbstractSubmitLink<T>
{
private static final long serialVersionUID = 1L;
/**
* Construct.
- *
+ *
* @param id
*/
public AjaxSubmitLink(String id)
@@ -76,7 +79,7 @@
/**
* Construct.
- *
+ *
* @param id
* @param form
*/
@@ -89,26 +92,31 @@
private static final long serialVersionUID = 1L;
+ @Override
protected void onSubmit(AjaxRequestTarget target)
{
AjaxSubmitLink.this.onSubmit(target, getForm());
}
+ @Override
protected void onError(AjaxRequestTarget target)
{
AjaxSubmitLink.this.onError(target, getForm());
}
+ @Override
protected CharSequence getEventHandler()
{
return new AppendingStringBuffer(super.getEventHandler()).append("; return false;");
}
+ @Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return AjaxSubmitLink.this.getAjaxCallDecorator();
}
+ @Override
protected void onComponentTag(ComponentTag tag)
{
// write the onclick handler only if link is enabled
@@ -124,7 +132,7 @@
/**
* Returns the {@link IAjaxCallDecorator} that will be used to modify the generated javascript.
* This is the preferred way of changing the javascript in the onclick handler
- *
+ *
* @return call decorator used to modify the generated javascript or null for none
*/
protected IAjaxCallDecorator getAjaxCallDecorator()
@@ -132,6 +140,7 @@
return null;
}
+ @Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
@@ -152,7 +161,7 @@
/**
* Final implementation of the Button's onSubmit. AjaxSubmitLinks have there own onSubmit which
* is called.
- *
+ *
* @see org.apache.wicket.markup.html.form.Button#onSubmit()
*/
public final void onSubmit()
@@ -161,7 +170,7 @@
/**
* Listener method invoked on form submit
- *
+ *
* @param target
* @param form
*/
@@ -169,10 +178,10 @@
/**
* Listener method invoked on form submit with errors
- *
+ *
* @param target
* @param form
- *
+ *
* TODO 1.3: Make abstract to be consistent with onsubmit()
*/
protected void onError(AjaxRequestTarget target, Form form)
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/DefaultClassResolver.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/DefaultClassResolver.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/DefaultClassResolver.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/DefaultClassResolver.java Tue Apr 8 11:10:20 2008
@@ -16,9 +16,17 @@
*/
package org.apache.wicket.application;
+import java.io.IOException;
import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
-import org.apache.wicket.util.concurrent.ConcurrentReaderHashMap;
+import org.apache.wicket.Application;
+import org.apache.wicket.WicketRuntimeException;
/**
* Resolves a class by using the classloader that loaded this class.
@@ -41,7 +49,7 @@
*
* This problem has gone since we synchronize the access.
*/
- private final ConcurrentReaderHashMap classes = new ConcurrentReaderHashMap();
+ private final ConcurrentHashMap<String, WeakReference<Class>> classes = new ConcurrentHashMap<String, WeakReference<Class>>();
/**
* @see org.apache.wicket.application.IClassResolver#resolveClass(java.lang.String)
@@ -49,7 +57,7 @@
public final Class resolveClass(final String classname) throws ClassNotFoundException
{
Class clazz = null;
- WeakReference ref = (WeakReference)classes.get(classname);
+ WeakReference ref = classes.get(classname);
// Might be garbage-collected between getting the WeakRef and retrieving
// the Class from it.
@@ -102,9 +110,53 @@
}
clazz = loader.loadClass(classname);
}
- classes.put(classname, new WeakReference(clazz));
+ classes.put(classname, new WeakReference<Class>(clazz));
}
}
return clazz;
}
+
+ public Iterator<URL> getResources(String name)
+ {
+ HashSet<URL> loadedFiles = new HashSet<URL>();
+ try
+ {
+ // Try the classloader for the wicket jar/bundle
+ Enumeration resources = Application.class.getClassLoader().getResources(
+ "wicket.properties");
+ loadResources(resources, loadedFiles);
+
+ // Try the classloader for the user's application jar/bundle
+ resources = Application.get().getClass().getClassLoader().getResources(
+ "wicket.properties");
+ loadResources(resources, loadedFiles);
+
+ // Try the context class loader
+ resources = Thread.currentThread().getContextClassLoader().getResources(
+ "wicket.properties");
+ loadResources(resources, loadedFiles);
+ }
+ catch (IOException e)
+ {
+ throw new WicketRuntimeException(e);
+ }
+
+ return loadedFiles.iterator();
+ }
+
+ private void loadResources(Enumeration resources, Set<URL> loadedFiles)
+ {
+ if (resources != null)
+ {
+ while (resources.hasMoreElements())
+ {
+ final URL url = (URL)resources.nextElement();
+ if (!loadedFiles.contains(url))
+ {
+ loadedFiles.add(url);
+ }
+ }
+ }
+ }
+
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IClassResolver.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IClassResolver.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IClassResolver.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/application/IClassResolver.java Tue Apr 8 11:10:20 2008
@@ -16,8 +16,10 @@
*/
package org.apache.wicket.application;
+import java.util.Iterator;
+
/**
- * An interface to code which finds classes.
+ * An interface to code which finds classes and resources
*
* @author Jonathan Locke
* @author Juergen Donnerstag
@@ -34,4 +36,14 @@
* @throws ClassNotFoundException
*/
Class resolveClass(final String classname) throws ClassNotFoundException;
+
+
+ /**
+ * Tries to load all the resources by the name that is given.
+ *
+ * @param name
+ * @return
+ */
+ Iterator getResources(String name);
+
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java Tue Apr 8 11:10:20 2008
@@ -21,10 +21,10 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.wicket.Component;
import org.apache.wicket.IClusterable;
-import org.apache.wicket.util.concurrent.CopyOnWriteArrayList;
import org.apache.wicket.util.string.StringList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,14 +49,14 @@
/**
* Holds a list of {@link org.apache.wicket.feedback.FeedbackMessage}s.
*/
- private List messages = null;
+ private List<FeedbackMessage> messages = null;
/**
* Construct.
*/
public FeedbackMessages()
{
- messages = new CopyOnWriteArrayList();
+ messages = new CopyOnWriteArrayList<FeedbackMessage>();
}
/**
@@ -95,7 +95,7 @@
return 0;
}
- List toDelete = messages(filter);
+ List<FeedbackMessage> toDelete = messages(filter);
int count = toDelete.size();
messages.removeAll(toDelete);
@@ -221,7 +221,7 @@
*
* @return iterator over stored messages
*/
- public final Iterator iterator()
+ public final Iterator<FeedbackMessage> iterator()
{
return messages.iterator();
}
@@ -236,9 +236,9 @@
*/
public final FeedbackMessage messageForComponent(final Component component)
{
- for (Iterator iterator = messages.iterator(); iterator.hasNext();)
+ for (Iterator<FeedbackMessage> iterator = messages.iterator(); iterator.hasNext();)
{
- FeedbackMessage message = (FeedbackMessage)iterator.next();
+ FeedbackMessage message = iterator.next();
if (message.getReporter() == component)
{
return message;
@@ -254,17 +254,17 @@
* Filter for selecting messages. If null, all messages will be returned
* @return The messages or an empty list if no messages are found
*/
- public final List messages(final IFeedbackMessageFilter filter)
+ public final List<FeedbackMessage> messages(final IFeedbackMessageFilter filter)
{
if (messages.size() == 0)
{
return Collections.EMPTY_LIST;
}
- final List list = new ArrayList();
- for (final Iterator iterator = messages.iterator(); iterator.hasNext();)
+ final List<FeedbackMessage> list = new ArrayList<FeedbackMessage>();
+ for (final Iterator<FeedbackMessage> iterator = messages.iterator(); iterator.hasNext();)
{
- final FeedbackMessage message = (FeedbackMessage)iterator.next();
+ final FeedbackMessage message = iterator.next();
if (filter == null || filter.accept(message))
{
list.add(message);
@@ -294,9 +294,9 @@
public final int size(final IFeedbackMessageFilter filter)
{
int count = 0;
- for (final Iterator iterator = messages.iterator(); iterator.hasNext();)
+ for (final Iterator<FeedbackMessage> iterator = messages.iterator(); iterator.hasNext();)
{
- final FeedbackMessage message = (FeedbackMessage)iterator.next();
+ final FeedbackMessage message = iterator.next();
if (filter == null || filter.accept(message))
{
count++;
@@ -308,6 +308,7 @@
/**
* @see java.lang.Object#toString()
*/
+ @Override
public String toString()
{
return "[feedbackMessages = " + StringList.valueOf(messages) + "]";
@@ -320,7 +321,7 @@
{
if (messages instanceof ArrayList)
{
- ((ArrayList)messages).trimToSize();
+ ((ArrayList<FeedbackMessage>)messages).trimToSize();
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java Tue Apr 8 11:10:20 2008
@@ -52,9 +52,6 @@
*/
public static final String DEFAULT_WICKET_NAMESPACE = "wicket";
- /** an empty list */
- private static final List EMPTY_LIST = new ArrayList();
-
/**
* Assuming this is a open (or open-close) tag, 'closes' refers to the ComponentTag which closes
* it.
@@ -92,7 +89,7 @@
* about the tags origin is lost. In some cases like wicket:head and wicket:link this
* information however is required.
*/
- private WeakReference/* <Class> */markupClassRef = null;
+ private WeakReference<Class> markupClassRef = null;
/**
* Tags which are detected to have only an open tag, which is allowed with some HTML tags like
@@ -101,10 +98,10 @@
private boolean hasNoCloseTag = false;
/** added behaviors */
- private List behaviors;
+ private List<IBehavior> behaviors;
/** Filters and Handlers may add their own attributes to the tag */
- private Map userData;
+ private Map<String, Object> userData;
/**
* Automatically create a XmlTag, assign the name and the type, and construct a ComponentTag
@@ -149,7 +146,7 @@
if (behaviors == null)
{
- behaviors = new ArrayList();
+ behaviors = new ArrayList<IBehavior>();
}
behaviors.add(behavior);
}
@@ -165,15 +162,15 @@
/**
* @return read only iterator over added behaviors
*/
- public final Iterator getBehaviors()
+ public final Iterator<IBehavior> getBehaviors()
{
if (behaviors == null)
{
- List empty = EMPTY_LIST;
- return empty.iterator();
+ List<IBehavior> lst = Collections.emptyList();
+ return lst.iterator();
}
- Collection locked = Collections.unmodifiableCollection(behaviors);
+ Collection<IBehavior> locked = Collections.unmodifiableCollection(behaviors);
return locked.iterator();
}
@@ -184,6 +181,7 @@
* The open tag
* @return True if this tag closes the given open tag
*/
+ @Override
public final boolean closes(final MarkupElement open)
{
if (open instanceof ComponentTag)
@@ -417,11 +415,11 @@
dest.setAutoComponentTag(autoComponent);
if (markupClassRef != null)
{
- dest.setMarkupClass((Class)markupClassRef.get());
+ dest.setMarkupClass(markupClassRef.get());
}
if (behaviors != null)
{
- dest.behaviors = new ArrayList(behaviors.size());
+ dest.behaviors = new ArrayList<IBehavior>(behaviors.size());
dest.behaviors.addAll(behaviors);
}
}
@@ -479,7 +477,7 @@
* @param map
* a key/value map
*/
- public final void putAll(final Map map)
+ public final void putAll(final Map<String, Object> map)
{
xmlTag.putAll(map);
}
@@ -587,6 +585,7 @@
/**
* @see org.apache.wicket.markup.MarkupElement#toCharSequence()
*/
+ @Override
public CharSequence toCharSequence()
{
return xmlTag.toCharSequence();
@@ -597,6 +596,7 @@
*
* @return String version of this object
*/
+ @Override
public final String toString()
{
return toCharSequence().toString();
@@ -613,7 +613,7 @@
* Wicket's namespace to use
*/
public final void writeOutput(final Response response, final boolean stripWicketAttributes,
- final String namespace)
+ final String namespace)
{
response.write("<");
@@ -678,6 +678,7 @@
*
* @return String version of this object
*/
+ @Override
public final String toUserDebugString()
{
return xmlTag.toUserDebugString();
@@ -785,6 +786,7 @@
/**
* @see org.apache.wicket.markup.MarkupElement#equalTo(org.apache.wicket.markup.MarkupElement)
*/
+ @Override
public boolean equalTo(final MarkupElement element)
{
if (element instanceof ComponentTag)
@@ -862,7 +864,7 @@
{
if (userData == null)
{
- userData = new HashMap();
+ userData = new HashMap<String, Object>();
}
userData.put(key, value);
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java Tue Apr 8 11:10:20 2008
@@ -47,7 +47,8 @@
* reloaded. Whatever is in the cache, it will be ignored
* @return Markup resource
*/
- Markup getMarkup(final MarkupContainer container, final Class clazz, final boolean enforceReload);
+ Markup getMarkup(final MarkupContainer container,
+ final Class< ? extends MarkupContainer> clazz, final boolean enforceReload);
/**
* Gets a fresh markup stream that contains the (immutable) markup resource for this class.
@@ -62,7 +63,7 @@
* @return A stream of MarkupElement elements
*/
MarkupStream getMarkupStream(final MarkupContainer container, final boolean enforceReload,
- final boolean throwException);
+ final boolean throwException);
/**
* Check if container has associated markup
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=646020&r1=646019&r2=646020&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java Tue Apr 8 11:10:20 2008
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.Application;
import org.apache.wicket.MarkupContainer;
@@ -26,7 +27,6 @@
import org.apache.wicket.markup.loader.DefaultMarkupLoader;
import org.apache.wicket.markup.loader.IMarkupLoader;
import org.apache.wicket.settings.IMarkupSettings;
-import org.apache.wicket.util.concurrent.ConcurrentHashMap;
import org.apache.wicket.util.listener.IChangeListener;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
@@ -56,10 +56,10 @@
private static final Logger log = LoggerFactory.getLogger(MarkupCache.class);
/** Map of markup tags by class (exactly what is in the file). */
- private final ICache /* <String(LocationString),Markup> */markupCache;
+ private final ICache<CharSequence, Markup> markupCache;
/** Map of markup tags by class (exactly what is in the file). */
- private final ICache /* <String(CacheKey),String(LocationString)> */markupKeyCache;
+ private final ICache<CharSequence, CharSequence> markupKeyCache;
/** The markup cache key provider used by MarkupCache */
private IMarkupCacheKeyProvider markupCacheKeyProvider;
@@ -143,7 +143,7 @@
// If a base markup file has been removed from the cache, than
// the derived markup should be removed as well.
- Iterator iter = markupCache.getKeys().iterator();
+ Iterator<CharSequence> iter = markupCache.getKeys().iterator();
while (iter.hasNext())
{
Markup cacheMarkup = (Markup)markupCache.get(iter.next());
@@ -178,10 +178,10 @@
.getResourceWatcher(true);
if (watcher != null)
{
- Iterator iter = watcher.getEntries().iterator();
+ Iterator<IModifiable> iter = watcher.getEntries().iterator();
while (iter.hasNext())
{
- IModifiable modifiable = (IModifiable)iter.next();
+ IModifiable modifiable = iter.next();
if (modifiable instanceof MarkupResourceStream)
{
MarkupResourceStream resourceStream = (MarkupResourceStream)modifiable;
@@ -253,7 +253,7 @@
*
* @return
*/
- protected final ICache getMarkupCache()
+ protected final ICache<CharSequence, Markup> getMarkupCache()
{
return markupCache;
}
@@ -584,20 +584,28 @@
* Allows you to change the map implementation which will hold the cache data. By default it is
* a ConcurrentHashMap() in order to allow multiple thread to access the data in a secure way.
*
+ * @param <K>
+ * @param <V>
+ *
* @return
*/
- protected ICache newCacheImplementation()
+ protected <K, V> ICache<K, V> newCacheImplementation()
{
- return new DefaultCacheImplementation();
+ return new DefaultCacheImplementation<K, V>();
}
/**
* MarkupCache allows you to implement you own cache implementation. ICache is the interface the
* implementation must comply with.
*
+ * @param <K>
+ * The key type
+ * @param <V>
+ * The value type
+ *
* @see MarkupCache
*/
- public interface ICache
+ public interface ICache<K, V>
{
/**
* Clear the cache
@@ -610,7 +618,7 @@
* @param key
* @return true, if found and removed
*/
- boolean remove(Object key);
+ boolean remove(K key);
/**
* Get the cache element associated with the key
@@ -618,14 +626,14 @@
* @param key
* @return
*/
- Object get(Object key);
+ Object get(K key);
/**
* Get all the keys referencing cache entries
*
* @return
*/
- Collection getKeys();
+ Collection<K> getKeys();
/**
* Check if key is in the cache
@@ -633,7 +641,7 @@
* @param key
* @return
*/
- boolean containsKey(Object key);
+ boolean containsKey(K key);
/**
* Get the number of cache entries
@@ -650,7 +658,7 @@
* @param value
* The element to be cached
*/
- void put(Object key, Object value);
+ void put(K key, V value);
/**
* Cleanup and shutdown
@@ -659,13 +667,15 @@
}
/**
+ * @param <K>
+ * @param <V>
*
*/
- public class DefaultCacheImplementation implements ICache
+ public class DefaultCacheImplementation<K, V> implements ICache<K, V>
{
private static final long serialVersionUID = 1L;
- private final ConcurrentHashMap cache = new ConcurrentHashMap();
+ private final ConcurrentHashMap<K, V> cache = new ConcurrentHashMap<K, V>();
/**
* Construct.
@@ -701,7 +711,7 @@
/**
* @see org.apache.wicket.markup.MarkupCache.ICache#getKeys()
*/
- public Collection getKeys()
+ public Collection<K> getKeys()
{
return cache.keySet();
}
@@ -709,7 +719,7 @@
/**
* @see org.apache.wicket.markup.MarkupCache.ICache#put(java.lang.Object, java.lang.Object)
*/
- public void put(Object key, Object value)
+ public void put(K key, V value)
{
cache.put(key, value);
}
@@ -717,7 +727,7 @@
/**
* @see org.apache.wicket.markup.MarkupCache.ICache#remove(java.lang.Object)
*/
- public boolean remove(Object key)
+ public boolean remove(K key)
{
return cache.remove(key) == null;
}