<?xml version="1.0" encoding="Shift_JIS"?>
<!--
  Copyright 2003-2004 The Apache Software Foundation.

  Licensed 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.

  $Id: MathTool.xml,v 1.6 2005/03/16 10:50:15 nekop Exp $
-->
<document>

    <properties>
        <title>MathTool</title>
        <author email="sidler@apache.org">Gabriel Sidler</author>
        <translator email="nekop@programmers.jp">木村 貴由</translator>
        <translator email="tatakaha@jajakarta.org">高橋 達男</translator>
        <projectfile>xdocs-ja/generic/menu.xml</projectfile>
        <original>MathTool</original>
    </properties>

    <body>

    <section name="MathTool Reference Documentation" alias="MathTool リファレンスドキュメント">

        <primary>
        <p>Tool for performing floating point math in Velocity.</p>
        </primary>
        <p>Velocity で浮動少数点数演算を行うツールです。</p>

        <primary>
        <p>A few things to note:</p>
        </primary>
        <p>いくつかの注意点:</p>
        
        <primary>
        <ul>
            <li>Most methods return numbers wrapped as Double
                which automatically render the decimal places even
                for whole numbers (e.g. new Double(1).toString() -> '1.0'). 
                This is intentional. This tool is for floating 
                point arithmetic. Integer arithmetic is already supported
                by the Velocity template language. If you really need '1' 
                instead of '1.0', just call intValue() on the result.</li> 
            <li>No null pointer, number format, or divide by zero
                exceptions are thrown here. This is because such exceptions
                halt template rendering. It should be sufficient debugging 
                feedback that Velocity will render the reference
                literally. (e.g. $math.div(1, 0) renders as '$math.div(1, 0)')</li>
            <li>Class <code>java.lang.Math</code> is used to perform the
                mathematical operations.</li>
        </ul>    
        </primary>
        <ul>
            <li>ほとんどのメソッドは Double でラップされた数値を返却し、自動的に小数点まで表示されます (例: new Double(1).toString() -> '1.0')。
                これは故意にそうしています。
                このツールは浮動少数点数演算を目的としているからです。
                整数の演算は既に Velocity テンプレート言語でサポートされています。
                '1.0' ではなく '1' が必要なら、結果に対して intValue() を呼び出してください。</li> 
            <li>NullPointer, NumberFormat, DivideByZero 例外は送出されません。
                これらの例外はテンプレートのレンダリングを停止させてしまうからです。
                デバッグのためのフィードバックとして、Velocity はこれを文字通りそのまま表示します。 (例: $math.div(1, 0) は '$math.div(1, 0)' として表示されます)</li>
            <li>数値演算の処理には <code>java.lang.Math</code> クラスが使用されます。</li>
        </ul>    
        
        <toolinfo>
            <version>@@@version@@@, @@@date@@@</version>
            <clazz>org.apache.velocity.tools.generic.MathTool</clazz>
            <name>$math</name>
            <author email="nathan@esha.com">Nathan Bubna</author>
            <config-example>&lt;tool&gt;
  &lt;key&gt;math&lt;/key&gt;
  &lt;scope&gt;application&lt;/scope&gt;
  &lt;class&gt;org.apache.velocity.tools.generic.MathTool&lt;/class&gt;
