apply suggested intellij format
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
index 5c06d50..88bcbf1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
@@ -135,7 +135,7 @@
log.debug("actionName="+actionName);
final Object params = req.getParameter("params");
log.debug("params="+params);
- List<String> paramValues = new ArrayList<String>();
+ List<String> paramValues = new ArrayList<>();
if (params instanceof String) {
final String paramString = (String)params;
if (StringUtils.isNotBlank(paramString)) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
index fb63e93..0a5d0ab 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
@@ -32,7 +32,7 @@
public class AclImpl implements Acl, Serializable
{
private static final long serialVersionUID = 1L;
- private final Vector<AclEntry> m_entries = new Vector<AclEntry>();
+ private final Vector<AclEntry> m_entries = new Vector<>();
/**
* Constructs a new AclImpl instance.
@@ -42,53 +42,44 @@
}
/**
- * Returns all Principal objects assigned a given Permission in the access
- * control list. The Principals returned are those that have been granted
- * either the supplied permission, or a permission implied by the supplied
- * permission. Principals are not "expanded" if they are a role or group.
+ * Returns all Principal objects assigned a given Permission in the access control list. The Principals returned are those that have
+ * been granted either the supplied permission, or a permission implied by the supplied permission. Principals are not "expanded" if
+ * they are a role or group.
+ *
* @param permission the permission to search for
* @return an array of Principals possessing the permission
*/
- public Principal[] findPrincipals( Permission permission )
- {
- Vector<Principal> principals = new Vector<Principal>();
- Enumeration<AclEntry> entries = entries();
+ public Principal[] findPrincipals( final Permission permission ) {
+ final Vector< Principal > principals = new Vector<>();
+ final Enumeration< AclEntry > entries = entries();
- while (entries.hasMoreElements())
- {
- AclEntry entry = entries.nextElement();
- Enumeration<Permission> permissions = entry.permissions();
- while ( permissions.hasMoreElements() )
- {
- Permission perm = permissions.nextElement();
- if ( perm.implies( permission ) )
- {
+ while( entries.hasMoreElements() ) {
+ final AclEntry entry = entries.nextElement();
+ final Enumeration< Permission > permissions = entry.permissions();
+ while( permissions.hasMoreElements() ) {
+ final Permission perm = permissions.nextElement();
+ if ( perm.implies( permission ) ) {
principals.add( entry.getPrincipal() );
}
}
}
- return principals.toArray( new Principal[principals.size()] );
+ return principals.toArray( new Principal[ principals.size() ] );
}
- private boolean hasEntry( AclEntry entry )
- {
- if( entry == null )
- {
+ private boolean hasEntry( final AclEntry entry ) {
+ if( entry == null ) {
return false;
}
- for( AclEntry e : m_entries )
- {
- Principal ep = e.getPrincipal();
- Principal entryp = entry.getPrincipal();
+ for( final AclEntry e : m_entries ) {
+ final Principal ep = e.getPrincipal();
+ final Principal entryp = entry.getPrincipal();
- if( ep == null || entryp == null )
- {
+ if( ep == null || entryp == null ) {
throw new IllegalArgumentException( "Entry is null; check code, please (entry="+entry+"; e="+e+")" );
}
- if( ep.getName().equals( entryp.getName() ) )
- {
+ if( ep.getName().equals( entryp.getName() ) ) {
return true;
}
}
@@ -97,24 +88,20 @@
}
/**
- * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an
- * individual or a group) with a set of permissions. Each principal can have
- * at most one positive ACL entry, specifying permissions to be granted to
- * the principal. If there is already an ACL entry already in the ACL, false
- * is returned.
+ * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group) with a set of permissions. Each
+ * principal can have at most one positive ACL entry, specifying permissions to be granted to the principal. If there is already an
+ * ACL entry already in the ACL, false is returned.
+ *
* @param entry - the ACL entry to be added to this ACL
- * @return true on success, false if an entry of the same type (positive or
- * negative) for the same principal is already present in this ACL
+ * @return true on success, false if an entry of the same type (positive or negative) for the same principal is already present in
+ * this ACL
*/
- public synchronized boolean addEntry( AclEntry entry )
- {
- if( entry.getPrincipal() == null )
- {
+ public synchronized boolean addEntry( final AclEntry entry ) {
+ if( entry.getPrincipal() == null ) {
throw new IllegalArgumentException( "Entry principal cannot be null" );
}
- if( hasEntry( entry ) )
- {
+ if( hasEntry( entry ) ) {
return false;
}
@@ -128,7 +115,7 @@
* @param entry the ACL entry to be removed from this ACL
* @return true on success, false if the entry is not part of this ACL
*/
- public synchronized boolean removeEntry( AclEntry entry )
+ public synchronized boolean removeEntry( final AclEntry entry )
{
return m_entries.remove( entry );
}
@@ -144,17 +131,14 @@
}
/**
- * Returns an AclEntry for a supplied Principal, or <code>null</code> if
- * the Principal does not have a matching AclEntry.
+ * Returns an AclEntry for a supplied Principal, or <code>null</code> if the Principal does not have a matching AclEntry.
+ *
* @param principal the principal to search for
* @return the AclEntry associated with the principal, or <code>null</code>
*/
- public AclEntry getEntry( Principal principal )
- {
- for( AclEntry entry : m_entries )
- {
- if( entry.getPrincipal().getName().equals( principal.getName() ) )
- {
+ public AclEntry getEntry( final Principal principal ) {
+ for( final AclEntry entry : m_entries ) {
+ if( entry.getPrincipal().getName().equals( principal.getName() ) ) {
return entry;
}
}
@@ -164,25 +148,21 @@
/**
* Returns a string representation of the contents of this Acl.
+ *
* @return the string representation
*/
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- for( AclEntry entry : m_entries )
- {
- Principal pal = entry.getPrincipal();
-
- if( pal != null )
- sb.append( " user = "+pal.getName()+": " );
- else
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ for( final AclEntry entry : m_entries ) {
+ final Principal pal = entry.getPrincipal();
+ if( pal != null ) {
+ sb.append( " user = " ).append( pal.getName() ).append( ": " );
+ } else {
sb.append( " user = null: " );
-
+ }
sb.append( "(" );
- for( Enumeration<Permission> perms = entry.permissions(); perms.hasMoreElements(); )
- {
- Permission perm = perms.nextElement();
+ for( final Enumeration< Permission > perms = entry.permissions(); perms.hasMoreElements(); ) {
+ final Permission perm = perms.nextElement();
sb.append( perm.toString() );
}
sb.append( ")\n" );
@@ -193,11 +173,11 @@
/**
* Returns <code>true</code>, if this Acl is empty.
+ *
* @return the result
* @since 2.4.68
*/
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return m_entries.isEmpty();
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
index 0e67464..58fd889 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
@@ -18,16 +18,16 @@
*/
package org.apache.wiki.parser;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
import org.apache.log4j.Logger;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.wiki.WikiContext;
import org.apache.wiki.api.exceptions.ProviderException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
/**
* Link parsing operations.
@@ -111,7 +111,7 @@
* @param link The link text
* @return {@code true}, if this represents a variable link.
*/
- public boolean isVariableLink( String link ) {
+ public boolean isVariableLink( final String link ) {
return link.startsWith( "{$" );
}
@@ -141,16 +141,10 @@
* @return true, if this is a link outside of this wiki.
*/
public boolean isExternalLink( final String page ) {
- int idx = Arrays.binarySearch( EXTERNAL_LINKS, page, new StartingComparator() );
+ final int idx = Arrays.binarySearch( EXTERNAL_LINKS, page, new StartingComparator() );
- //
// We need to check here once again; otherwise we might get a match for something like "h".
- //
- if( idx >= 0 && page.startsWith( EXTERNAL_LINKS[ idx ] ) ) {
- return true;
- }
-
- return false;
+ return idx >= 0 && page.startsWith( EXTERNAL_LINKS[ idx ] );
}
/**
@@ -160,10 +154,10 @@
public boolean isImageLink( String link ) {
if( wikiContext.getEngine().getRenderingManager().getParser( wikiContext, link ).isImageInlining() ) {
link = link.toLowerCase();
- List< Pattern > inlineImagePatterns = wikiContext.getEngine().getRenderingManager()
- .getParser( wikiContext, link ).getInlineImagePatterns();
+ final List< Pattern > inlineImagePatterns = wikiContext.getEngine().getRenderingManager()
+ .getParser( wikiContext, link ).getInlineImagePatterns();
- for( Pattern p : inlineImagePatterns ) {
+ for( final Pattern p : inlineImagePatterns ) {
if( new Perl5Matcher().matches( link, p ) ) {
return true;
}
@@ -185,7 +179,7 @@
}
try {
return wikiContext.getEngine().getFinalPageName( page ) != null;
- } catch( ProviderException e ) {
+ } catch( final ProviderException e ) {
log.warn( "TranslatorReader got a faulty page name [" + page + "]!", e );
return false;
}
@@ -203,23 +197,21 @@
}
try {
return wikiContext.getEngine().getFinalPageName( page );
- } catch( ProviderException e ) {
+ } catch( final ProviderException e ) {
log.warn( "TranslatorReader got a faulty page name [" + page + "]!", e );
return null;
}
}
/**
- * Compares two Strings, and if one starts with the other, then returns null. Otherwise just like the normal Comparator for strings.
- *
- * @since
+ * Compares two Strings, and if one starts with the other, then returns 0. Otherwise just like the normal Comparator for strings.
*/
private static class StartingComparator implements Comparator< String > {
/**
* {@inheritDoc}
*
- * @see Comparator#compare(String, String)
+ * @see Comparator#compare(Object, Object)
*/
@Override
public int compare( final String s1, final String s2 ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/ParseException.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/ParseException.java
index 6c37824..87f2213 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/ParseException.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/ParseException.java
@@ -21,12 +21,10 @@
import org.apache.wiki.api.exceptions.WikiException;
/**
- * This is an exception which gets thrown whenever the parser cannot
- * parse the parsing things.
- *
+ * This is an exception which gets thrown whenever the parser cannot parse the parsing things.
*/
-public class ParseException extends WikiException
-{
+public class ParseException extends WikiException {
+
private static final long serialVersionUID = 1L;
/**
@@ -34,9 +32,9 @@
*
* @param msg the message exception.
*/
- public ParseException(String msg)
+ public ParseException( final String msg )
{
- super(msg);
+ super( msg );
}
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
index d34405a..4aa40dc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
@@ -60,14 +60,6 @@
private static final Logger log = Logger.getLogger( DefaultRenderingManager.class );
- private final int m_cacheExpiryPeriod = 24*60*60; // This can be relatively long
- private final CacheManager m_cacheManager = CacheManager.getInstance();
-
- private WikiEngine m_engine;
- private boolean m_useCache = true;
- /** If true, all titles will be cleaned. */
- private boolean m_beautifyTitle = false;
-
/** The capacity of the caches, if you want something else, tweak ehcache.xml. */
private static final int DEFAULT_CACHESIZE = 1_000;
private static final String VERSION_DELIMITER = "::";
@@ -79,6 +71,15 @@
/** The name of the default WYSIWYG renderer. */
private static final String DEFAULT_WYSIWYG_RENDERER = WysiwygEditingRenderer.class.getName();
+ private WikiEngine m_engine;
+
+ private boolean m_useCache = true;
+ private final CacheManager m_cacheManager = CacheManager.getInstance();
+ private final int m_cacheExpiryPeriod = 24*60*60; // This can be relatively long
+
+ /** If true, all titles will be cleaned. */
+ private boolean m_beautifyTitle = false;
+
/** Stores the WikiDocuments that have been cached. */
private Cache m_documentCache;
@@ -99,8 +100,8 @@
}
log.info( "Using " + m_markupParserClass + " as markup parser." );
- m_useCache = "true".equals( properties.getProperty( PageManager.PROP_USECACHE ) );
m_beautifyTitle = TextUtil.getBooleanProperty( properties, PROP_BEAUTIFYTITLE, m_beautifyTitle );
+ m_useCache = "true".equals( properties.getProperty( PageManager.PROP_USECACHE ) );
if( m_useCache ) {
final String documentCacheName = engine.getApplicationName() + "." + DOCUMENTCACHE_NAME;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
index 36fef32..b46e628 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
@@ -77,7 +77,7 @@
* @return A beautified title (or, if beautification is off, returns the title without modification)
* @since 1.7.11, moved to PageManager on 2.11.0
*/
- String beautifyTitle( final String title );
+ String beautifyTitle( String title );
/**
* Beautifies the title of the page by appending non-breaking spaces in suitable places. This is really suitable only for HTML output,
@@ -87,7 +87,7 @@
* @return A beautified title.
* @since 2.1.127
*/
- String beautifyTitleNoBreak( final String title );
+ String beautifyTitleNoBreak( String title );
/**
* Returns the wiki Parser