diff --git a/docs/config_naming.html b/docs/config_naming.html index e4de6c7b0..b6a263bfe 100644 --- a/docs/config_naming.html +++ b/docs/config_naming.html @@ -1,151 +1,139 @@ - - + + + Checks for Naming Conventions - + -

Checks for Naming Conventions

+ + + + + + +

Checks for Naming Conventions

Checkstyle Logo
+ +

Overview

+

+ Each of these naming modules validates identifiers for particular code elements. Valid + identifiers for a naming module are specified by its + format property. The value of format is a regular + expression for valid identifiers. + This is an example of a configuration of the MemberName module to + ensure that member identifiers begin with 'm', + followed by an upper case letter, and then letters and digits: +

+
+        <module name="MemberName">
+            <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
+        </module>
+      
+

+ All naming modules belong to package + com.puppycrawl.tools.checkstyle.checks and are submodules of + TreeWalker. +

+

Modules

-

Checkstyle supports checking that names in a Java code confirms to -specified naming conventions which are specifed as regular expressions. The -excellent Jakarta Regexp -library is used by Checkstyle.

- -

Format of members

- -

The property checkstyle.pattern.member specifies -the format for members (non static). -The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- -

An example is:

- -
-    private int mySize = 0;
-
- -

The property checkstyle.pattern.publicmember -specifies the format for public members (non -static public). The property type is -regular expression and defaults to -^f[A-Z][a-zA-Z0-9]*$.

- -
-

Tip

- -

This is useful for the fields required for Container Managed Persistence -(CMP) Enterprise JavaBeans 1.1. An example is:

- -
-    public int fCMPField;
-
-
- - -

Format of constants

- -

The property checkstyle.pattern.const specifies -the format for constants (static and -final). The property type is -regular expression and defaults to -^[A-Z](_?[A-Z0-9]+)*$.

- -

The exception to the rule is serialVersionUID. An -example is:

- -
-    public static final int MAX_ROWS = 2;
-
- - -

Format of statics

- -

The property checkstyle.pattern.static specifies -the format for static variables (static only). -The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- -

An example is:

- -
-    private static int numCreated = 0;
-
- - - -

Format of parameter names

- -

The property checkstyle.pattern.parameter -specifies the format for parameter names. The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- - -

Format of package names

- -

The property checkstyle.pattern.package specifies -the format for class and interface names. The property type is -regular expression and defaults to -^[a-z]+(\.[a-zA-Z_][a-zA-Z_0-9]*)*$.

- -
-

Tip

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
modulevalidates identifiers fordefault value of format
ConstantNameconstants (static, + final fields)^[A-Z](_?[A-Z0-9]+)*$
LocalFinalVariableNamelocal, final variables^[a-z][a-zA-Z0-9]*$
LocalVariableNamelocal, non-final variables^[a-z][a-zA-Z0-9]*$
MemberNamenon-public, non-static fields^[a-z][a-zA-Z0-9]*$
MethodNamemethods^[a-z][a-zA-Z0-9]*$
PackageNamepackages^[a-z]+(\\.[a-zA-Z_][a-zA-Z_0-9]*)*$
ParameterNameparameters^[a-z][a-zA-Z0-9]*$
PublicMemberNamepublic, non-static fields^f[A-Z][a-zA-Z0-9]*$
StaticVariableNamestatic, non-final fields^[a-z][a-zA-Z0-9]*$
TypeNameclasses and interfaces^[A-Z][a-zA-Z0-9]*$
+

Notes

+ +

-The default value of checkstyle.pattern.package -has been chosen to match the requirements in the - -Java Language specification and the Sun coding conventions. -However both underscores and uppercase letters are rather uncommon, so most projects -should probably use -checkstyle.pattern.package=^[a-z]+(\.[a-z][a-z0-9]*)*$ +Copyright © 2002 Oliver Burn. All rights Reserved.

-
- - -

Format of type names

- -

The property checkstyle.pattern.type specifies -the format for class and interface names. The property type is -regular expression and defaults to -^[A-Z][a-zA-Z0-9]*$.

- - -

Format of method names

- -

The property checkstyle.pattern.method specifies -the format for method names. The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- - -

Format of local variable names

- -

The property checkstyle.pattern.localvar -specifies the format for local variables. The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- -
-    int localInt = 3;
-
- - -

The property checkstyle.pattern.localfinalvar -specifies the format for final local variables. The property type is -regular expression and defaults to -^[a-z][a-zA-Z0-9]*$.

- -
-    final int finalLocalInt = 3;
-
- -
-

Copyright © 2002 Oliver Burn. All rights Reserved.

\ No newline at end of file