&lt;/tool&gt;</config-example>
        </toolinfo>

        <methods/>

    </section>

    <section name="add()">
        <primary>
        <method name="add()">
    
            <abstract>
                Addition
            </abstract>
                
            <signature>
                Double add(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Operands of the addition. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the sum or <code>null</code> if the input
                paramters are not valid.
            </returns>
    
        </method>
        </primary>
        <method name="add()">
    
            <abstract>
                加算
            </abstract>
                
            <signature>
                Double add(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    加算する値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                合計を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
        </method>
    </section>


    <section name="sub()">
        <primary>
        <method name="sub()">
    
            <abstract>
                Subtraction
            </abstract>
                
            <signature>
                Double sub(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Operands of the subtraction. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the result of the subtraction
                or <code>null</code> if the input paramters are not valid.
            </returns>
    
        </method>
        </primary>
        <method name="sub()">
    
            <abstract>
                減算
            </abstract>
                
            <signature>
                Double sub(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    減算する値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                減算の結果を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
        </method>
    </section>


    <section name="mul()">
        <primary>
        <method name="mul()">
    
            <abstract>
                Multiplication
            </abstract>
                
            <signature>
                Double mul(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Factors of the multiplication. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the result of the multiplication
                or <code>null</code> if the input paramters are not valid.
            </returns>
    
        </method>
        </primary>
        <method name="mul()">
    
            <abstract>
                乗算
            </abstract>
                
            <signature>
                Double mul(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    乗算する値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                乗算の結果を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
        </method>
    </section>


    <section name="div()">
        <primary>
        <method name="div()">
    
            <abstract>
                Division
            </abstract>
                
            <signature>
                Double div(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Input for the division. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the result of the division
                or <code>null</code> if the input paramters are not valid.
            </returns>
    
        </method>
        </primary>
        <method name="div()">
    
            <abstract>
                除算
            </abstract>
                
            <signature>
                Double div(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    除算の入力値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                除算の結果を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
        </method>
    </section>


    <section name="pow()">
        <primary>
        <method name="pow()">
    
            <abstract>
                Power of
            </abstract>
    
            <signature>
                Double pow(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Operands. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the first number raised to 
                the power of the second or <code>null</code> if the input paramters are not valid.
            </returns>
    
       </method>
        </primary>
        <method name="pow()">
    
            <abstract>
                累乗
            </abstract>
    
            <signature>
                Double pow(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                一番目の数値を二番目の数値で累乗した結果を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>



    <section name="max()">
        <primary>
        <method name="max()">
    
            <abstract>
                Maximum of two numbers
            </abstract>
    
            <signature>
                Double max(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Operands. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the maximum of the two
                numbers or <code>null</code> if the input paramters are not valid.
            </returns>
    
       </method>
        </primary>
        <method name="max()">
    
            <abstract>
                二つの数値の最大値
            </abstract>
    
            <signature>
                Double max(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                2つの数値の大きい方を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>



    <section name="min()">
        <primary>
        <method name="min()">
    
            <abstract>
                Minimum of two numbers
            </abstract>
    
            <signature>
                Double min(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    Operands. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the minimum of the two
                numbers or <code>null</code> if the input paramters are not valid.
            </returns>
    
       </method>
        </primary>
        <method name="min()">
    
            <abstract>
                二つの数値の最小値
            </abstract>
    
            <signature>
                Double min(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                2つの数値の小さい方を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>




    <section name="abs()">
        <primary>
        <method name="abs()">
    
            <abstract>
                Absolute value of a number
            </abstract>
    
            <signature>
                Double abs(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    Operand. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the absolute value of the
                input or <code>null</code> if the input paramter is not valid.
            </returns>
    
       </method>
        </primary>
        <method name="abs()">
    
            <abstract>
                絶対値
            </abstract>
    
            <signature>
                Double abs(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                絶対値を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>




    <section name="toDouble()">
        <primary>
        <method name="toDouble()">
    
            <abstract>
                Converts a number into a double.
            </abstract>
    
            <signature>
                Double toDouble(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    Operand. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the input number or 
                <code>null</code> if the input paramter is not valid.
            </returns>
    
       </method>
        </primary>
        <method name="toDouble()">
    
            <abstract>
                数値を Double へ変換
            </abstract>
    
            <signature>
                Double toDouble(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                入力値を表す <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>



    <section name="toInteger()">
        <primary>
        <method name="toInteger()">
    
            <abstract>
                Converts a number into an integer
            </abstract>
    
            <signature>
                Integer toInteger(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    Operand. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Integer</code> representing the input number or 
                <code>null</code> if the input paramter is not valid.
            </returns>
    
       </method>
        </primary>
        <method name="toInteger()">
    
            <abstract>
                数値を Integer へ変換
            </abstract>
    
            <signature>
                Integer toInteger(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    演算値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                入力値を表す <code>java.lang.Integer</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
    
       </method>
    </section>



    <section name="roundTo()">
        <primary>
        <method name="roundTo()">
    
            <abstract>
                Rounds a number to the specified number of decimal places
            </abstract>
    
            <signature>
                Double roundTo(Object decimals, Object num)
            </signature>

            <parameters>
                <parameter name="decimals">
                    The number of decimal places. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
                
                <parameter name="num">
                    The number to round. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Double</code> representing the input number 
                rounded to the specified number of decimal places or 
                <code>null</code> if the input paramter is not valid.
            </returns>
               
            <description>
                <p>This method is particulary useful for simple display formatting.
                If you want to round an number to the nearest integer, it
                is better to use method <code><a href="#roundToInt()">roundToInt()</a></code>, 
                as that will return an <code>java.lang.Integer</code> rather than 
                a <code>java.lang.Double</code>.</p>
            </description>
    
        </method>
        </primary>
        <method name="roundTo()">
    
            <abstract>
                指定された小数点位置での数値の丸め処理
            </abstract>
    
            <signature>
                Double roundTo(Object decimals, Object num)
            </signature>

            <parameters>
                <parameter name="decimals">
                    小数点位置。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
                
                <parameter name="num">
                    丸める数値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                渡された数値を指定された小数点位置で丸めた <code>java.lang.Double</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
               
            <description>
                <p>このメソッドはシンプルな表示フォーマットを行うのに役立ちます。
                最も近い整数値に丸めたい場合は <code>java.lang.Double</code> ではなく <code>java.lang.Integer</code> を返却する <code><a href="#roundToInt()">roundToInt()</a></code> メソッドを使用するほうが良いでしょう。</p>
            </description>
    
        </method>
    </section>


    <section name="roundToInt()">
        <primary>
        <method name="roundToInt()">
    
            <abstract>
                Rounds a number to the nearest whole Integer
            </abstract>
    
            <signature>
                Integer roundToInt(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    The number to round. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Integer</code> representing the input number 
                rounded to nearest whole Integer or <code>null</code> if the input paramter is not valid.
            </returns>
               
        </method>
        </primary>
        <method name="roundToInt()">
    
            <abstract>
                一番近い整数値への数値の丸め処理
            </abstract>
    
            <signature>
                Integer roundToInt(Object num)
            </signature>

            <parameters>
                <parameter name="num">
                    丸める数値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                一番近い整数値へと丸めた <code>java.lang.Integer</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
               
        </method>
    </section>



    <section name="getRandom()">
        <primary>
        <method name="getRandom()">
    
            <abstract>
                Returns a pseudo-random number
            </abstract>
    
            <signature>
                Double getRandom()
            </signature>
    
            <returns>
                A <code>java.lang.Double</code> 
                greater than or equal to 0.0 and less than 1.0.
            </returns>
    
       </method>
        </primary>
        <method name="getRandom()">
    
            <abstract>
                乱数値の返却
            </abstract>
    
            <signature>
                Double getRandom()
            </signature>
    
            <returns>
                0.0 以上 1.0 未満の <code>java.lang.Double</code> 。
            </returns>
    
       </method>
    </section>



    <section name="random()">
        <primary>
        <method name="random()">
    
            <abstract>
                Returns a pseudo-random number in a configurable range
            </abstract>
    
            <signature>
                Integer random(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    First and last number of range. Valid input is any number (primitive
                    types or objects, Velocity automatically converts primitives types 
                    to objects) or a string representation of a number.
                </parameter>
            </parameters>
    
            <returns>
                A <code>java.lang.Integer</code> greater than or equal to the first
                number and less than the second number or <code>null</code> if the input paramter 
                is not valid.
            </returns>
               
        </method>
        </primary>
        <method name="random()">
    
            <abstract>
                指定された範囲の乱数の返却
            </abstract>
    
            <signature>
                Integer random(Object num1, Object num2)
            </signature>

            <parameters>
                <parameter name="num1, num2">
                    範囲の開始値と終了値。
                    有効な引数はあらゆる数値 (プリミティブ、もしくは Velocity が自動的にプリミティブに変換することのできるオブジェクト) 、または数値を表す String です。
                </parameter>
            </parameters>
    
            <returns>
                一番目の数値 以上 二番目の数値 未満の <code>java.lang.Integer</code> 。
                引数が不正の場合は <code>null</code> 。
            </returns>
               
        </method>
    </section>

 </body>
</document>

