Author: ivaynberg
Date: Sun Jul 13 08:32:35 2008
New Revision: 676344

URL: http://svn.apache.org/viewvc?rev=676344&view=rev
Log:
WICKET-1731

Modified:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java?rev=676344&r1=676343&r2=676344&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
 Sun Jul 13 08:32:35 2008
@@ -66,8 +66,8 @@
         * Abstract implementation that has a helper method for creating a 
resource reference.
         */
        public static abstract class AbstractAutolinkResolverDelegate
-                       implements
-                               IAutolinkResolverDelegate
+               implements
+                       IAutolinkResolverDelegate
        {
                /**
                 * Creates a new auto component that references a package 
resource.
@@ -83,8 +83,8 @@
                 * @return a new auto component or null if the path was absolute
                 */
                protected final Component 
newPackageResourceReferenceAutoComponent(
-                               final MarkupContainer container, final String 
autoId, final PathInfo pathInfo,
-                               final String attribute)
+                       final MarkupContainer container, final String autoId, 
final PathInfo pathInfo,
+                       final String attribute)
                {
                        if (!pathInfo.absolute)
                        {
@@ -109,7 +109,7 @@
 
                                // Create the component implementing the link
                                ResourceReferenceAutolink autoLink = new 
ResourceReferenceAutolink(autoId, clazz,
-                                               pathInfo.reference, attribute);
+                                       pathInfo.reference, attribute);
                                if (autoLink.resourceReference != null)
                                {
                                        // if the resource reference is null, 
it means that it the
@@ -155,7 +155,7 @@
                 * @param anchor
                 */
                public AutolinkBookmarkablePageLink(final String id, final 
Class pageClass,
-                               final PageParameters parameters, final String 
anchor)
+                       final PageParameters parameters, final String anchor)
                {
                        super(id, pageClass, parameters);
                        this.anchor = anchor;
@@ -206,13 +206,13 @@
                 *         auto component
                 */
                Component newAutoComponent(final MarkupContainer container, 
final String autoId,
-                               final PathInfo pathInfo);
+                       final PathInfo pathInfo);
        }
 
        /**
         * Encapsulates different aspects of a path. For instance, the path
-        * <code>org.apache.wicket.markup.html.tree.Tree/tree.css</code> has 
extension
-        * <code>css</code>, is relative (absolute == true) and has no page 
parameters.
+        * <code>org.apache.wicket.markup.html.tree.Tree/tree.css</code> has 
extension <code>css</code>,
+        * is relative (absolute == true) and has no page parameters.
         */
        public static final class PathInfo
        {
@@ -380,10 +380,10 @@
                 *      java.lang.String, 
org.apache.wicket.markup.resolver.AutoLinkResolver.PathInfo)
                 */
                public Component newAutoComponent(final MarkupContainer 
container, final String autoId,
-                               PathInfo pathInfo)
+                       PathInfo pathInfo)
                {
                        if ((pathInfo.extension != null) &&
-                                       
supportedPageExtensions.contains(pathInfo.extension))
+                               
supportedPageExtensions.contains(pathInfo.extension))
                        {
                                // Obviously a href like 
href="myPkg.MyLabel.html" will do as
                                // well. Wicket will not throw an exception. It 
accepts it.
@@ -391,19 +391,20 @@
 
                                Page page = container.getPage();
                                final IClassResolver defaultClassResolver = 
page.getApplication()
-                                               
.getApplicationSettings().getClassResolver();
-                String className = Packages.absolutePath(page.getClass(), 
pathInfo.path );
-                className = Strings.replaceAll(className, "/", ".").toString();
-                if(className.startsWith("."))
-                {
-                    className = className.substring(1);
-                }
-                
+                                       .getApplicationSettings()
+                                       .getClassResolver();
+                               String className = 
Packages.absolutePath(page.getClass(), pathInfo.path);
+                               className = Strings.replaceAll(className, "/", 
".").toString();
+                               if (className.startsWith("."))
+                               {
+                                       className = className.substring(1);
+                               }
+
                                try
                                {
                                        final Class clazz = 
defaultClassResolver.resolveClass(className);
                                        return new 
AutolinkBookmarkablePageLink(autoId, clazz, pathInfo.pageParameters,
-                                                       pathInfo.anchor);
+                                               pathInfo.anchor);
                                }
                                catch (ClassNotFoundException ex)
                                {
@@ -418,7 +419,7 @@
                                        parentWithContainer = 
container.findParentWithAssociatedMarkup();
                                }
                                if ((parentWithContainer instanceof Page) && 
!pathInfo.path.startsWith("/") &&
-                                               
page.getMarkupStream().isMergedMarkup())
+                                       page.getMarkupStream().isMergedMarkup())
                                {
                                        Class clazz = 
container.getMarkupStream().getTag().getMarkupClass();
                                        if (clazz != null)
@@ -426,12 +427,17 @@
                                                // Href is relative. Resolve 
the url given relative to
                                                // the current page
                                                className = 
Packages.absolutePath(clazz, pathInfo.path);
+                                               className = 
Strings.replaceAll(className, "/", ".").toString();
+                                               if (className.startsWith("."))
+                                               {
+                                                       className = 
className.substring(1);
+                                               }
 
                                                try
                                                {
                                                        clazz = 
defaultClassResolver.resolveClass(className);
-                                                       return new 
AutolinkBookmarkablePageLink(autoId, clazz, pathInfo
-                                                                       
.getPageParameters(), pathInfo.anchor);
+                                                       return new 
AutolinkBookmarkablePageLink(autoId, clazz,
+                                                               
pathInfo.getPageParameters(), pathInfo.anchor);
                                                }
                                                catch (ClassNotFoundException 
ex)
                                                {
@@ -446,7 +452,7 @@
                                // not a registered type for bookmarkable 
pages; create a link
                                // to a resource instead
                                return 
newPackageResourceReferenceAutoComponent(container, autoId, pathInfo,
-                                               attribute);
+                                       attribute);
                        }
 
                        // fallthrough
