blob: 708534b4d73df2f817f5eb7753b149bc58d66155 [file] [log] [blame]
////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
////
= Apache OpenNLP Code Conventions
:jbake-type: page
:jbake-tags: building, source, code conventions
:jbake-status: published
:idprefix:
The Apache OpenNLP code should follow our code conventions. All code which
is contributed to the project should adhere to these guidelines.
* Use 2 spaces for indentation. No tabs!
* Place open braces on the same line as the declaration, for example:
[source,java]
----
public class Foo extends Bar {
public static void main(String args[]) {
try {
for (int i = 0; i < args.length; i++) {
System.out.println(Integer.parseInt(args[i]));
}
}
catch(NumberFormatException e) {
e.printStackTrace();
}
}
}
----
* Wrap lines longer than 80 to 100 characters. For wrapped lines use an indent of 4 characters.
* Within a class or interface, definitions should be ordered as follows:
* Inner classses
* Class (static) variables
* Instance variables
* Constructors
* Methods
* Do not use package imports (for example import org.apache.opennlp.*)
* For other cases, we try to follow
http://www.oracle.com/technetwork/java/codeconv-138413.html[Java code conventions] as much as possible.
# Formatter and Style files
* A code formatter file for Eclipse can be found link:code-formatter/OpenNLP-Eclipse-Formatter.xml[here] and the import order file link:code-formatter/eclipse-opennlp.importorder[here].
* A code formatter file for IntelliJ can be found link:code-formatter/OpenNLP-IntelliJ-Formatter.xml[here].