From commits-return-12072-apmail-openejb-commits-archive=openejb.apache.org@openejb.apache.org Thu Oct 07 03:19:00 2010 Return-Path: Delivered-To: apmail-openejb-commits-archive@www.apache.org Received: (qmail 18709 invoked from network); 7 Oct 2010 03:19:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Oct 2010 03:19:00 -0000 Received: (qmail 58104 invoked by uid 500); 7 Oct 2010 03:18:59 -0000 Delivered-To: apmail-openejb-commits-archive@openejb.apache.org Received: (qmail 58079 invoked by uid 500); 7 Oct 2010 03:18:59 -0000 Mailing-List: contact commits-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openejb.apache.org Delivered-To: mailing list commits@openejb.apache.org Received: (qmail 58071 invoked by uid 99); 7 Oct 2010 03:18:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 03:18:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 03:18:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E7AA223889EA; Thu, 7 Oct 2010 03:18:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1005322 [1/5] - in /openejb/branches/openejb-3.1.x/container/openejb-core: ./ src/main/java/org/apache/openejb/assembler/classic/ src/main/java/org/apache/openejb/math/ src/main/java/org/apache/openejb/math/stat/ src/main/java/org/apache/o... Date: Thu, 07 Oct 2010 03:18:27 -0000 To: commits@openejb.apache.org From: dblevins@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101007031827.E7AA223889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dblevins Date: Thu Oct 7 03:18:24 2010 New Revision: 1005322 URL: http://svn.apache.org/viewvc?rev=1005322&view=rev Log: Trim out large commons-math library and just grab the classes we need Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/FirstMoment.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/FourthMoment.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/GeometricMean.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Kurtosis.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Mean.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/SecondMoment.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Skewness.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/ThirdMoment.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/moment/Variance.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/rank/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/rank/Max.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/rank/Min.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/rank/Percentile.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/summary/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/summary/Sum.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/summary/SumOfLogs.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/summary/SumOfSquares.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/util/ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/util/DoubleArray.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/util/MathUtils.java (with props) openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/util/ResizableDoubleArray.java (with props) Modified: openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/monitoring/StatsInterceptor.java Modified: openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml?rev=1005322&r1=1005321&r2=1005322&view=diff ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml (original) +++ openejb/branches/openejb-3.1.x/container/openejb-core/pom.xml Thu Oct 7 03:18:24 2010 @@ -262,11 +262,13 @@ commons-cli commons-cli + org.apache.activemq Modified: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1005322&r1=1005321&r2=1005322&view=diff ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Thu Oct 7 03:18:24 2010 @@ -791,7 +791,9 @@ public class Assembler extends Assembler destroyApplication(appInfo); } - private void destroyApplication(AppInfo appInfo) throws UndeployException { + public void destroyApplication(AppInfo appInfo) throws UndeployException { + deployedApplications.remove(appInfo.jarPath); + logger.info("destroyApplication.start", appInfo.jarPath); fireBeforeApplicationDestroyed(appInfo); Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,516 @@ +/* + * 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. + */ +package org.apache.openejb.math; + +import java.io.EOFException; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.text.MessageFormat; +import java.text.ParseException; +import java.util.ConcurrentModificationException; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.NoSuchElementException; +import java.util.ResourceBundle; + +/** +* Base class for commons-math unchecked exceptions. +* +* @version $Revision: 822850 $ $Date: 2009-10-07 11:56:42 -0700 (Wed, 07 Oct 2009) $ +* @since 2.0 +*/ +public class MathRuntimeException extends RuntimeException { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -5128983364075381060L; + + /** + * Pattern used to build the message. + */ + private final String pattern; + + /** + * Arguments used to build the message. + */ + private final Object[] arguments; + + /** + * Constructs a new MathRuntimeException with specified + * formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + */ + public MathRuntimeException(final String pattern, final Object ... arguments) { + this.pattern = pattern; + this.arguments = (arguments == null) ? new Object[0] : arguments.clone(); + } + + /** + * Constructs a new MathRuntimeException with specified + * nested Throwable root cause. + * + * @param rootCause the exception or error that caused this exception + * to be thrown. + */ + public MathRuntimeException(final Throwable rootCause) { + super(rootCause); + this.pattern = getMessage(); + this.arguments = new Object[0]; + } + + /** + * Constructs a new MathRuntimeException with specified + * formatted detail message and nested Throwable root cause. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param rootCause the exception or error that caused this exception + * to be thrown. + * @param pattern format specifier + * @param arguments format arguments + */ + public MathRuntimeException(final Throwable rootCause, + final String pattern, final Object ... arguments) { + super(rootCause); + this.pattern = pattern; + this.arguments = (arguments == null) ? new Object[0] : arguments.clone(); + } + + /** + * Translate a string to a given locale. + * @param s string to translate + * @param locale locale into which to translate the string + * @return translated string or original string + * for unsupported locales or unknown strings + */ + private static String translate(final String s, final Locale locale) { + try { + ResourceBundle bundle = + ResourceBundle.getBundle("org.apache.commons.math.MessagesResources", locale); + if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) { + // the value of the resource is the translated string + return bundle.getString(s); + } + + } catch (MissingResourceException mre) { + // do nothing here + } + + // the locale is not supported or the resource is unknown + // don't translate and fall back to using the string as is + return s; + + } + + /** + * Builds a message string by from a pattern and its arguments. + * @param locale Locale in which the message should be translated + * @param pattern format specifier + * @param arguments format arguments + * @return a message string + */ + private static String buildMessage(final Locale locale, final String pattern, + final Object ... arguments) { + return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments); + } + + /** Gets the pattern used to build the message of this throwable. + * + * @return the pattern used to build the message of this throwable + */ + public String getPattern() { + return pattern; + } + + /** Gets the arguments used to build the message of this throwable. + * + * @return the arguments used to build the message of this throwable + */ + public Object[] getArguments() { + return arguments.clone(); + } + + /** Gets the message in a specified locale. + * + * @param locale Locale in which the message should be translated + * + * @return localized message + */ + public String getMessage(final Locale locale) { + return buildMessage(locale, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return getMessage(Locale.US); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return getMessage(Locale.getDefault()); + } + + /** + * Prints the stack trace of this exception to the standard error stream. + */ + @Override + public void printStackTrace() { + printStackTrace(System.err); + } + + /** + * Prints the stack trace of this exception to the specified stream. + * + * @param out the PrintStream to use for output + */ + @Override + public void printStackTrace(final PrintStream out) { + synchronized (out) { + PrintWriter pw = new PrintWriter(out, false); + printStackTrace(pw); + // Flush the PrintWriter before it's GC'ed. + pw.flush(); + } + } + + /** + * Constructs a new ArithmeticException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static ArithmeticException createArithmeticException(final String pattern, + final Object ... arguments) { + return new ArithmeticException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = 7705628723242533939L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new ArrayIndexOutOfBoundsException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static ArrayIndexOutOfBoundsException createArrayIndexOutOfBoundsException(final String pattern, + final Object ... arguments) { + return new ArrayIndexOutOfBoundsException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -3394748305449283486L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new EOFException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static EOFException createEOFException(final String pattern, + final Object ... arguments) { + return new EOFException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = 279461544586092584L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new IOException with specified nested + * Throwable root cause. + *