@@ -492,8 +498,8 @@
        {
                /**
                 * Gets the reference attribute value of the tag depending on 
the type of the tag. For
-                * instance, anchors use the <code>href</code> attribute but 
script and image references
-                * use the <code>src</code> attribute.
+                * instance, anchors use the <code>href</code> attribute but 
script and image references use
+                * the <code>src</code> attribute.
                 * 
                 * @param tag
                 *            The component tag. Not for modification.
@@ -523,7 +529,7 @@
                 * @param attribute
                 */
                public ResourceReferenceAutolink(final String id, final Class 
clazz, final String href,
-                               final String attribute)
+                       final String attribute)
                {
                        super(id);
 
@@ -578,9 +584,8 @@
         * Resolves to [EMAIL PROTECTED] ResourceReference} link components. 
Typically used for header
         * contributions like javascript and css files.
         */
-       private static final class ResourceReferenceResolverDelegate
-                       extends
-                               AbstractAutolinkResolverDelegate
+       private static final class ResourceReferenceResolverDelegate extends
+               AbstractAutolinkResolverDelegate
        {
                private final String attribute;
 
@@ -599,7 +604,7 @@
                 *      java.lang.String, 
org.apache.wicket.markup.resolver.AutoLinkResolver.PathInfo)
                 */
                public Component newAutoComponent(final MarkupContainer 
container, final String autoId,
-                               final PathInfo pathInfo)
+                       final PathInfo pathInfo)
                {
                        return 
newPackageResourceReferenceAutoComponent(container, autoId, pathInfo, 
attribute);
                }
