Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/MountedEncoder.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/MountedEncoder.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/MountedEncoder.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/MountedEncoder.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.encoder;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.wicket.IPage;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.encoder.info.PageComponentInfo;
+import org.apache.wicket.request.encoder.parameters.PageParametersEncoder;
+import 
org.apache.wicket.request.encoder.parameters.SimplePageParametersEncoder;
+import org.apache.wicket.request.request.Request;
+
+/**
+ * Encoder for mounted URL. The mount path can contain parameter placeholders, 
i.e.
+ * <code>/mount/${foo}/path</code>. In that case the appropriate segment from 
the URL will be
+ * accessible as named parameter "foo" in the {...@link PageParameters}. 
Similarly when the URL is
+ * constructed, the second segment will contain the value of the "foo" named 
page parameter.
+ * <p>
+ * Decodes and encodes the following URLs:
+ * 
+ * <pre>
+ *  Page Class - Render (BookmarkablePageRequestHandler for mounted pages)
+ *  /mount/point
+ *  /mount/point?pageMap
+ *  (these will redirect to hybrid alternative if page is not stateless)
+ * 
+ *  IPage Instance - Render Hybrid (RenderPageRequestHandler for mounted 
pages) 
+ *  /mount/point?2
+ *  /mount/point?2.4
+ *  /mount/point?pageMap.2.4
+ * 
+ *  IPage Instance - Bookmarkable Listener 
(BookmarkableListenerInterfaceRequestHandler for mounted pages) 
+ *  /mount/point?2-click-foo-bar-baz
+ *  /mount/point?2.4-click-foo-bar-baz
+ *  /mount/point?pageMap.2.4-click-foo-bar-baz
+ *  /mount/point?2.4-click.1-foo-bar-baz (1 is behavior index)
+ *  (these will redirect to hybrid if page is not stateless)
+ * </pre>
+ * 
+ * @author Matej Knopp
+ */
+public class MountedEncoder extends AbstractBookmarkableEncoder
+{
+       private final PageParametersEncoder pageParametersEncoder;
+       private final String[] mountSegments;
+
+       /** bookmarkable page class. */
+       protected final WeakReference<Class<? extends IPage>> pageClass;
+
+
+       /**
+        * Construct.
+        * 
+        * @param mountPath
+        * @param pageClass
+        * @param pageParametersEncoder
+        */
+       public MountedEncoder(String mountPath, Class<? extends IPage> 
pageClass,
+               PageParametersEncoder pageParametersEncoder)
+       {
+               if (pageParametersEncoder == null)
+               {
+                       throw new IllegalArgumentException("Argument 
'pageParametersEncoder' may not be null.");
+               }
+               if (pageClass == null)
+               {
+                       throw new IllegalArgumentException("Argument 
'pageClass' may not be null.");
+               }
+               if (mountPath == null)
+               {
+                       throw new IllegalArgumentException("Argument 
'mountPath' may not be null.");
+               }
+               this.pageParametersEncoder = pageParametersEncoder;
+               this.pageClass = new WeakReference<Class<? extends 
IPage>>(pageClass);
+               this.mountSegments = getMountSegments(mountPath);
+       }
+
+       /**
+        * Construct.
+        * 
+        * @param mountPath
+        * @param pageClass
+        */
+       public MountedEncoder(String mountPath, Class<? extends IPage> 
pageClass)
+       {
+               this(mountPath, pageClass, new SimplePageParametersEncoder());
+       }
+
+       @Override
+       protected UrlInfo parseRequest(Request request)
+       {
+               Url url = request.getUrl();
+
+               // when redirect to buffer/render is active and 
redirectFromHomePage returns true
+               // check mounted class against the home page class. if it 
matches let wicket redirect
+               // to the mounted URL
+               if (redirectFromHomePage() && checkHomePage(url))
+               {
+                       UrlInfo info = new UrlInfo(null, 
getContext().getHomePageClass(), newPageParameters());
+                       return info;
+               }
+               // check if the URL is long enough and starts with the proper 
segments
+               else if (url.getSegments().size() >= mountSegments.length &&
+                       urlStartsWith(url, mountSegments))
+               {
+                       // try to extract page and component information from 
URL
+                       PageComponentInfo info = getPageComponentInfo(url);
+
+                       Class<? extends IPage> pageClass = this.pageClass.get();
+
+                       // extract the PageParameters from URL if there are any
+                       PageParameters pageParameters = 
extractPageParameters(url,
+                               request.getRequestParameters(), 
mountSegments.length, pageParametersEncoder);
+
+                       // check if there are placeholders in mount segments
+                       for (int i = 0; i < mountSegments.length; ++i)
+                       {
+                               String placeholder = 
getPlaceholder(mountSegments[i]);
+                               if (placeholder != null)
+                               {
+                                       // extract the parameter from URL
+                                       
pageParameters.addNamedParameter(placeholder, url.getSegments().get(i));
+                               }
+                       }
+
+                       return new UrlInfo(info, pageClass, pageParameters);
+               }
+               else
+               {
+                       return null;
+               }
+       }
+
+       protected PageParameters newPageParameters()
+       {
+               return new PageParameters();
+       }
+
+       @Override
+       protected Url buildUrl(UrlInfo info)
+       {
+               Url url = new Url();
+               for (String s : mountSegments)
+               {
+                       url.getSegments().add(s);
+               }
+               encodePageComponentInfo(url, info.getPageComponentInfo());
+
+               PageParameters copy = new 
PageParameters(info.getPageParameters());
+
+               for (int i = 0; i < mountSegments.length; ++i)
+               {
+                       String placeholder = getPlaceholder(mountSegments[i]);
+                       if (placeholder != null)
+                       {
+                               url.getSegments().set(i, 
copy.getNamedParameter(placeholder).toString(""));
+                               copy.removeNamedParameter(placeholder);
+                       }
+               }
+
+               return encodePageParameters(url, copy, pageParametersEncoder);
+       }
+
+       /**
+        * Check if the URL is for home page and the home page class match 
mounted class. If so,
+        * redirect to mounted URL.
+        * 
+        * @param url
+        * @return request handler or <code>null</code>
+        */
+       private boolean checkHomePage(Url url)
+       {
+               if (url.getSegments().isEmpty() && 
url.getQueryParameters().isEmpty())
+               {
+                       // this is home page
+                       if 
(pageClass.get().equals(getContext().getHomePageClass()) && 
redirectFromHomePage())
+                       {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * If this method returns <code>true</code> and application home page 
class is same as the
+        * class mounted with this encoder, request to home page will result in 
a redirect to the
+        * mounted path.
+        * 
+        * @return whether this encode should respond to home page request when 
home page class is same
+        *         as mounted class.
+        */
+       protected boolean redirectFromHomePage()
+       {
+               return true;
+       }
+
+       @Override
+       protected boolean pageMustHaveBeenCreatedBookmarkable()
+       {
+               return false;
+       }
+
+       public int getMachingSegmentsCount(Request request)
+       {
+               if (urlStartsWith(request.getUrl(), mountSegments))
+               {
+                       return mountSegments.length;
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/MountedEncoder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/PageInstanceEncoder.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/PageInstanceEncoder.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/PageInstanceEncoder.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/PageInstanceEncoder.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.encoder;
+
+import org.apache.wicket.IComponent;
+import org.apache.wicket.IPage;
+import org.apache.wicket.RequestListenerInterface;
+import org.apache.wicket.request.RequestHandler;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.encoder.info.ComponentInfo;
+import org.apache.wicket.request.encoder.info.PageComponentInfo;
+import org.apache.wicket.request.encoder.info.PageInfo;
+import org.apache.wicket.request.handler.impl.ListenerInterfaceRequestHandler;
+import org.apache.wicket.request.handler.impl.RenderPageRequestHandler;
+import org.apache.wicket.request.request.Request;
+
+/**
+ * Decodes and encodes the following URLs:
+ * 
+ * <pre>
+ *  Page Instance - Render (RenderPageRequestHandler)
+ *  /wicket/page?2
+ *  /wicket/page?2.4
+ *  /wicket/page?abc.2.4
+ * 
+ *  Page Instance - Listener (ListenerInterfaceRequestHandler)
+ *  /wicket/page?2-click-foo-bar-baz
+ *  /wicket/page?2.4-click-foo-bar-baz
+ *  /wicket/page?pageMap.2.4-click-foo-bar-bazr-baz
+ *  /wicket/page?2.4-click.1-foo-bar-baz (1 is behavior index)  
+ * </pre>
+ * 
+ * @author Matej Knopp
+ */
+public class PageInstanceEncoder extends AbstractEncoder
+{
+
+       /**
+        * Construct.
+        */
+       public PageInstanceEncoder()
+       {
+       }
+
+
+       public RequestHandler decode(Request request)
+       {
+               Url url = request.getUrl();
+               if (urlStartsWith(url, getContext().getNamespace(), 
getContext().getPageIdentifier()))
+               {
+                       PageComponentInfo info = getPageComponentInfo(url);
+                       if (info != null && info.getPageInfo().getPageId() != 
null)
+                       {
+                               Integer renderCount = info.getComponentInfo() 
!= null ? info.getComponentInfo().getRenderCount() : null;
+                               
+                               IPage page = 
getPageInstance(info.getPageInfo(), renderCount);
+                               
+                               if (info.getComponentInfo() == null)
+                               {
+                                       // render page
+                                       return new 
RenderPageRequestHandler(page);
+                               }
+                               else
+                               {
+                                       ComponentInfo componentInfo = 
info.getComponentInfo();
+                                       // listener interface
+                                       IComponent component = 
getComponent(page, componentInfo.getComponentPath());
+                                       RequestListenerInterface 
listenerInterface = 
requestListenerInterfaceFromString(componentInfo.getListenerInterface());
+
+                                       return new 
ListenerInterfaceRequestHandler(page, component, listenerInterface,
+                                               
componentInfo.getBehaviorIndex());
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public Url encode(RequestHandler requestHandler)
+       {
+               PageComponentInfo info = null;
+
+               if (requestHandler instanceof RenderPageRequestHandler)
+               {
+                       IPage page = 
((RenderPageRequestHandler)requestHandler).getPage();
+
+                       PageInfo i = new PageInfo(page);
+                       info = new PageComponentInfo(i, null);
+               }
+               else if (requestHandler instanceof 
ListenerInterfaceRequestHandler)
+               {
+                       ListenerInterfaceRequestHandler handler = 
(ListenerInterfaceRequestHandler)requestHandler;
+                       IPage page = handler.getPage();
+                       String componentPath = handler.getComponent().getPath();
+                       RequestListenerInterface listenerInterface = 
handler.getListenerInterface();
+
+                       PageInfo pageInfo = new PageInfo(page);
+                       ComponentInfo componentInfo = new ComponentInfo(
+                               page.getRenderCount(), 
requestListenerInterfaceToString(listenerInterface), componentPath,
+                               handler.getBehaviorIndex());
+                       info = new PageComponentInfo(pageInfo, componentInfo);
+               }
+
+               if (info != null)
+               {
+                       Url url = new Url();
+                       url.getSegments().add(getContext().getNamespace());
+                       url.getSegments().add(getContext().getPageIdentifier());
+                       encodePageComponentInfo(url, info);
+                       return url;
+               }
+               else
+               {
+                       return null;
+               }
+       }
+
+       public int getMachingSegmentsCount(Request request)
+       {
+               // always return 0 here so that the mounts have higher priority
+               return 0;
+       }
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/PageInstanceEncoder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/ResourceReferenceEncoder.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/ResourceReferenceEncoder.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/ResourceReferenceEncoder.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/ResourceReferenceEncoder.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.encoder;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.request.RequestHandler;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.encoder.parameters.PageParametersEncoder;
+import 
org.apache.wicket.request.encoder.parameters.SimplePageParametersEncoder;
+import 
org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
+import org.apache.wicket.request.handler.resource.ResourceRequestHandler;
+import org.apache.wicket.request.request.Request;
+import org.apache.wicket.resource.Resource;
+import org.apache.wicket.resource.ResourceReference;
+import org.apache.wicket.util.lang.Classes;
+
+/**
+ * Generic {...@link ResourceReference} encoder that encodes and decodes 
non-mounted
+ * {...@link ResourceReference}s.
+ * <p>
+ * Decodes and encodes the following URLs:
+ * <pre>
+ *    /wicket/resource/org.apache.wicket.ResourceScope/name
+ *    /wicket/resource/org.apache.wicket.ResourceScope/name?en
+ *    /wicket/resource/org.apache.wicket.ResourceScope/name?-style
+ *    
/wicket/resource/org.apache.wicket.ResourceScope/resource/name.xyz?en_EN-style
+ * </pre>
+ * 
+ * @author Matej Knopp
+ */
+public class ResourceReferenceEncoder extends AbstractResourceReferenceEncoder
+{
+       private final PageParametersEncoder pageParametersEncoder;
+
+       /**
+        * Construct.
+        * 
+        * @param pageParametersEncoder
+        */
+       public ResourceReferenceEncoder(PageParametersEncoder 
pageParametersEncoder)
+       {
+               this.pageParametersEncoder = pageParametersEncoder;
+       }
+
+       /**
+        * Construct.
+        */
+       public ResourceReferenceEncoder()
+       {
+               this(new SimplePageParametersEncoder());
+       }
+
+       protected EncoderContext getContext()
+       {
+               return null;
+       };
+
+       public RequestHandler decode(Request request)
+       {
+               Url url = request.getUrl();
+               if (url.getSegments().size() >= 4 &&
+                       urlStartsWith(url, getContext().getNamespace(), 
getContext().getResourceIdentifier()))
+               {
+                       String className = url.getSegments().get(2);
+                       StringBuilder name = new StringBuilder();
+                       for (int i = 3; i < url.getSegments().size(); ++i)
+                       {
+                               if (name.length() > 0)
+                               {
+                                       name.append("/");
+                               }
+                               name.append(url.getSegments().get(i));
+                       }
+
+                       ResourceReferenceAttributes attributes = 
getResourceReferenceAttributes(url);
+
+                       // extract the PageParameters from URL if there are any
+                       PageParameters pageParameters = 
extractPageParameters(url,
+                               request.getRequestParameters(), 
url.getSegments().size(), pageParametersEncoder);
+
+                       Class<?> scope = resolveClass(className);
+                       if (scope != null)
+                       {
+                               ResourceReference res = 
getContext().getResourceReferenceRegistry()
+                                       .getResourceReference(scope, 
name.toString(), attributes.locale,
+                                               attributes.style, false);
+                               if (res != null)
+                               {
+                                       Resource resource = res.getResource();
+                                       if (resource != null)
+                                       {
+                                               ResourceRequestHandler handler 
= new ResourceRequestHandler(resource,
+                                                       attributes.locale, 
attributes.style, pageParameters);
+                                               return handler;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       protected Class<?> resolveClass(String name)
+       {
+               return Classes.resolveClass(name);
+       }
+
+       protected String getClassName(Class<?> scope)
+       {
+               return scope.getName();
+       }
+
+       public Url encode(RequestHandler requestHandler)
+       {
+               if (requestHandler instanceof ResourceReferenceRequestHandler)
+               {
+                       ResourceReferenceRequestHandler referenceRequestHandler 
= (ResourceReferenceRequestHandler)requestHandler;
+                       ResourceReference reference = 
referenceRequestHandler.getResourceReference();
+                       Url url = new Url();
+                       url.getSegments().add(getContext().getNamespace());
+                       
url.getSegments().add(getContext().getResourceIdentifier());
+                       
url.getSegments().add(getClassName(reference.getScope()));
+                       String nameParts[] = reference.getName().split("/");
+                       for (String name : nameParts)
+                       {
+                               url.getSegments().add(name);
+                       }
+                       encodeResourceReferenceAttributes(url, reference);
+                       PageParameters parameters = 
referenceRequestHandler.getPageParameters();
+                       if (parameters != null)
+                       {
+                               parameters = new PageParameters(parameters);
+                               // need to remove indexed parameters otherwise 
the URL won't be able to decode
+                               parameters.clearIndexedParameters();
+                               url = encodePageParameters(url, parameters, 
pageParametersEncoder);
+                       }
+                       return url;
+               }
+               return null;
+       }
+
+       public int getMachingSegmentsCount(Request request)
+       {
+               // always return 0 here so that the mounts have higher priority
+               return 0;
+       }
+
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/ResourceReferenceEncoder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/StalePageException.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/StalePageException.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/StalePageException.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/StalePageException.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.encoder;
+
+import org.apache.wicket.IPage;
+import org.apache.wicket.WicketRuntimeException;
+
+/**
+ * Exception invoked when when stale link has been clicked. The page should 
then be rerendered
+ * with an explanatory error message.
+ * 
+ * @author Matej Knopp
+ */
+public class StalePageException extends WicketRuntimeException
+{
+       private static final long serialVersionUID = 1L;
+
+       private final IPage page;
+
+       /**
+        * 
+        * Construct.
+        * @param page
+        */
+       public StalePageException(IPage page)
+       {
+               this.page = page;
+       }
+       
+       /**
+        * 
+        * @return page instance
+        */
+       public IPage getPage()
+       {
+               return page;
+       }
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/encoder/StalePageException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/ComponentRequestHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/ComponentRequestHandler.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/ComponentRequestHandler.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/ComponentRequestHandler.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.handler;
+
+import org.apache.wicket.IComponent;
+import org.apache.wicket.request.RequestHandler;
+
+/**
+ * Request handler that works with a component.
+ * 
+ * @author Matje Knopp
+ */
+public interface ComponentRequestHandler extends RequestHandler
+{
+       /**
+        * Returns the component instance.
+        * 
+        * @return component instance
+        */
+       public IComponent getComponent();
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/ComponentRequestHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageClassRequestHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageClassRequestHandler.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageClassRequestHandler.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageClassRequestHandler.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.handler;
+
+import org.apache.wicket.IPage;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.request.RequestHandler;
+
+/**
+ * Request handler that works with page class.
+ * 
+ * @author Matej Knopp
+ */
+public interface PageClassRequestHandler extends RequestHandler
+{
+       /**
+        * Returns the page class
+        * 
+        * @return page class
+        */
+       public Class<? extends IPage> getPageClass();
+       
+       /**
+        * @return page parameters
+        */
+       public PageParameters getPageParameters();
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageClassRequestHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageRequestHandler.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageRequestHandler.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageRequestHandler.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageRequestHandler.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.handler;
+
+import org.apache.wicket.IPage;
+
+/**
+ * Request handler that works with a page instance.
+ * 
+ * @author Matej Knopp
+ */
+public interface PageRequestHandler extends PageClassRequestHandler
+{
+       /**
+        * Returns the page
+        * 
+        * @return page instance
+        */
+       public IPage getPage();
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/handler/PageRequestHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/url-format.txt
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/url-format.txt?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/url-format.txt
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/url-format.txt
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,59 @@
+NOTE - According to http://www.rfc-editor.org/rfc/rfc1738.txt ':' is not a 
valid
+       character in URL and must be encoded. 
+       In order for Wicket to produce valid URLs I've decided to use - as 
separator instead
+       This will only affect listener URLs anyway, which are not shown in 
location bar 
+       (except for bookmarkable listeners on stateless pages)
+       '-' in component name is encoded as '--'.
+
+
+NOT BOOKMARKABLE
+----------------
+
+Page Instance - Render (RenderPageRequestHandler)
+/wicket/page?2
+
+Page Instance - Listener (ListenerInterfaceRequestHandler)
+/wicket/page?2-click-foo-bar-baz
+
+BOOKMARKABLE - NOT MOUNTED
+--------------------------
+
+Page Class - Render (BookmarkablePageRequestHandler)
+/wicket/bookmarkable/org.apache.wicket.MyPage
+/wicket/bookmarkable/org.apache.wicket.MyPage?pageMap
+(these will redirect to hybrid alternative if page is not stateless)
+
+Page Instance - Render Hybrid (RenderPageRequestHandler for pages that were 
created using bookmarkable URLs)
+/wicket/bookmarkable/org.apache.wicket.MyPage?2
+
+Page Instance - Bookmarkable Listener 
(BookmarkableListenerInterfaceRequestHandler)
+/wicket/bookmarkable/org.apache.wicket.MyPage?2-5.click-foo-bar-baz (5 is 
renderCount)
+/wicket/bookmarkable/org.apache.wicket.MyPage?2-5.click.1-foo-bar-baz (5 is 
renderCount, 1 is behavior index)
+(these will redirect to hybrid if page is not stateless)
+
+BOOKMARKABLE - MOUNTED
+----------------------
+
+Page Class - Render (BookmarkablePageRequestHandler for mounted pages)
+/mount/point
+/mount/point?pageMap
+(these will redirect to hybrid alternative if page is not stateless)
+
+Page Instance - Render Hybrid (RenderPageRequestHandler for mounted pages) 
+/mount/point?2
+
+Page Instance - Bookmarkable Listener 
(BookmarkableListenerInterfaceRequestHandler for mounted pages) 
+/mount/point?2-5.click-foo-bar-baz (5 is render count)
+/mount/point?2-5.click.1-foo-bar-baz (5 is render count, 1 is behavior index)
+(these will redirect to hybrid if page is not stateless)
+
+mount path can also contain parameter placeholders
+e.g. when mount path is /foo/${bar}/baz and the incomming url is /foo/abc/baz  
 the extracted page parameters will 
+contain named parameter bar="abc".
+
+RESOURCES
+---------
+/wicket/resource/org.apache.wicket.ResourceScope/resource/path.xyz?en_EN-style
+/mounted/resource?en_EN-style
+/mounted/resource/with/locale/and/style
+

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/request/url-format.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/settings/IRequestCycleSettings.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/settings/IRequestCycleSettings.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/settings/IRequestCycleSettings.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/settings/IRequestCycleSettings.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,19 @@
+package org.apache.wicket.settings;
+
+public interface IRequestCycleSettings
+{
+       public enum RenderStrategy
+       {
+               ONE_PASS_RENDER,
+               REDIRECT_TO_BUFFER,
+               REDIRECT_TO_RENDER
+       };
+       
+       void setRenderStrategy(RenderStrategy renderStrategy);
+       
+       RenderStrategy getRenderStrategy();
+       
+       String getResponseRequestEncoding();
+       
+       void setResponseRequestEncoding(final String responseRequestEncoding);
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/settings/IRequestCycleSettings.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Classes.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Classes.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Classes.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Classes.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,44 @@
+package org.apache.wicket.util.lang;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Classes
+{
+
+       /**
+        * @param <T>
+        *            class type
+        * @param className
+        *            Class to resolve
+        * @return Resolved class
+        */
+       @SuppressWarnings("unchecked")
+       public static <T> Class<T> resolveClass(final String className)
+       {
+               if (className == null)
+               {
+                       return null;
+               }
+               try
+               {
+                       // TODO: Ask Application
+//                     if (Application.exists())
+//                     {
+//                             return (Class<T>)Application.get()
+//                                     .getApplicationSettings()
+//                                     .getClassResolver()
+//                                     .resolveClass(className);
+//                     }
+                       return (Class<T>)Class.forName(className);
+               }
+               catch (ClassNotFoundException e)
+               {
+                       log.warn("Could not resolve class: " + className);
+                       return null;
+               }
+       }
+
+       private static final Logger log = 
LoggerFactory.getLogger(Classes.class);
+
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Classes.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Generics.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Generics.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Generics.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Generics.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.lang;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.wicket.model.IModel;
+
+/**
+ * Generics related utilities
+ * 
+ * @author igor.vaynberg
+ */
+public class Generics
+{
+       private Generics()
+       {
+
+       }
+
+       /**
+        * Silences generics warning when need to cast iterator types
+        * 
+        * @param <T>
+        * @param delegate
+        * @return <code>delegate</code> iterator cast to proper generics type
+        */
+       @SuppressWarnings("unchecked")
+       public static <T> Iterator<T> iterator(Iterator<?> delegate)
+       {
+               return (Iterator<T>)delegate;
+       }
+
+       /**
+        * Supresses generics warning when converting model types
+        * 
+        * @param <T>
+        * @param model
+        * @return <code>model</code>
+        */
+       @SuppressWarnings("unchecked")
+       public static <T> IModel<T> model(IModel<?> model)
+       {
+               return (IModel<T>)model;
+       }
+
+       /**
+        * Creates a new HashMap
+        * 
+        * @param <K>
+        * @param <V>
+        * @return new hash map
+        */
+       public static <K, V> HashMap<K, V> newHashMap()
+       {
+               return new HashMap<K, V>();
+       }
+
+       /**
+        * Creates a new HashMap
+        * 
+        * @param <K>
+        * @param <V>
+        * @param capacity
+        *            initial capacity
+        * @return new hash map
+        */
+       public static <K, V> HashMap<K, V> newHashMap(int capacity)
+       {
+               return new HashMap<K, V>(capacity);
+       }
+
+       /**
+        * Creates a new ArrayList
+        * 
+        * @param <T>
+        * @param capacity
+        *            initial capacity
+        * @return array list
+        */
+       public static <T> ArrayList<T> newArrayList(int capacity)
+       {
+               return new ArrayList<T>(capacity);
+       }
+
+       /**
+        * Creates a new ArrayList
+        * 
+        * @param <T>
+        * @return array list
+        */
+       public static <T> ArrayList<T> newArrayList()
+       {
+               return new ArrayList<T>();
+       }
+
+       /**
+        * Creates a new ConcurrentHashMap
+        * 
+        * @param <K>
+        * @param <V>
+        * @return new hash map
+        */
+       public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap()
+       {
+               return new ConcurrentHashMap<K, V>();
+       }
+
+       /**
+        * Creates a new ConcurrentHashMap
+        * 
+        * @param <K>
+        * @param <V>
+        * @param initialCapacity
+        *            initial capacity
+        * @return new hash map
+        */
+       public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap(int 
initialCapacity)
+       {
+               return new ConcurrentHashMap<K, V>(initialCapacity);
+       }
+
+
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Generics.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Objects.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Objects.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Objects.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Objects.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,49 @@
+package org.apache.wicket.util.lang;
+
+public class Objects {
+
+       /**
+        * Returns true if a and b are equal. Either object may be null.
+        * 
+        * @param a
+        *            Object a
+        * @param b
+        *            Object b
+        * @return True if the objects are equal
+        */
+       public static boolean equal(final Object a, final Object b)
+       {
+               if (a == b)
+               {
+                       return true;
+               }
+
+               if ((a != null) && (b != null) && a.equals(b))
+               {
+                       return true;
+               }
+
+               return false;
+       }
+
+       /**
+        * returns hashcode of the objects by calling obj.hashcode(). safe to 
use when obj is null.
+        * 
+        * @param obj
+        * @return hashcode of the object or 0 if obj is null
+        */
+       public static int hashCode(final Object... obj)
+       {
+               if (obj == null || obj.length == 0)
+               {
+                       return 0;
+               }
+               int result = 37;
+               for (int i = obj.length - 1; i > -1; i--)
+               {
+                       result = 37 * result + (obj[i] != null ? 
obj[i].hashCode() : 0);
+               }
+               return result;
+       }
+
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/lang/Objects.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/resource/ResourceStreamNotFoundException.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/resource/ResourceStreamNotFoundException.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/resource/ResourceStreamNotFoundException.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/resource/ResourceStreamNotFoundException.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.resource;
+
+/**
+ * Thrown if a required resource cannot be found.
+ * 
+ * @author Jonathan Locke
+ */
+public final class ResourceStreamNotFoundException extends Exception
+{
+       private static final long serialVersionUID = 1L;
+
+       /**
+        * Constructor
+        */
+       public ResourceStreamNotFoundException()
+       {
+               super();
+       }
+
+       /**
+        * Constructor
+        * 
+        * @param message
+        *            Description of the problem
+        */
+       public ResourceStreamNotFoundException(final String message)
+       {
+               super(message);
+       }
+
+       /**
+        * Constructor
+        * 
+        * @param cause
+        *            Nested stack trace
+        */
+       public ResourceStreamNotFoundException(final Throwable cause)
+       {
+               super(cause);
+       }
+
+       /**
+        * Constructor
+        * 
+        * @param message
+        *            Description of the problem
+        * @param cause
+        *            Nested stack trace
+        */
+       public ResourceStreamNotFoundException(final String message, final 
Throwable cause)
+       {
+               super(message, cause);
+       }
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/resource/ResourceStreamNotFoundException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/string/AbstractStringList.java
URL: 
http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/string/AbstractStringList.java?rev=759514&view=auto
==============================================================================
--- 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/string/AbstractStringList.java
 (added)
+++ 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/string/AbstractStringList.java
 Sat Mar 28 17:30:04 2009
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.string;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An abstract base class for string list implementations. Besides having an 
implementation for
+ * IStringSequence (iterator(), get(int index) and size()), an 
AbstractStringList can be converted
+ * to a String array or a List of Strings.
+ * <p>
+ * The total length of all Strings in the list can be determined by calling 
totalLength().
+ * <p>
+ * Strings or a subset of Strings in the list can be formatted using three 
join() methods:
+ * <p>
+ * <ul>
+ * <li>join(String) Joins strings together using a given separator
+ * <li>join() Joins Strings using comma as a separator
+ * <li>join(int first, int last, String) Joins a sublist of strings using a 
given separator
+ * </ul>
+ * 
+ * @author Jonathan Locke
+ */
+public abstract class AbstractStringList implements IStringSequence, 
Serializable
+{
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+
+       /**
+        * @return String iterator
+        * @see org.apache.wicket.util.string.IStringSequence#iterator()
+        */
+       public abstract IStringIterator iterator();
+
+       /**
+        * @return Number of strings in this string list
+        * @see org.apache.wicket.util.string.IStringSequence#size()
+        */
+       public abstract int size();
+
+       /**
+        * @param index
+        *            The index into this string list
+        * @return The string at the given index
+        * @see org.apache.wicket.util.string.IStringSequence#get(int)
+        */
+       public abstract String get(int index);
+
+       /**
+        * Returns this String sequence as an array of Strings. Subclasses may 
provide a more efficient
+        * implementation than the one provided here.
+        * 
+        * @return An array containing exactly this sequence of Strings
+        */
+       public String[] toArray()
+       {
+               // Get number of Strings
+               final int size = size();
+
+               // Allocate array
+               final String[] strings = new String[size];
+
+               // Copy string references
+               for (int i = 0; i < size; i++)
+               {
+                       strings[i] = get(i);
+               }
+
+               return strings;
+       }
+
+       /**
+        * Returns this String sequence as an array of Strings. Subclasses may 
provide a more efficient
+        * implementation than the one provided here.
+        * 
+        * @return An array containing exactly this sequence of Strings
+        */
+       public final List<String> toList()
+       {
+               // Get number of Strings
+               final int size = size();
+
+               // Allocate list of exactly the right size
+               final List<String> strings = new ArrayList<String>(size);
+
+               // Add strings to list
+               for (int i = 0; i < size; i++)
+               {
+                       strings.add(get(i));
+               }
+
+               return strings;
+       }
+
+       /**
+        * @return The total length of all Strings in this sequence.
+        */
+       public int totalLength()
+       {
+               // Get number of Strings
+               final int size = size();
+
+               // Add strings to list
+               int totalLength = 0;
+
+               for (int i = 0; i < size; i++)
+               {
+                       totalLength += get(i).length();
+               }
+
+               return totalLength;
+       }
+
+       /**
+        * Joins this sequence of strings using a comma separator. For example, 
if this sequence
+        * contains [1 2 3], the result of calling this method will be "1, 2, 
3".
+        * 
+        * @return The joined String
+        */
+       public final String join()
+       {
+               return join(", ");
+       }
+
+       /**
+        * Joins this sequence of strings using a separator
+        * 
+        * @param separator
+        *            The separator to use
+        * @return The joined String
+        */
+       public final String join(final String separator)
+       {
+               return join(0, size(), separator);
+       }
+
+       /**
+        * Joins this sequence of strings from first index to last using a 
separator
+        * 
+        * @param first
+        *            The first index to use, inclusive
+        * @param last
+        *            The last index to use, exclusive
+        * @param separator
+        *            The separator to use
+        * @return The joined String
+        */
+       public final String join(final int first, final int last, final String 
separator)
+       {
+               // Allocate buffer of exactly the right length
+               final int length = totalLength() + (separator.length() * 
(Math.max(0, last - first - 1)));
+               final AppendingStringBuffer buf = new 
AppendingStringBuffer(length);
+
+               // Loop through indexes requested
+               for (int i = first; i < last; i++)
+               {
+                       // Add next string
+                       buf.append(get(i));
+
+                       // Add separator?
+                       if (i != (last - 1))
+                       {
+                               buf.append(separator);
+                       }
+               }
+
+               return buf.toString();
+       }
+
+       /**
+        * Converts this object to a string representation
+        * 
+        * @return String version of this object
+        */
+       @Override
+       public String toString()
+       {
+               return "[" + join() + "]";
+       }
+}

Propchange: 
wicket/sandbox/knopp/experimental/wicket-ng/src/main/java/org/apache/wicket/util/string/AbstractStringList.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to