This factory method allows chaining of other exceptions within an + * IOException even for Java 5. The constructor for + * IOException with a cause parameter was introduced only + * with Java 6.

+ * @param rootCause the exception or error that caused this exception + * to be thrown. + * @return built exception + */ + public static IOException createIOException(final Throwable rootCause) { + IOException ioe = new IOException(rootCause.getLocalizedMessage()); + ioe.initCause(rootCause); + return ioe; + } + + /** + * Constructs a new IllegalArgumentException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static IllegalArgumentException createIllegalArgumentException(final String pattern, + final Object ... arguments) { + return new IllegalArgumentException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -6555453980658317913L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new IllegalArgumentException with specified nested + * Throwable root cause. + * @param rootCause the exception or error that caused this exception + * to be thrown. + * @return built exception + */ + public static IllegalArgumentException createIllegalArgumentException(final Throwable rootCause) { + IllegalArgumentException iae = new IllegalArgumentException(rootCause.getLocalizedMessage()); + iae.initCause(rootCause); + return iae; + } + + /** + * Constructs a new IllegalStateException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static IllegalStateException createIllegalStateException(final String pattern, + final Object ... arguments) { + return new IllegalStateException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -95247648156277208L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new ConcurrentModificationException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static ConcurrentModificationException createConcurrentModificationException(final String pattern, + final Object ... arguments) { + return new ConcurrentModificationException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = 6134247282754009421L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new NoSuchElementException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static NoSuchElementException createNoSuchElementException(final String pattern, + final Object ... arguments) { + return new NoSuchElementException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = 7304273322489425799L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new NullPointerException with specified formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static NullPointerException createNullPointerException(final String pattern, + final Object ... arguments) { + return new NullPointerException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -3075660477939965216L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** + * Constructs a new ParseException with specified + * formatted detail message. + * Message formatting is delegated to {@link java.text.MessageFormat}. + * @param offset offset at which error occurred + * @param pattern format specifier + * @param arguments format arguments + * @return built exception + */ + public static ParseException createParseException(final int offset, + final String pattern, + final Object ... arguments) { + return new ParseException(null, offset) { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -1103502177342465975L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, arguments); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, arguments); + } + + }; + } + + /** Create an {@link java.lang.RuntimeException} for an internal error. + * @param cause underlying cause + * @return an {@link java.lang.RuntimeException} for an internal error + */ + public static RuntimeException createInternalError(final Throwable cause) { + + final String pattern = "internal error, please fill a bug report at {0}"; + final String argument = "https://issues.apache.org/jira/browse/MATH"; + + return new RuntimeException() { + + /** Serializable version identifier. */ + private static final long serialVersionUID = -201865440834027016L; + + /** {@inheritDoc} */ + @Override + public String getMessage() { + return buildMessage(Locale.US, pattern, argument); + } + + /** {@inheritDoc} */ + @Override + public String getLocalizedMessage() { + return buildMessage(Locale.getDefault(), pattern, argument); + } + + }; + + } + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/MathRuntimeException.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,182 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +import org.apache.openejb.math.MathRuntimeException; +import org.apache.openejb.math.util.MathUtils; + +/** + * + * Abstract implementation of the {@link StorelessUnivariateStatistic} interface. + *

+ * Provides default evaluate() and incrementAll(double[]) + * implementations.

+ *

+ * Note that these implementations are not synchronized.

+ * + * @version $Revision: 811833 $ $Date: 2009-09-06 09:27:50 -0700 (Sun, 06 Sep 2009) $ + */ +public abstract class AbstractStorelessUnivariateStatistic + extends AbstractUnivariateStatistic + implements StorelessUnivariateStatistic { + + /** + * This default implementation calls {@link #clear}, then invokes + * {@link #increment} in a loop over the the input array, and then uses + * {@link #getResult} to compute the return value. + *

+ * Note that this implementation changes the internal state of the + * statistic. Its side effects are the same as invoking {@link #clear} and + * then {@link #incrementAll(double[])}.

+ *

+ * Implementations may override this method with a more efficient and + * possibly more accurate implementation that works directly with the + * input array.

+ *

+ * If the array is null, an IllegalArgumentException is thrown.

+ * @param values input array + * @return the value of the statistic applied to the input array + * @see UnivariateStatistic#evaluate(double[]) + */ + @Override + public double evaluate(final double[] values) { + if (values == null) { + throw MathRuntimeException.createIllegalArgumentException("input values array is null"); + } + return evaluate(values, 0, values.length); + } + + /** + * This default implementation calls {@link #clear}, then invokes + * {@link #increment} in a loop over the specified portion of the input + * array, and then uses {@link #getResult} to compute the return value. + *

+ * Note that this implementation changes the internal state of the + * statistic. Its side effects are the same as invoking {@link #clear} and + * then {@link #incrementAll(double[], int, int)}.

+ *

+ * Implementations may override this method with a more efficient and + * possibly more accurate implementation that works directly with the + * input array.

+ *

+ * If the array is null or the index parameters are not valid, an + * IllegalArgumentException is thrown.

+ * @param values the input array + * @param begin the index of the first element to include + * @param length the number of elements to include + * @return the value of the statistic applied to the included array entries + * @see UnivariateStatistic#evaluate(double[], int, int) + */ + @Override + public double evaluate(final double[] values, final int begin, final int length) { + if (test(values, begin, length)) { + clear(); + incrementAll(values, begin, length); + } + return getResult(); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract StorelessUnivariateStatistic copy(); + + /** + * {@inheritDoc} + */ + public abstract void clear(); + + /** + * {@inheritDoc} + */ + public abstract double getResult(); + + /** + * {@inheritDoc} + */ + public abstract void increment(final double d); + + /** + * This default implementation just calls {@link #increment} in a loop over + * the input array. + *

+ * Throws IllegalArgumentException if the input values array is null.

+ * + * @param values values to add + * @throws IllegalArgumentException if values is null + * @see StorelessUnivariateStatistic#incrementAll(double[]) + */ + public void incrementAll(double[] values) { + if (values == null) { + throw MathRuntimeException.createIllegalArgumentException("input values array is null"); + } + incrementAll(values, 0, values.length); + } + + /** + * This default implementation just calls {@link #increment} in a loop over + * the specified portion of the input array. + *

+ * Throws IllegalArgumentException if the input values array is null.

+ * + * @param values array holding values to add + * @param begin index of the first array element to add + * @param length number of array elements to add + * @throws IllegalArgumentException if values is null + * @see StorelessUnivariateStatistic#incrementAll(double[], int, int) + */ + public void incrementAll(double[] values, int begin, int length) { + if (test(values, begin, length)) { + int k = begin + length; + for (int i = begin; i < k; i++) { + increment(values[i]); + } + } + } + + /** + * Returns true iff object is an + * AbstractStorelessUnivariateStatistic returning the same + * values as this for getResult() and getN() + * @param object object to test equality against. + * @return true if object returns the same value as this + */ + @Override + public boolean equals(Object object) { + if (object == this ) { + return true; + } + if (object instanceof AbstractStorelessUnivariateStatistic == false) { + return false; + } + AbstractStorelessUnivariateStatistic stat = (AbstractStorelessUnivariateStatistic) object; + return MathUtils.equals(stat.getResult(), this.getResult()) && + MathUtils.equals(stat.getN(), this.getN()); + } + + /** + * Returns hash code based on getResult() and getN() + * + * @return hash code + */ + @Override + public int hashCode() { + return 31* (31 + MathUtils.hash(getResult())) + MathUtils.hash(getN()); + } + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,177 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +import org.apache.openejb.math.MathRuntimeException; + +/** + * Abstract base class for all implementations of the + * {@link UnivariateStatistic} interface. + *

+ * Provides a default implementation of evaluate(double[]), + * delegating to evaluate(double[], int, int) in the natural way. + *

+ *

+ * Also includes a test method that performs generic parameter + * validation for the evaluate methods.

+ * + * @version $Revision: 894705 $ $Date: 2009-12-30 12:24:54 -0800 (Wed, 30 Dec 2009) $ + */ +public abstract class AbstractUnivariateStatistic + implements UnivariateStatistic { + + /** + * {@inheritDoc} + */ + public double evaluate(final double[] values) { + test(values, 0, 0); + return evaluate(values, 0, values.length); + } + + /** + * {@inheritDoc} + */ + public abstract double evaluate(final double[] values, final int begin, final int length); + + /** + * {@inheritDoc} + */ + public abstract UnivariateStatistic copy(); + + /** + * This method is used by evaluate(double[], int, int) methods + * to verify that the input parameters designate a subarray of positive length. + *

+ *

    + *
  • returns true iff the parameters designate a subarray of + * positive length
  • + *
  • throws IllegalArgumentException if the array is null or + * or the indices are invalid
  • + *
  • returns false
  • if the array is non-null, but + * length is 0. + *

+ * + * @param values the input array + * @param begin index of the first array element to include + * @param length the number of elements to include + * @return true if the parameters are valid and designate a subarray of positive length + * @throws IllegalArgumentException if the indices are invalid or the array is null + */ + protected boolean test( + final double[] values, + final int begin, + final int length) { + + if (values == null) { + throw MathRuntimeException.createIllegalArgumentException("input values array is null"); + } + + if (begin < 0) { + throw MathRuntimeException.createIllegalArgumentException( + "start position cannot be negative ({0})", begin); + } + + if (length < 0) { + throw MathRuntimeException.createIllegalArgumentException( + "length cannot be negative ({0})", length); + } + + if (begin + length > values.length) { + throw MathRuntimeException.createIllegalArgumentException( + "subarray ends after array end"); + } + + if (length == 0) { + return false; + } + + return true; + + } + + /** + * This method is used by evaluate(double[], double[], int, int) methods + * to verify that the begin and length parameters designate a subarray of positive length + * and the weights are all non-negative, non-NaN, finite, and not all zero. + *

+ *

    + *
  • returns true iff the parameters designate a subarray of + * positive length and the weights array contains legitimate values.
  • + *
  • throws IllegalArgumentException if any of the following are true: + *
    • the values array is null
    • + *
    • the weights array is null
    • + *
    • the weights array does not have the same length as the values array
    • + *
    • the weights array contains one or more infinite values
    • + *
    • the weights array contains one or more NaN values
    • + *
    • the weights array contains negative values
    • + *
    • the start and length arguments do not determine a valid array
    + *
  • + *
  • returns false
  • if the array is non-null, but + * length is 0. + *

+ * + * @param values the input array + * @param weights the weights array + * @param begin index of the first array element to include + * @param length the number of elements to include + * @return true if the parameters are valid and designate a subarray of positive length + * @throws IllegalArgumentException if the indices are invalid or the array is null + * @since 2.1 + */ + protected boolean test( + final double[] values, + final double[] weights, + final int begin, + final int length) { + + if (weights == null) { + throw MathRuntimeException.createIllegalArgumentException("input weights array is null"); + } + + if (weights.length != values.length) { + throw MathRuntimeException.createIllegalArgumentException( + "Different number of weights and values"); + } + + boolean containsPositiveWeight = false; + for (int i = begin; i < begin + length; i++) { + if (Double.isNaN(weights[i])) { + throw MathRuntimeException.createIllegalArgumentException( + "NaN weight at index {0}", i); + } + if (Double.isInfinite(weights[i])) { + throw MathRuntimeException.createIllegalArgumentException( + "Infinite weight at index {0}", i); + } + if (weights[i] < 0) { + throw MathRuntimeException.createIllegalArgumentException( + "negative weight {0} at index {1} ", weights[i], i); + } + if (!containsPositiveWeight && weights[i] > 0.0) { + containsPositiveWeight = true; + } + } + + if (!containsPositiveWeight) { + throw MathRuntimeException.createIllegalArgumentException( + "weight array must contain at least one non-zero value"); + } + + return test(values, begin, length); + } +} + Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/AbstractUnivariateStatistic.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,713 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.apache.openejb.math.MathRuntimeException; +import org.apache.openejb.math.stat.descriptive.moment.GeometricMean; +import org.apache.openejb.math.stat.descriptive.moment.Kurtosis; +import org.apache.openejb.math.stat.descriptive.moment.Mean; +import org.apache.openejb.math.stat.descriptive.moment.Skewness; +import org.apache.openejb.math.stat.descriptive.moment.Variance; +import org.apache.openejb.math.stat.descriptive.rank.Max; +import org.apache.openejb.math.stat.descriptive.rank.Min; +import org.apache.openejb.math.stat.descriptive.rank.Percentile; +import org.apache.openejb.math.stat.descriptive.summary.Sum; +import org.apache.openejb.math.stat.descriptive.summary.SumOfSquares; +import org.apache.openejb.math.util.ResizableDoubleArray; + + +/** + * Maintains a dataset of values of a single variable and computes descriptive + * statistics based on stored data. The {@link #getWindowSize() windowSize} + * property sets a limit on the number of values that can be stored in the + * dataset. The default value, INFINITE_WINDOW, puts no limit on the size of + * the dataset. This value should be used with caution, as the backing store + * will grow without bound in this case. For very large datasets, + * {@link org.apache.commons.math.stat.descriptive.SummaryStatistics}, which does not store the dataset, should be used + * instead of this class. If windowSize is not INFINITE_WINDOW and + * more values are added than can be stored in the dataset, new values are + * added in a "rolling" manner, with new values replacing the "oldest" values + * in the dataset. + * + *

Note: this class is not threadsafe. Use + * {@link org.apache.openejb.math.stat.descriptive.SynchronizedDescriptiveStatistics} if concurrent access from multiple + * threads is required.

+ * + * @version $Revision: 885278 $ $Date: 2009-11-29 13:47:51 -0800 (Sun, 29 Nov 2009) $ + */ +public class DescriptiveStatistics implements StatisticalSummary, Serializable { + + /** + * Represents an infinite window size. When the {@link #getWindowSize()} + * returns this value, there is no limit to the number of data values + * that can be stored in the dataset. + */ + public static final int INFINITE_WINDOW = -1; + + /** Serialization UID */ + private static final long serialVersionUID = 4133067267405273064L; + + /** Name of the setQuantile method. */ + private static final String SET_QUANTILE_METHOD_NAME = "setQuantile"; + + /** Message for unsupported setQuantile. */ + private static final String UNSUPPORTED_METHOD_MESSAGE = + "percentile implementation {0} does not support {1}"; + + /** Message for illegal accesson setquantile. */ + private static final String ILLEGAL_ACCESS_MESSAGE = + "cannot access {0} method in percentile implementation {1}"; + + /** hold the window size **/ + protected int windowSize = INFINITE_WINDOW; + + /** + * Stored data values + */ + protected ResizableDoubleArray eDA = new ResizableDoubleArray(); + + /** Mean statistic implementation - can be reset by setter. */ + private UnivariateStatistic meanImpl = new Mean(); + + /** Geometric mean statistic implementation - can be reset by setter. */ + private UnivariateStatistic geometricMeanImpl = new GeometricMean(); + + /** Kurtosis statistic implementation - can be reset by setter. */ + private UnivariateStatistic kurtosisImpl = new Kurtosis(); + + /** Maximum statistic implementation - can be reset by setter. */ + private UnivariateStatistic maxImpl = new Max(); + + /** Minimum statistic implementation - can be reset by setter. */ + private UnivariateStatistic minImpl = new Min(); + + /** Percentile statistic implementation - can be reset by setter. */ + private UnivariateStatistic percentileImpl = new Percentile(); + + /** Skewness statistic implementation - can be reset by setter. */ + private UnivariateStatistic skewnessImpl = new Skewness(); + + /** Variance statistic implementation - can be reset by setter. */ + private UnivariateStatistic varianceImpl = new Variance(); + + /** Sum of squares statistic implementation - can be reset by setter. */ + private UnivariateStatistic sumsqImpl = new SumOfSquares(); + + /** Sum statistic implementation - can be reset by setter. */ + private UnivariateStatistic sumImpl = new Sum(); + + /** + * Construct a DescriptiveStatistics instance with an infinite window + */ + public DescriptiveStatistics() { + } + + /** + * Construct a DescriptiveStatistics instance with the specified window + * + * @param window the window size. + */ + public DescriptiveStatistics(int window) { + setWindowSize(window); + } + + /** + * Copy constructor. Construct a new DescriptiveStatistics instance that + * is a copy of original. + * + * @param original DescriptiveStatistics instance to copy + */ + public DescriptiveStatistics(DescriptiveStatistics original) { + copy(original, this); + } + + /** + * Adds the value to the dataset. If the dataset is at the maximum size + * (i.e., the number of stored elements equals the currently configured + * windowSize), the first (oldest) element in the dataset is discarded + * to make room for the new value. + * + * @param v the value to be added + */ + public void addValue(double v) { + if (windowSize != INFINITE_WINDOW) { + if (getN() == windowSize) { + eDA.addElementRolling(v); + } else if (getN() < windowSize) { + eDA.addElement(v); + } + } else { + eDA.addElement(v); + } + } + + /** + * Removes the most recent value from the dataset. + */ + public void removeMostRecentValue() { + eDA.discardMostRecentElements(1); + } + + /** + * Replaces the most recently stored value with the given value. + * There must be at least one element stored to call this method. + * + * @param v the value to replace the most recent stored value + * @return replaced value + */ + public double replaceMostRecentValue(double v) { + return eDA.substituteMostRecentElement(v); + } + + /** + * Returns the + * arithmetic mean of the available values + * @return The mean or Double.NaN if no values have been added. + */ + public double getMean() { + return apply(meanImpl); + } + + /** + * Returns the + * geometric mean of the available values + * @return The geometricMean, Double.NaN if no values have been added, + * or if the product of the available values is less than or equal to 0. + */ + public double getGeometricMean() { + return apply(geometricMeanImpl); + } + + /** + * Returns the variance of the available values. + * @return The variance, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public double getVariance() { + return apply(varianceImpl); + } + + /** + * Returns the standard deviation of the available values. + * @return The standard deviation, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + public double getStandardDeviation() { + double stdDev = Double.NaN; + if (getN() > 0) { + if (getN() > 1) { + stdDev = Math.sqrt(getVariance()); + } else { + stdDev = 0.0; + } + } + return stdDev; + } + + /** + * Returns the skewness of the available values. Skewness is a + * measure of the asymmetry of a given distribution. + * @return The skewness, Double.NaN if no values have been added + * or 0.0 for a value set <=2. + */ + public double getSkewness() { + return apply(skewnessImpl); + } + + /** + * Returns the Kurtosis of the available values. Kurtosis is a + * measure of the "peakedness" of a distribution + * @return The kurtosis, Double.NaN if no values have been added, or 0.0 + * for a value set <=3. + */ + public double getKurtosis() { + return apply(kurtosisImpl); + } + + /** + * Returns the maximum of the available values + * @return The max or Double.NaN if no values have been added. + */ + public double getMax() { + return apply(maxImpl); + } + + /** + * Returns the minimum of the available values + * @return The min or Double.NaN if no values have been added. + */ + public double getMin() { + return apply(minImpl); + } + + /** + * Returns the number of available values + * @return The number of available values + */ + public long getN() { + return eDA.getNumElements(); + } + + /** + * Returns the sum of the values that have been added to Univariate. + * @return The sum or Double.NaN if no values have been added + */ + public double getSum() { + return apply(sumImpl); + } + + /** + * Returns the sum of the squares of the available values. + * @return The sum of the squares or Double.NaN if no + * values have been added. + */ + public double getSumsq() { + return apply(sumsqImpl); + } + + /** + * Resets all statistics and storage + */ + public void clear() { + eDA.clear(); + } + + + /** + * Returns the maximum number of values that can be stored in the + * dataset, or INFINITE_WINDOW (-1) if there is no limit. + * + * @return The current window size or -1 if its Infinite. + */ + public int getWindowSize() { + return windowSize; + } + + /** + * WindowSize controls the number of values which contribute + * to the reported statistics. For example, if + * windowSize is set to 3 and the values {1,2,3,4,5} + * have been added in that order + * then the available values are {3,4,5} and all + * reported statistics will be based on these values + * @param windowSize sets the size of the window. + */ + public void setWindowSize(int windowSize) { + if (windowSize < 1) { + if (windowSize != INFINITE_WINDOW) { + throw MathRuntimeException.createIllegalArgumentException( + "window size must be positive ({0})", windowSize); + } + } + + this.windowSize = windowSize; + + // We need to check to see if we need to discard elements + // from the front of the array. If the windowSize is less than + // the current number of elements. + if (windowSize != INFINITE_WINDOW && windowSize < eDA.getNumElements()) { + eDA.discardFrontElements(eDA.getNumElements() - windowSize); + } + } + + /** + * Returns the current set of values in an array of double primitives. + * The order of addition is preserved. The returned array is a fresh + * copy of the underlying data -- i.e., it is not a reference to the + * stored data. + * + * @return returns the current set of numbers in the order in which they + * were added to this set + */ + public double[] getValues() { + return eDA.getElements(); + } + + /** + * Returns the current set of values in an array of double primitives, + * sorted in ascending order. The returned array is a fresh + * copy of the underlying data -- i.e., it is not a reference to the + * stored data. + * @return returns the current set of + * numbers sorted in ascending order + */ + public double[] getSortedValues() { + double[] sort = getValues(); + Arrays.sort(sort); + return sort; + } + + /** + * Returns the element at the specified index + * @param index The Index of the element + * @return return the element at the specified index + */ + public double getElement(int index) { + return eDA.getElement(index); + } + + /** + * Returns an estimate for the pth percentile of the stored values. + *

+ * The implementation provided here follows the first estimation procedure presented + * here. + *

+ * Preconditions:

    + *
  • 0 < p ≤ 100 (otherwise an + * IllegalArgumentException is thrown)
  • + *
  • at least one value must be stored (returns Double.NaN + * otherwise)
  • + *

+ * + * @param p the requested percentile (scaled from 0 - 100) + * @return An estimate for the pth percentile of the stored data + * @throws IllegalStateException if percentile implementation has been + * overridden and the supplied implementation does not support setQuantile + * values + */ + public double getPercentile(double p) { + if (percentileImpl instanceof Percentile) { + ((Percentile) percentileImpl).setQuantile(p); + } else { + try { + percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME, + new Class[] {Double.TYPE}).invoke(percentileImpl, + new Object[] {Double.valueOf(p)}); + } catch (NoSuchMethodException e1) { // Setter guard should prevent + throw MathRuntimeException.createIllegalArgumentException( + UNSUPPORTED_METHOD_MESSAGE, + percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME); + } catch (IllegalAccessException e2) { + throw MathRuntimeException.createIllegalArgumentException( + ILLEGAL_ACCESS_MESSAGE, + SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName()); + } catch (InvocationTargetException e3) { + throw MathRuntimeException.createIllegalArgumentException(e3.getCause()); + } + } + return apply(percentileImpl); + } + + /** + * Generates a text report displaying univariate statistics from values + * that have been added. Each statistic is displayed on a separate + * line. + * + * @return String with line feeds displaying statistics + */ + @Override + public String toString() { + StringBuffer outBuffer = new StringBuffer(); + String endl = "\n"; + outBuffer.append("DescriptiveStatistics:").append(endl); + outBuffer.append("n: ").append(getN()).append(endl); + outBuffer.append("min: ").append(getMin()).append(endl); + outBuffer.append("max: ").append(getMax()).append(endl); + outBuffer.append("mean: ").append(getMean()).append(endl); + outBuffer.append("std dev: ").append(getStandardDeviation()) + .append(endl); + outBuffer.append("median: ").append(getPercentile(50)).append(endl); + outBuffer.append("skewness: ").append(getSkewness()).append(endl); + outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl); + return outBuffer.toString(); + } + + /** + * Apply the given statistic to the data associated with this set of statistics. + * @param stat the statistic to apply + * @return the computed value of the statistic. + */ + public double apply(UnivariateStatistic stat) { + return stat.evaluate(eDA.getInternalValues(), eDA.start(), eDA.getNumElements()); + } + + // Implementation getters and setter + + /** + * Returns the currently configured mean implementation. + * + * @return the UnivariateStatistic implementing the mean + * @since 1.2 + */ + public synchronized UnivariateStatistic getMeanImpl() { + return meanImpl; + } + + /** + *

Sets the implementation for the mean.

+ * + * @param meanImpl the UnivariateStatistic instance to use + * for computing the mean + * @since 1.2 + */ + public synchronized void setMeanImpl(UnivariateStatistic meanImpl) { + this.meanImpl = meanImpl; + } + + /** + * Returns the currently configured geometric mean implementation. + * + * @return the UnivariateStatistic implementing the geometric mean + * @since 1.2 + */ + public synchronized UnivariateStatistic getGeometricMeanImpl() { + return geometricMeanImpl; + } + + /** + *

Sets the implementation for the gemoetric mean.

+ * + * @param geometricMeanImpl the UnivariateStatistic instance to use + * for computing the geometric mean + * @since 1.2 + */ + public synchronized void setGeometricMeanImpl( + UnivariateStatistic geometricMeanImpl) { + this.geometricMeanImpl = geometricMeanImpl; + } + + /** + * Returns the currently configured kurtosis implementation. + * + * @return the UnivariateStatistic implementing the kurtosis + * @since 1.2 + */ + public synchronized UnivariateStatistic getKurtosisImpl() { + return kurtosisImpl; + } + + /** + *

Sets the implementation for the kurtosis.

+ * + * @param kurtosisImpl the UnivariateStatistic instance to use + * for computing the kurtosis + * @since 1.2 + */ + public synchronized void setKurtosisImpl(UnivariateStatistic kurtosisImpl) { + this.kurtosisImpl = kurtosisImpl; + } + + /** + * Returns the currently configured maximum implementation. + * + * @return the UnivariateStatistic implementing the maximum + * @since 1.2 + */ + public synchronized UnivariateStatistic getMaxImpl() { + return maxImpl; + } + + /** + *

Sets the implementation for the maximum.

+ * + * @param maxImpl the UnivariateStatistic instance to use + * for computing the maximum + * @since 1.2 + */ + public synchronized void setMaxImpl(UnivariateStatistic maxImpl) { + this.maxImpl = maxImpl; + } + + /** + * Returns the currently configured minimum implementation. + * + * @return the UnivariateStatistic implementing the minimum + * @since 1.2 + */ + public synchronized UnivariateStatistic getMinImpl() { + return minImpl; + } + + /** + *

Sets the implementation for the minimum.

+ * + * @param minImpl the UnivariateStatistic instance to use + * for computing the minimum + * @since 1.2 + */ + public synchronized void setMinImpl(UnivariateStatistic minImpl) { + this.minImpl = minImpl; + } + + /** + * Returns the currently configured percentile implementation. + * + * @return the UnivariateStatistic implementing the percentile + * @since 1.2 + */ + public synchronized UnivariateStatistic getPercentileImpl() { + return percentileImpl; + } + + /** + * Sets the implementation to be used by {@link #getPercentile(double)}. + * The supplied UnivariateStatistic must provide a + * setQuantile(double) method; otherwise + * IllegalArgumentException is thrown. + * + * @param percentileImpl the percentileImpl to set + * @throws IllegalArgumentException if the supplied implementation does not + * provide a setQuantile method + * @since 1.2 + */ + public synchronized void setPercentileImpl( + UnivariateStatistic percentileImpl) { + try { + percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME, + new Class[] {Double.TYPE}).invoke(percentileImpl, + new Object[] {Double.valueOf(50.0d)}); + } catch (NoSuchMethodException e1) { + throw MathRuntimeException.createIllegalArgumentException( + "percentile implementation {0} does not support setQuantile", + percentileImpl.getClass().getName()); + } catch (IllegalAccessException e2) { + throw MathRuntimeException.createIllegalArgumentException( + ILLEGAL_ACCESS_MESSAGE, + SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName()); + } catch (InvocationTargetException e3) { + throw MathRuntimeException.createIllegalArgumentException(e3.getCause()); + } + this.percentileImpl = percentileImpl; + } + + /** + * Returns the currently configured skewness implementation. + * + * @return the UnivariateStatistic implementing the skewness + * @since 1.2 + */ + public synchronized UnivariateStatistic getSkewnessImpl() { + return skewnessImpl; + } + + /** + *

Sets the implementation for the skewness.

+ * + * @param skewnessImpl the UnivariateStatistic instance to use + * for computing the skewness + * @since 1.2 + */ + public synchronized void setSkewnessImpl( + UnivariateStatistic skewnessImpl) { + this.skewnessImpl = skewnessImpl; + } + + /** + * Returns the currently configured variance implementation. + * + * @return the UnivariateStatistic implementing the variance + * @since 1.2 + */ + public synchronized UnivariateStatistic getVarianceImpl() { + return varianceImpl; + } + + /** + *

Sets the implementation for the variance.

+ * + * @param varianceImpl the UnivariateStatistic instance to use + * for computing the variance + * @since 1.2 + */ + public synchronized void setVarianceImpl( + UnivariateStatistic varianceImpl) { + this.varianceImpl = varianceImpl; + } + + /** + * Returns the currently configured sum of squares implementation. + * + * @return the UnivariateStatistic implementing the sum of squares + * @since 1.2 + */ + public synchronized UnivariateStatistic getSumsqImpl() { + return sumsqImpl; + } + + /** + *

Sets the implementation for the sum of squares.

+ * + * @param sumsqImpl the UnivariateStatistic instance to use + * for computing the sum of squares + * @since 1.2 + */ + public synchronized void setSumsqImpl(UnivariateStatistic sumsqImpl) { + this.sumsqImpl = sumsqImpl; + } + + /** + * Returns the currently configured sum implementation. + * + * @return the UnivariateStatistic implementing the sum + * @since 1.2 + */ + public synchronized UnivariateStatistic getSumImpl() { + return sumImpl; + } + + /** + *

Sets the implementation for the sum.

+ * + * @param sumImpl the UnivariateStatistic instance to use + * for computing the sum + * @since 1.2 + */ + public synchronized void setSumImpl(UnivariateStatistic sumImpl) { + this.sumImpl = sumImpl; + } + + /** + * Returns a copy of this DescriptiveStatistics instance with the same internal state. + * + * @return a copy of this + */ + public DescriptiveStatistics copy() { + DescriptiveStatistics result = new DescriptiveStatistics(); + copy(this, result); + return result; + } + + /** + * Copies source to dest. + *

Neither source nor dest can be null.

+ * + * @param source DescriptiveStatistics to copy + * @param dest DescriptiveStatistics to copy to + * @throws NullPointerException if either source or dest is null + */ + public static void copy(DescriptiveStatistics source, DescriptiveStatistics dest) { + // Copy data and window size + dest.eDA = source.eDA.copy(); + dest.windowSize = source.windowSize; + + // Copy implementations + dest.maxImpl = source.maxImpl.copy(); + dest.meanImpl = source.meanImpl.copy(); + dest.minImpl = source.minImpl.copy(); + dest.sumImpl = source.sumImpl.copy(); + dest.varianceImpl = source.varianceImpl.copy(); + dest.sumsqImpl = source.sumsqImpl.copy(); + dest.geometricMeanImpl = source.geometricMeanImpl.copy(); + dest.kurtosisImpl = source.kurtosisImpl; + dest.skewnessImpl = source.skewnessImpl; + dest.percentileImpl = source.percentileImpl; + } +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/DescriptiveStatistics.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,65 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +/** + * Reporting interface for basic univariate statistics. + * + * @version $Revision: 811786 $ $Date: 2009-09-06 02:36:08 -0700 (Sun, 06 Sep 2009) $ + */ +public interface StatisticalSummary { + + /** + * Returns the + * arithmetic mean of the available values + * @return The mean or Double.NaN if no values have been added. + */ + double getMean(); + /** + * Returns the variance of the available values. + * @return The variance, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + double getVariance(); + /** + * Returns the standard deviation of the available values. + * @return The standard deviation, Double.NaN if no values have been added + * or 0.0 for a single value set. + */ + double getStandardDeviation(); + /** + * Returns the maximum of the available values + * @return The max or Double.NaN if no values have been added. + */ + double getMax(); + /** + * Returns the minimum of the available values + * @return The min or Double.NaN if no values have been added. + */ + double getMin(); + /** + * Returns the number of available values + * @return The number of available values + */ + long getN(); + /** + * Returns the sum of the values that have been added to Univariate. + * @return The sum or Double.NaN if no values have been added + */ + double getSum(); + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StatisticalSummary.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,86 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +/** + * Extends the definition of {@link UnivariateStatistic} with + * {@link #increment} and {@link #incrementAll(double[])} methods for adding + * values and updating internal state. + *

+ * This interface is designed to be used for calculating statistics that can be + * computed in one pass through the data without storing the full array of + * sample values.

+ * + * @version $Revision: 811685 $ $Date: 2009-09-05 10:36:48 -0700 (Sat, 05 Sep 2009) $ + */ +public interface StorelessUnivariateStatistic extends UnivariateStatistic { + + /** + * Updates the internal state of the statistic to reflect the addition of the new value. + * @param d the new value. + */ + void increment(double d); + + /** + * Updates the internal state of the statistic to reflect addition of + * all values in the values array. Does not clear the statistic first -- + * i.e., the values are added incrementally to the dataset. + * + * @param values array holding the new values to add + * @throws IllegalArgumentException if the array is null + */ + void incrementAll(double[] values); + + /** + * Updates the internal state of the statistic to reflect addition of + * the values in the designated portion of the values array. Does not + * clear the statistic first -- i.e., the values are added + * incrementally to the dataset. + * + * @param values array holding the new values to add + * @param start the array index of the first value to add + * @param length the number of elements to add + * @throws IllegalArgumentException if the array is null or the index + */ + void incrementAll(double[] values, int start, int length); + + /** + * Returns the current value of the Statistic. + * @return value of the statistic, Double.NaN if it + * has been cleared or just instantiated. + */ + double getResult(); + + /** + * Returns the number of values that have been added. + * @return the number of values. + */ + long getN(); + + /** + * Clears the internal state of the Statistic + */ + void clear(); + + /** + * Returns a copy of the statistic with the same internal state. + * + * @return a copy of the statistic + */ + StorelessUnivariateStatistic copy(); + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/StorelessUnivariateStatistic.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,172 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +/** + * Implementation of + * {@link DescriptiveStatistics} that + * is safe to use in a multithreaded environment. Multiple threads can safely + * operate on a single instance without causing runtime exceptions due to race + * conditions. In effect, this implementation makes modification and access + * methods atomic operations for a single instance. That is to say, as one + * thread is computing a statistic from the instance, no other thread can modify + * the instance nor compute another statistic. + * + * @since 1.2 + * @version $Revision: 811685 $ $Date: 2009-09-05 10:36:48 -0700 (Sat, 05 Sep 2009) $ + */ +public class SynchronizedDescriptiveStatistics extends DescriptiveStatistics { + + /** Serialization UID */ + private static final long serialVersionUID = 1L; + + /** + * Construct an instance with infinite window + */ + public SynchronizedDescriptiveStatistics() { + this(INFINITE_WINDOW); + } + + /** + * Construct an instance with finite window + * @param window the finite window size. + */ + public SynchronizedDescriptiveStatistics(int window) { + super(window); + } + + /** + * A copy constructor. Creates a deep-copy of the {@code original}. + * + * @param original the {@code SynchronizedDescriptiveStatistics} instance to copy + */ + public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original) { + copy(original, this); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void addValue(double v) { + super.addValue(v); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized double apply(UnivariateStatistic stat) { + return super.apply(stat); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void clear() { + super.clear(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized double getElement(int index) { + return super.getElement(index); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized long getN() { + return super.getN(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized double getStandardDeviation() { + return super.getStandardDeviation(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized double[] getValues() { + return super.getValues(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized int getWindowSize() { + return super.getWindowSize(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void setWindowSize(int windowSize) { + super.setWindowSize(windowSize); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized String toString() { + return super.toString(); + } + + /** + * Returns a copy of this SynchronizedDescriptiveStatistics instance with the + * same internal state. + * + * @return a copy of this + */ + @Override + public synchronized SynchronizedDescriptiveStatistics copy() { + SynchronizedDescriptiveStatistics result = + new SynchronizedDescriptiveStatistics(); + copy(this, result); + return result; + } + + /** + * Copies source to dest. + *

Neither source nor dest can be null.

+ *

Acquires synchronization lock on source, then dest before copying.

+ * + * @param source SynchronizedDescriptiveStatistics to copy + * @param dest SynchronizedDescriptiveStatistics to copy to + * @throws NullPointerException if either source or dest is null + */ + public static void copy(SynchronizedDescriptiveStatistics source, + SynchronizedDescriptiveStatistics dest) { + synchronized (source) { + synchronized (dest) { + DescriptiveStatistics.copy(source, dest); + } + } + } +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/SynchronizedDescriptiveStatistics.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,53 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + + +/** + * Base interface implemented by all statistics. + * + * @version $Revision: 811685 $ $Date: 2009-09-05 10:36:48 -0700 (Sat, 05 Sep 2009) $ + */ +public interface UnivariateStatistic { + + /** + * Returns the result of evaluating the statistic over the input array. + * + * @param values input array + * @return the value of the statistic applied to the input array + */ + double evaluate(double[] values); + + /** + * Returns the result of evaluating the statistic over the specified entries + * in the input array. + * + * @param values the input array + * @param begin the index of the first element to include + * @param length the number of elements to include + * @return the value of the statistic applied to the included array entries + */ + double evaluate(double[] values, int begin, int length); + + /** + * Returns a copy of the statistic with the same internal state. + * + * @return a copy of the statistic + */ + UnivariateStatistic copy(); + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/UnivariateStatistic.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java?rev=1005322&view=auto ============================================================================== --- openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java (added) +++ openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java Thu Oct 7 03:18:24 2010 @@ -0,0 +1,49 @@ +/* + * 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. + */ +package org.apache.openejb.math.stat.descriptive; + +/** + * Weighted evaluation for statistics. + * + * @since 2.1 + * @version $Revision: 894474 $ $Date: 2009-12-29 12:02:37 -0800 (Tue, 29 Dec 2009) $ + */ +public interface WeightedEvaluation { + + /** + * Returns the result of evaluating the statistic over the input array, + * using the supplied weights. + * + * @param values input array + * @param weights array of weights + * @return the value of the weighted statistic applied to the input array + */ + double evaluate(double[] values, double[] weights); + + /** + * Returns the result of evaluating the statistic over the specified entries + * in the input array, using corresponding entries in the supplied weights array. + * + * @param values the input array + * @param weights array of weights + * @param begin the index of the first element to include + * @param length the number of elements to include + * @return the value of the weighted statistic applied to the included array entries + */ + double evaluate(double[] values, double[] weights, int begin, int length); + +} Propchange: openejb/branches/openejb-3.1.x/container/openejb-core/src/main/java/org/apache/openejb/math/stat/descriptive/WeightedEvaluation.java ------------------------------------------------------------------------------ svn:eol-style = native