<?xml version="1.0" encoding="Shift_JIS"?>

<document>

 <properties>
  <title>Coding Standards</title>
  <author email="jvanzyl@locus.apache.org">Velocity Documentation Team</author>
  <translator>熊坂祐二</translator>
  <translator>野瀬直樹</translator>
  <original>code-standards</original>
 </properties>

<body>

<section name="Coding Standards" alias="コーディング標準">

<primary>
<p>
This document describes a list of coding conventions that are required
for code submissions to the project. By default, the coding conventions
for most Open Source Projects should follow the existing coding conventions
in the code that you are working on. For example, if the bracket is on
the same line as the if statement, then you should write all your code
to have that convention.
</p>
</primary>
<p>
このドキュメントでは、プロジェクトに対してコードを提出するのに必要な、
コーディング規約のリストについて説明しています。
たいていのオープンソースプロジェクトのコーディング規約は、
デフォルトでは、あなたが取り組んでいるコードにある、
既存のコーディング規約に従うべきです。
例えば、if 文と同じ行に括弧がある場合には、
あなたは全てその規約にしたがってあなたのコードを書くべきです。
</p>

<primary>
<p>
<strong>If you commit code that does not follow these conventions and you
are caught, you are responsible for also fixing your own code.</strong>
</p>
</primary>
<p>
<strong>もし、これらの制約にしたがっていないコードをコミットしたら、
責任をもって自分のコードを修正しなければなりません。</strong>
</p>

<primary>
<p>
Below is a list of coding conventions that are specific to Velocity,
everything else not specificially mentioned here should follow the official
<a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun
Java Coding Conventions</a>.
</p>
</primary>
<p>
以下は、Velocity 固有のコーディング規約のリストで、その他は特に言及しないかぎり
<a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun Java コーディング規約</a>に従います。
</p>

<primary>
<p>
1. Brackets should begin and end on a new line. Examples:
</p>
</primary>
<p>
1.
括弧の開始・終了は新しい行で行います。<br/>
例:
</p>

<source test=""><![CDATA[

if ( foo )
{
    // code here
}

try
{
    // code here
}
catch (Exception bar)
{
    // code here
}
finally
{
    // code here
}

while ( true )
{
    // code here
}

]]></source>

<primary>
<p>
2. It is <strong>OK</strong> to have spaces between the parens or not. The
preference is to not include the extra spaces. For example, both of these are
ok:
</p>
</primary>
<p>
2. 括弧の間にスペースをいれるのは <strong>OK</strong> です。
ただし、スペースが入れない方が望ましいです。
例えば、これらは両方とも、OK です：
</p>

<source test=""><![CDATA[

if (foo)

or

if ( foo )

]]></source>

<primary>
<p>
3. 4 spaces. <strong>NO</strong> tabs. Period. We understand that a lot of you
like to use tabs, but the fact of the matter is that in a distributed
development enviroment, when the cvs commit messages get sent to a mailing list,
they are almost impossible to read if you use tabs.
</p>
</primary>
<p>
3. (インデントは)4つのスペースで。タブは<strong>ダメです</strong>。以上。
多くの人がタブを使いたがるのは理解していますが、実際問題として、
分散開発環境では、タブを使用していると、
cvs コミットメッセージがメーリングリストに送られた時に、
コミットメッセージがほとんど読めません。
</p>

<primary>
<p>
In Emacs-speak, this translates to the following command:

(setq-default tab-width 4 indent-tabs-mode nil)

</p>
</primary>
<p>
Emacs では、以下のコマンドで変換を行えます。
<br/>
(setq-default tab-width 4 indent-tabs-mode nil)

</p>

<primary>
<p>
4. Unix linefeeds for all .java source code files. Other platform specific
files should have the platform specific linefeeds.
</p>
</primary>
<p>
4. .java ソースコードファイルは全て、Unix 改行コードを使用します。
その他のプラットフォーム固有のファイルでは、
プラットフォーム固有の改行を使用します。
</p>

<primary>
<p>
5. Javadoc <strong>MUST</strong> exist on all your methods. Also, if you are
working on existing code and there currently isn't a javadoc for that
method/class/variable or whatever, then you should contribute and add it.
This will improve the project as a whole.
</p>
</primary>
<p>
5. すべてのメソッドにjavadocがなければ<strong>なりません</strong>。
また、既存のコードで作業をしていて、javadoc
が無いようなメソッド/クラス/変数などを見つけたら追加してください。
こうしたことで、プロジェクトが全体として改善されます。
</p>