@@ -626,8 +631,8 @@
 
                /**
                 * Gets the reference attribute value of the tag depending on 
the type of the tag. For
-                * instance, anchors use the <code>href</code> attribute but 
script and image references
-                * use the <code>src</code> attribute.
+                * instance, anchors use the <code>href</code> attribute but 
script and image references use
+                * the <code>src</code> attribute.
                 * 
                 * @param tag
                 *            The component tag. Not for modification.
@@ -643,7 +648,7 @@
         * If no specific resolver is found, always use the href attribute for 
references.
         */
        private static final TagReferenceResolver DEFAULT_ATTRIBUTE_RESOLVER = 
new TagReferenceResolver(
-                       "href");
+               "href");
 
        /** Logging */
        private static final Logger log = 
LoggerFactory.getLogger(AutoLinkResolver.class);
@@ -678,9 +683,9 @@
                // register autolink resolver delegates
                tagNameToAutolinkResolverDelegates.put("a", new 
AnchorResolverDelegate());
                tagNameToAutolinkResolverDelegates.put("link",
-                               new ResourceReferenceResolverDelegate("href"));
+                       new ResourceReferenceResolverDelegate("href"));
                tagNameToAutolinkResolverDelegates.put("script", new 
ResourceReferenceResolverDelegate(
-                               "src"));
+                       "src"));
                tagNameToAutolinkResolverDelegates.put("img", new 
ResourceReferenceResolverDelegate("src"));
        }
 
@@ -696,7 +701,7 @@
         *            Implements what to do based on the tag and the attribute
         */
        public final void addTagReferenceResolver(final String tagName, final 
String attributeName,
-                       final IAutolinkResolverDelegate resolver)
+               final IAutolinkResolverDelegate resolver)
        {
                TagReferenceResolver tagReferenceResolver = new 
TagReferenceResolver(attributeName);
                tagNameToTagReferenceResolvers.put(tagName, 
tagReferenceResolver);
@@ -731,7 +736,7 @@
         * @return true, if componentId was handle by the resolver. False, 
otherwise
         */
        public final boolean resolve(final MarkupContainer container, final 
MarkupStream markupStream,
-                       final ComponentTag tag)
+               final ComponentTag tag)
        {
                // Must be marked as autolink tag
                if (tag.isAutolinkEnabled())
@@ -740,7 +745,7 @@
                        // Note: to not use tag.getId() because it will be 
modified while
                        // resolving the link and hence the 2nd render will 
fail.
                        final Component link = resolveAutomaticLink(container,
-                                       WicketLinkTagHandler.AUTOLINK_ID, tag);
+                               WicketLinkTagHandler.AUTOLINK_ID, tag);
 
                        // Add the link to the container
                        container.autoAdd(link, markupStream);
@@ -773,7 +778,7 @@
         * @return A BookmarkablePageLink to handle the href
         */
        private final Component resolveAutomaticLink(final MarkupContainer 
container, final String id,
-                       final ComponentTag tag)
+               final ComponentTag tag)
        {
                final Page page = container.getPage();
 
@@ -792,8 +797,7 @@
                }
 
                // get the reference resolver
-               ITagReferenceResolver referenceResolver = 
(ITagReferenceResolver)tagNameToTagReferenceResolvers
-                               .get(tagName);
+               ITagReferenceResolver referenceResolver = 
(ITagReferenceResolver)tagNameToTagReferenceResolvers.get(tagName);
                if (referenceResolver == null)
                {
                        // fallback on default
@@ -807,8 +811,7 @@
                // create the path info object
                PathInfo pathInfo = new PathInfo(reference);
                // now get the resolver delegate
-               IAutolinkResolverDelegate autolinkResolverDelegate = 
(IAutolinkResolverDelegate)tagNameToAutolinkResolverDelegates
-                               .get(tagName);
+               IAutolinkResolverDelegate autolinkResolverDelegate = 
(IAutolinkResolverDelegate)tagNameToAutolinkResolverDelegates.get(tagName);
                Component autoComponent = null;
                if (autolinkResolverDelegate != null)
                {


Reply via email to