jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject [11/15] jspwiki git commit: delete JSPWikiMarkupParser#linkExists(String) and use LinkParsingOperations#linkExists(String) / LinkParsingOperations#linkIfExists(String) instead
Date Sun, 03 Dec 2017 18:57:03 GMT
delete JSPWikiMarkupParser#linkExists(String) and use LinkParsingOperations#linkExists(String)
/ LinkParsingOperations#linkIfExists(String) instead


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/cc253b3c
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/cc253b3c
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/cc253b3c

Branch: refs/heads/master
Commit: cc253b3c801f5839b929d27e902f367a362dced2
Parents: 2a87ca5
Author: juanpablo <juanpablo@apache.org>
Authored: Sun Dec 3 19:04:31 2017 +0100
Committer: juanpablo <juanpablo@apache.org>
Committed: Sun Dec 3 19:04:31 2017 +0100

----------------------------------------------------------------------
 .../apache/wiki/parser/JSPWikiMarkupParser.java | 55 ++++----------------
 .../wiki/parser/LinkParsingOperations.java      | 12 +++++
 2 files changed, 22 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/cc253b3c/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index 0f4ec48..7c7f1af 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -51,7 +51,6 @@ import org.apache.wiki.StringTransmutator;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.PluginException;
-import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.acl.Acl;
@@ -106,14 +105,11 @@ public class JSPWikiMarkupParser extends MarkupParser {
     private StringBuilder  m_genlistBulletBuffer = new StringBuilder(10);  // stores the
# and * pattern
     private boolean        m_allowPHPWikiStyleLists = true;
 
-
     private boolean        m_isOpenParagraph = false;
 
     /** Parser for extended link functionality. */
     private LinkParser     m_linkParser = new LinkParser();
 
-    private PatternMatcher m_inlineMatcher = new Perl5Matcher();
-
     /** Keeps track of any plain text that gets put in the Text nodes */
     private StringBuilder  m_plainTextBuf = new StringBuilder(20);
 
@@ -236,25 +232,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
     }
 
     /**
-     *  Returns link name, if it exists; otherwise it returns null.
-     */
-    private String linkExists( String page )
-    {
-        try
-        {
-            if( page == null || page.length() == 0 ) return null;
-
-            return m_engine.getFinalPageName( page );
-        }
-        catch( ProviderException e )
-        {
-            log.warn("TranslatorReader got a faulty page name!",e);
-
-            return page;  // FIXME: What would be the correct way to go back?
-        }
-    }
-
-    /**
      *  Calls a transmutator chain.
      *
      *  @param list Chain to call
@@ -461,7 +438,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
         return el;
     }
 
-
     /**
      *  Figures out if a link is an off-site link.  This recognizes
      *  the most common protocols by checking how it starts.
@@ -1001,16 +977,13 @@ public class JSPWikiMarkupParser extends MarkupParser {
      */
     private Element makeCamelCaseLink( String wikiname )
     {
-        String matchedLink;
+        String matchedLink = m_linkParsingOperations.linkIfExists( wikiname );
 
         callMutatorChain( m_localLinkMutatorChain, wikiname );
 
-        if( (matchedLink = linkExists( wikiname )) != null )
-        {
+        if( matchedLink != null ) {
             makeLink( READ, matchedLink, wikiname, null, null );
-        }
-        else
-        {
+        } else {
             makeLink( EDIT, wikiname, wikiname, null, null );
         }
 
@@ -1112,8 +1085,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
         {
             return makeLink( IMAGELINK, reallink, link, null, null );
         }
-        else if( ( linkExists( possiblePage ) ) != null &&
-                 hasLinkText )
+        else if( m_linkParsingOperations.linkExists( possiblePage ) && hasLinkText
)
         {
             // System.out.println("Orig="+link+", Matched: "+matchedLink);
             callMutatorChain( m_localLinkMutatorChain, possiblePage );
@@ -1393,15 +1365,12 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
                     callMutatorChain( m_localLinkMutatorChain, linkref );
 
-                    String matchedLink;
-                    if( (matchedLink = linkExists( linkref )) != null )
-                    {
+                    String matchedLink = m_linkParsingOperations.linkIfExists( linkref );
+                    if( matchedLink != null ) {
                         String sectref = "section-"+m_engine.encodeName(matchedLink+"-"+wikifyLink(namedSection));
                         sectref = sectref.replace('%', '_');
                         makeLink( READ, matchedLink, linktext, sectref, link.getAttributes()
);
-                    }
-                    else
-                    {
+                    } else {
                         makeLink( EDIT, linkref, linktext, null, link.getAttributes() );
                     }
                 }
@@ -1412,14 +1381,10 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
                     callMutatorChain( m_localLinkMutatorChain, linkref );
 
-                    String matchedLink = linkExists( linkref );
-
-                    if( matchedLink != null )
-                    {
+                    String matchedLink = m_linkParsingOperations.linkIfExists( linkref );
+                    if( matchedLink != null ) {
                         makeLink( READ, matchedLink, linktext, null, link.getAttributes()
);
-                    }
-                    else
-                    {
+                    } else {
                         makeLink( EDIT, linkref, linktext, null, link.getAttributes() );
                     }
                 }

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/cc253b3c/jspwiki-war/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java b/jspwiki-war/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
index c05c6d7..0a631a8 100755
--- a/jspwiki-war/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
@@ -165,6 +165,12 @@ public class LinkParsingOperations {
         return false;
     }
 
+    /**
+     * Returns {@code true}, if the link name exists; otherwise it returns {@code false}.
+     *
+     * @param page link name
+     * @return {@code true}, if the link name exists; otherwise it returns {@code false}.
+     */
     public boolean linkExists( final String page ) {
         if( page == null || page.length() == 0 ) {
             return false;
@@ -177,6 +183,12 @@ public class LinkParsingOperations {
         }
     }
 
+    /**
+     * Returns link name, if it exists; otherwise it returns {@code null}.
+     *
+     * @param page link name
+     * @return link name, if it exists; otherwise it returns {@code null}.
+     */
     public String linkIfExists( final String page ) {
         if( page == null || page.length() == 0 ) {
             return null;


Mime
View raw message