You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2015/09/20 19:37:51 UTC
svn commit: r1704167 -
/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
Author: hboutemy
Date: Sun Sep 20 17:37:48 2015
New Revision: 1704167
URL: http://svn.apache.org/viewvc?rev=1704167&view=rev
Log:
little refactoring
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
Modified: maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java?rev=1704167&r1=1704166&r2=1704167&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java Sun Sep 20 17:37:48 2015
@@ -171,12 +171,12 @@ public class DefaultDecorationModelInher
{
if ( banner.getHref() != null ) // it may be empty
{
- banner.setHref( rebaseLink( banner.getHref(), urlContainer ) );
+ banner.setHref( urlContainer.rebaseLink( banner.getHref() ) );
}
if ( banner.getSrc() != null )
{
- banner.setSrc( rebaseLink( banner.getSrc(), urlContainer ) );
+ banner.setSrc( urlContainer.rebaseLink( banner.getSrc() ) );
}
}
@@ -301,7 +301,7 @@ public class DefaultDecorationModelInher
private void rebaseLinkItemPaths( final LinkItem item, final URLContainer urlContainer )
{
- item.setHref( rebaseLink( item.getHref(), urlContainer ) );
+ item.setHref( urlContainer.rebaseLink( item.getHref() ) );
}
private void relativizeLogoPaths( final Logo logo, final String baseUrl )
@@ -312,7 +312,7 @@ public class DefaultDecorationModelInher
private void rebaseLogoPaths( final Logo logo, final URLContainer urlContainer )
{
- logo.setImg( rebaseLink( logo.getImg(), urlContainer ) );
+ logo.setImg( urlContainer.rebaseLink( logo.getImg() ) );
rebaseLinkItemPaths( logo, urlContainer );
}
@@ -379,20 +379,6 @@ public class DefaultDecorationModelInher
return logos;
}
- // rebase only affects relative links, a relative link wrt an old base gets translated,
- // so it points to the same location as viewed from a new base
- private String rebaseLink( final String link, final URLContainer urlContainer )
- {
- if ( link == null || urlContainer.getOldPath() == null )
- {
- return link;
- }
-
- final URIPathDescriptor oldPath = new URIPathDescriptor( urlContainer.getOldPath(), link );
-
- return oldPath.rebaseLink( urlContainer.getNewPath() ).toString();
- }
-
// relativize only affects absolute links, if the link has the same scheme, host and port
// as the base, it is made into a relative link as viewed from the base
private String relativizeLink( final String link, final String baseUri )
@@ -456,5 +442,21 @@ public class DefaultDecorationModelInher
{
return this.oldPath;
}
+
+ /**
+ * Rebase only affects relative links, a relative link wrt an old base gets translated,
+ * so it points to the same location as viewed from a new base
+ */
+ public String rebaseLink( final String link )
+ {
+ if ( link == null || getOldPath() == null )
+ {
+ return link;
+ }
+
+ final URIPathDescriptor oldPath = new URIPathDescriptor( getOldPath(), link );
+
+ return oldPath.rebaseLink( getNewPath() ).toString();
+ }
}
}