| <?xml version="1.0" encoding="ISO-8859-1"?> |
| <!-- |
| 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 |
| |
| https://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. |
| --> |
| <document> |
| |
| <properties> |
| <title>Apache UIMA Code Conventions</title> |
| <author email="dev@uima.apache.org"> |
| Apache UIMA Documentation Team</author> |
| </properties> |
| |
| <body> |
| |
| <section name="Apache UIMA Code Conventions"> |
| |
| <p> |
| To improve the readability and maintainability of the Apache UIMA™ code, |
| we have adopted the following code conventions. All UIMA developers |
| should adhere to these guidelines when committing changes or submitting patches. |
| </p> |
| <p> |
| <ul> |
| <li>Use 2 spaces for indentation. <b>No tabs!</b></li> |
| <li>Place open braces on the same line as the declaration, for example: |
| <pre> |
| 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(); |
| } |
| } |
| } |
| </pre> |
| </li> |
| <li>Wrap lines longer than 100 characters. For wrapped lines, either use |
| an indent of 8 characters or align with the expression at the same level |
| on the previous line.</li> |
| <li>Within a class or interface, definitions should be ordered as follows: |
| <ol> |
| <li>Class (static) variables</li> |
| <li>Instance variables</li> |
| <li>Constructors</li> |
| <li>Methods</li> |
| </ol> |
| </li> |
| <li>Do not use package imports (for example <code>import org.apache.uima.*</code>)</li> |
| <li>For other cases, we try to follow Sun's code conventions as much as possible: see |
| <a class="external" href="https://java.sun.com/docs/codeconv/">https://java.sun.com/docs/codeconv</a> |
| </li> |
| </ul> |
| </p> |
| </section> |
| <section name="For Eclipse Users"> |
| <p> |
| Eclipse users may download this preferences file: |
| <a class="external" href="downloads/ApacheUima_EclipseCodeStylePrefs.xml">ApacheUima_EclipseCodeStylePrefs.xml</a> |
| and import this into Eclipse. (Window->Preferences, go to Java->Code Style->Formatter and click "Import..."). |
| Once you have done this you can reformat your code by using Source->Format (Ctrl+Shift+F). |
| </p> |
| <p> |
| Also note that Eclipse will automatically format your import statements appropriately when you |
| invoke Source -> Organize Imports (Ctrl+Shift+O). |
| </p> |
| </section> |
| </body> |
| </document> |