<primary>
<p>
6. The <a href="license.html">Apache Software License</a> <strong>MUST</strong> be placed at the top
of each and every file.
</p>
</primary>
<p>
6. <a href="license.html">Apache Software License</a> は、
すべてのファイルの先頭に挿入しなければ<strong>なりません</strong>。
</p>

<primary>
<p>
7. If you contribute to a file (code or documentation), add yourself to the
top of the file. For java files the preferred Javadoc format is:
</p>
</primary>
<p>
7. ファイル(コードやドキュメント)に貢献していただいたら、
自分の名前をファイルの先頭に追加してください。
java ファイルでは、望ましいJavadoc 形式は以下の通りです。
</p>

<source><![CDATA[
@author <a href="mailto:user@domain.com">John Doe</a>
]]></source>

<primary>
<p>
Thanks for your cooperation.
</p>
</primary>
<p>
ご協力をお願いします。
</p>

</section>

<section name="More Fun For Emacs" alias="Emacsの便利ツール">

<primary>
<p>
  To make coding easier,  following bit of Emacs LISP does 
  the 'right thing' with bracing, if you want.
 </p>
</primary>
<p>
コーディングを簡単にするために、以下のちょっとした Emacs LISP で、
括弧づけについて、「正しく」行うことができます。
 </p>

<primary>
<source><![CDATA[
(defun apache-jakarta-mode ()
  "The Java mode specialization for Apache Jakarta projects."
  (if (not (assoc "apache-jakarta" c-style-alist))
      ;; Define the Apache Jakarta cc-mode style.
      (c-add-style "apache-jakarta" '("java" (indent-tabs-mode . nil))))

  (c-set-style "apache-jakarta")
  (c-set-offset 'substatement-open 0 nil)
  (setq mode-name "Apache Jakarta")

  ;; Turn on syntax highlighting when X is running.
  (if (boundp 'window-system)
      (progn (setq font-lock-support-mode 'lazy-lock-mode)
             (font-lock-mode t))))

;; Activate Jakarta mode.
(if (fboundp 'jde-mode)
    (add-hook 'jde-mode-hook 'apache-jakarta-mode)
  (add-hook 'java-mode-hook 'apache-jakarta-mode))
]]></source>
</primary>
<source><![CDATA[
(defun apache-jakarta-mode ()
  "Apache Jakartaプロジェクト向けJavaモード特殊化"
  (if (not (assoc "apache-jakarta" c-style-alist))
      ;; Apache Jakarta cc-mode スタイルを定義。
      (c-add-style "apache-jakarta" '("java" (indent-tabs-mode . nil))))

  (c-set-style "apache-jakarta")
  (c-set-offset 'substatement-open 0 nil)
  (setq mode-name "Apache Jakarta")

  ;; Xウィンドウだったら、シンタックスハイライトをONにする。
  (if (boundp 'window-system)
      (progn (setq font-lock-support-mode 'lazy-lock-mode)
             (font-lock-mode t))))

;; Jakartaモードを有効にする。
(if (fboundp 'jde-mode)
    (add-hook 'jde-mode-hook 'apache-jakarta-mode)
  (add-hook 'java-mode-hook 'apache-jakarta-mode))
]]></source>

<primary>
  <p>
  Note that  this will apply to all java in emacs. 
  To control it :

  <ul>
  <li>
      Turn off : <code>M-: (remove-hook 'java-mode 'apache-jakarta-mode)</code>
  </li>
  <li>
     Turn on : <code>M-: (add-hook 'java-mode 'apache-jakarta-mode)</code>
  </li>
  </ul>
   'M-:' is &lt;meta&gt; followed by ':', of course.  
   It will be on by default at startup.
  </p>
</primary>
  <p>
  注意: これは、emacs ですべての java に適用されます。
  制御するためには、以下のようにします。

  <ul>
  <li>
     オフ : <code>M-: (remove-hook 'java-mode 'apache-jakarta-mode)</code>
  </li>
  <li>
     オン : <code>M-: (add-hook 'java-mode 'apache-jakarta-mode)</code>
  </li>
  </ul>

もちろん 'M-:' はメタキーを押しながら':'を押すことを示します。
スタートアップ時のデフォルトは ON です。
  </p>
  
<primary>
  <p>
  This was stolen lock, stock and barrel from the contribution 
  to the Turbine project by Daniel L. Rall. Thanks Daniel!
  </p>
</primary>
  <p>
ここの内容はすべて、Daniel L.Rall が Turbine
プロジェクトに貢献してくれたものを使わせてもらいました。
ありがとうダニエル！
  </p>

</section>

</body>
</document>
