checkstyle/docs/checks_patterns.html

101 lines
2.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Checks for Patterns</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h1>Checks for Naming Conventions</h1>
<p>Checkstyle supports checking that names in a Java code confirms to
specified naming conventions which are specifed as regular expressions. The
excellent <a href="http://jakarta.apache.org/regexp">Jakarta Regexp</a>
library is used by Checkstyle.</p>
<h2>Format of variable names</h2>
<p>The property <span class="code">checkstyle.pattern.member</span> specifies
the format for members (non <span class="code">static</span>). Defaults to
<span class="code">^[a-z][a-zA-Z0-9]*$</span>. An example is:</p>
<pre>
private int mySize = 0;
</pre>
<p>The property <span class="code">checkstyle.pattern.const</span> specifies
the format for constants (<span class="code">static</span> and <span
class="code">final</span>). Defaults to <span
class="code">^[A-Z](_?[A-Z0-9]+)*$</span>. The exception to the rule is for
<span class="code">serialVersionUID</span>. An example is:</p>
<pre>
public static final int MAX_ROWS = 2;
</pre>
<p>The property <span class="code">checkstyle.pattern.static</span> specifies
the format for static variables (<span class="code">static</span>
only). Defaults to <span class="code">^[a-z][a-zA-Z0-9]*$</span>. An example
is:</p>
<pre>
private static int numCreated = 0;
</pre>
<p>The property <span class="code">checkstyle.pattern.publicmember</span>
specifies the format for public members (non <span
class="code">static public</span>). Defaults to <span
class="code">^f[A-Z][a-zA-Z0-9]*$</span>. This is useful for the fields
required for Container Managed Persistence (CMP) Enterprise JavaBeans 1.1. An
example is:</p>
<pre>
public int fCMPField;
</pre>
<h2>Format of parameter names</h2>
<p>The property <span class="code">checkstyle.pattern.parameter</span>
specifies the format for parameter names. The default is <span
class="code">^[a-z][a-zA-Z0-9]*$</span>.</p>
<h2>Format of type names</h2>
<p>The property <span class="code">checkstyle.pattern.type</span> specifies
the format for class and interface names. The default is <span
class="code">^[A-Z][a-zA-Z0-9]*$</span>.</p>
<h2>Format of method names</h2>
<p>The property <span class="code">checkstyle.pattern.method</span> specifies
the format for method names. The default is <span
class="code">^[a-z][a-zA-Z0-9]*$</span>.</p>
<h2>Format of local variable names</h2>
<p>The property <span class="code">checkstyle.pattern.localvar</span>
specifies the format for local variables. The default is <span
class="code">^[a-z][a-zA-Z0-9]*$</span>. An example is:</p>
<pre>
int localInt = 3;
</pre>
<p>The property <span class="code">checkstyle.pattern.localfinalvar</span>
specifies the format for final local variables. The default is <span
class="code">^[a-z][a-zA-Z0-9]*$</span>. An example is:</p>
<pre>
final int finalLocalInt = 3;
</pre>
</body>
</html>