Thread: [Japi-cvs] SF.net SVN: japi: [38] trunk/src/app/net/sf/japi
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-04-10 22:47:40
|
Revision: 38 Author: christianhujer Date: 2006-04-10 15:47:20 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=38&view=rev Log Message: ----------- Finance is not a util package, but a package of its own. Added Paths: ----------- trunk/src/app/net/sf/japi/finance/ trunk/src/app/net/sf/japi/finance/InterestCalculator.java trunk/src/test/net/sf/japi/finance/ trunk/src/test/net/sf/japi/finance/InterestCalculatorTest.java Removed Paths: ------------- trunk/src/app/net/sf/japi/util/finance/ trunk/src/test/net/sf/japi/util/finance/ Copied: trunk/src/app/net/sf/japi/finance/InterestCalculator.java (from rev 36, trunk/src/app/net/sf/japi/util/finance/InterestCalculator.java) =================================================================== --- trunk/src/app/net/sf/japi/finance/InterestCalculator.java (rev 0) +++ trunk/src/app/net/sf/japi/finance/InterestCalculator.java 2006-04-10 22:47:20 UTC (rev 38) @@ -0,0 +1,95 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Anja Heim + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.finance; + +/** Class contains some functionality for calculating capital after some periods of time. + * @author <a href="mailto:miz...@we...">A. Heim</a> + */ +public class InterestCalculator { + + private final float initialCapital; + private float interestRate; + private float currentCapital; + + public InterestCalculator(final float initialCapital, final float interestRate) { + this.initialCapital = initialCapital; + this.interestRate = interestRate; + this.currentCapital = this.initialCapital; + } + + /** Calculates the overall capital after some periods beginnig with given initial capital and interest rate. + * <br />The formula is: <code>capital_after_n_periods = start_captial * ( 1 + p/100 )^n</code> + * (with p as interest rate) + * @param numberOfPeriods + * @return the overall capital after numberOfPeriods periods + */ + public float calculateCapital( int numberOfPeriods ) { + if ( numberOfPeriods < 0 ) throw new IllegalArgumentException("Number of periods has to be at least 1!"); + if ( numberOfPeriods == 0 ) + return initialCapital; + if( numberOfPeriods == 1 ) { + currentCapital = currentCapital *(1 + interestRate/100); + } else { + currentCapital = calculateCapital( numberOfPeriods - 1 ); + } + return currentCapital; + } + + /** Returns the current capital. + * + * @return current capital + */ + public float getCurrentCapital() { + return currentCapital; + } + + /** Sets new current capital. + * + * @param currentCapital + */ + public void setCurrentCapital(float currentCapital) { + this.currentCapital = currentCapital; + } + + /** Sets new interest rate. + * + * @param interestRate + */ + public void setInterestRate(float interestRate) { + this.interestRate = interestRate; + } + + /** Returns the current interest rate. + * + * @return the current interest rate + */ + public float getInterestRate() { + return interestRate; + } + + /** Resets the current capital to initial capital. + * + */ + public void resetCapital() { + this.currentCapital = this.initialCapital; + } + +} // class InterestCalculator Property changes on: trunk/src/app/net/sf/japi/finance/InterestCalculator.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/src/test/net/sf/japi/finance/InterestCalculatorTest.java (from rev 37, trunk/src/test/net/sf/japi/util/finance/InterestCalculatorTest.java) =================================================================== --- trunk/src/test/net/sf/japi/finance/InterestCalculatorTest.java (rev 0) +++ trunk/src/test/net/sf/japi/finance/InterestCalculatorTest.java 2006-04-10 22:47:20 UTC (rev 38) @@ -0,0 +1,89 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Anja Heim + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package test.net.sf.japi.finance; + +import junit.framework.TestCase; +import net.sf.japi.finance.InterestCalculator; + +/** Tests the capital finance class. + * Date: 09.04.2006 + * + */ +public class InterestCalculatorTest extends TestCase { + + InterestCalculator ic = new InterestCalculator(100, 15); + + public void testInterestCalculator() throws Exception { + //ic = new InterestCalculator(100, 15); + } + + /** Tests capital after 0, 1, 2 , 3 years. + * @throws Exception + */ + public void testCalculateCapital() throws Exception { + //ic = new InterestCalculator(100, 15); + + + /* first try it with invalid argument */ + try { + ic.calculateCapital(-1); + fail("Expected IllegalArgumentException."); + } catch (final IllegalArgumentException ignore) { + /* ignore */ + } + /* then use some different periods */ + assertEquals("Capital after a time period of 0 must be the starting capital.", (float)100.0 , ic.calculateCapital( 0 ) ); + assertEquals( (float)115.0 , ic.calculateCapital( 1 ) ); + assertEquals( (float)132.25 , ic.calculateCapital( 2 ) ); + assertEquals( (float)152.0875, ic.calculateCapital( 3 ) ); + } + + public void testGetCurrentCapital() throws Exception { + assertEquals( (float)100.00, ic.getCurrentCapital() ); + ic.calculateCapital(1); + assertEquals( (float)115.00, ic.getCurrentCapital() ); + } + + public void testSetCurrentCapital() throws Exception { + assertEquals( (float)100.00, ic.getCurrentCapital() ); + ic.calculateCapital(1); + assertEquals( (float)115.00, ic.getCurrentCapital() ); + ic.setCurrentCapital((float)100.00); + assertEquals( (float)100.00, ic.getCurrentCapital() ); + } + + public void testGetInterestRate() throws Exception { + assertEquals( (float)15, ic.getInterestRate() ); + } + + public void testSetInterestRate() throws Exception { + ic.setInterestRate(16); + assertEquals( (float)16, ic.getInterestRate() ); + } + + public void testResetCapital() throws Exception { + ic.calculateCapital(1); + assertEquals( (float)115, ic.getCurrentCapital() ); + ic.resetCapital(); + assertEquals( (float)100, ic.getCurrentCapital() ); + } + +} // class InterestCalculatorTest Property changes on: trunk/src/test/net/sf/japi/finance/InterestCalculatorTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-08-13 20:47:05
|
Revision: 134 Author: christianhujer Date: 2006-08-13 13:46:49 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=134&view=rev Log Message: ----------- Added first version of yet another Logging API. Added Paths: ----------- trunk/src/app/net/sf/japi/log/ trunk/src/app/net/sf/japi/log/Level.java trunk/src/app/net/sf/japi/log/LogConfigurationError.java trunk/src/app/net/sf/japi/log/LogEntry.java trunk/src/app/net/sf/japi/log/Logger.java trunk/src/app/net/sf/japi/log/LoggerFactory.java trunk/src/app/net/sf/japi/log/package.html Added: trunk/src/app/net/sf/japi/log/Level.java =================================================================== --- trunk/src/app/net/sf/japi/log/Level.java (rev 0) +++ trunk/src/app/net/sf/japi/log/Level.java 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,45 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.log; + +/** + * Enumeration of log levels. + * <p /> + * JAPI Logging knows six logging levels: + * <ol> + * <li>trace (the least serious)</li> + * <li>debug</li> + * <li>info</li> + * <li>warn</li> + * <li>error</li> + * <li>fatal (the most serious)</li> + * </ol> + * It's regarded a feature that JAPI Logging is simple and only knows exactly these six levels. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public enum Level { + + // The ordinal of the enums is used for determining the log level. + // Therefore the order of these enum constants MUST NOT be changed. + TRACE, DEBUG, INFO, WARN, ERROR, FATAL + +} // enum Level Property changes on: trunk/src/app/net/sf/japi/log/Level.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/japi/log/LogConfigurationError.java =================================================================== --- trunk/src/app/net/sf/japi/log/LogConfigurationError.java (rev 0) +++ trunk/src/app/net/sf/japi/log/LogConfigurationError.java 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,64 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.log; + +/** + * This error is thrown when a configuration error prevented a Logger from being created. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class LogConfigurationError extends Error { + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** + * Create a LogConfigurationError without message. + */ + public LogConfigurationError() { + } + + /** + * Create a LogConfigurationError with a message. + * @param msg Message + */ + public LogConfigurationError(final String msg) { + super(msg); + } + + /** + * Create a LogConfigurationError with a cause. + * @param cause Cause + */ + public LogConfigurationError(final Throwable cause) { + super(cause); + } + + /** + * Create a LogConfigurationError with a message and a cause. + * @param cause Cause + * @param msg Message + */ + public LogConfigurationError(final String msg, final Throwable cause) { + super(msg, cause); + } + +} // class LogConfigurationError Property changes on: trunk/src/app/net/sf/japi/log/LogConfigurationError.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/japi/log/LogEntry.java =================================================================== --- trunk/src/app/net/sf/japi/log/LogEntry.java (rev 0) +++ trunk/src/app/net/sf/japi/log/LogEntry.java 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,170 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +package net.sf.japi.log; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A LogEntry is a single log element. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class LogEntry { + + /** The log message. */ + @NotNull private final String message; + + /** The log level. */ + @NotNull private final Level level; + + /** The throwable. */ + @Nullable private final Throwable cause; + + /** The timestamp. */ + private final long timestamp; + + /** The StackTraceElement of the invoking method. */ + @NotNull private final StackTraceElement invokingMethod; + + /** The filename. */ + @Nullable private final String filename; + + /** The line number. */ + private final int lineNumber; + + /** The class name. */ + @NotNull private final String className; + + /** The method name. */ + @NotNull private final String methodName; + + /** + * Create a LogEntry. + * @param level Level + * @param message Message + * @param cause Throwable + */ + public LogEntry(@NotNull final Level level, @NotNull final String message, @Nullable final Throwable cause) { + timestamp = System.currentTimeMillis(); + this.level = level; + this.message = message; + this.cause = cause; + invokingMethod = findInvokingMethod(); + filename = invokingMethod.getFileName(); + lineNumber = invokingMethod.getLineNumber(); + className = invokingMethod.getClassName(); + methodName = invokingMethod.getMethodName(); + } + + /** + * Finds the invoking method. + * @return invoking method + */ + private StackTraceElement findInvokingMethod() { + final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + int i = 0; + try { + while (!stackTrace[i].getClassName().startsWith("net.sf.japi.log.")) { + i++; + } + while (stackTrace[i].getClassName().startsWith("net.sf.japi.log.")) { + i++; + } + return stackTrace[i]; + } catch (final ArrayIndexOutOfBoundsException e) { + assert false; + throw new Error("Couldn'cause find StackTraceElement."); + } + } + + /** + * Get the log message. + * @return log message + */ + @NotNull public String getMessage() { + return message; + } + + /** + * Get the log level. + * @return log level + */ + @NotNull public Level getLevel() { + return level; + } + + /** + * Get the cause of this log entry. + * @return cause or <code>null</code> if no cause + */ + @Nullable public Throwable getCause() { + return cause; + } + + /** + * Get the time stamp of this log entry. + * @return time stamp + */ + public long getTimestamp() { + return timestamp; + } + + /** + * Get the invoking method. + * @return invoking method + */ + @NotNull public StackTraceElement getInvokingMethod() { + return invokingMethod; + } + + /** + * Get the source filename that caused this log entry. + * @return source filename or <code>null</code> if unavailable + */ + @Nullable public String getFilename() { + return filename; + } + + /** + * Get the source linenumber that caused this log entry. + * @return source linenumber or a negative number if unavailable + */ + public int getLineNumber() { + return lineNumber; + } + + /** + * Get the class name that caused this log entry. + * @return class name + */ + @NotNull public String getClassName() { + return className; + } + + /** + * Get the method name that caused this log entry. + * @return method name + */ + @NotNull public String getMethodName() { + return methodName; + } + +} // class LogEntry Property changes on: trunk/src/app/net/sf/japi/log/LogEntry.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/japi/log/Logger.java =================================================================== --- trunk/src/app/net/sf/japi/log/Logger.java (rev 0) +++ trunk/src/app/net/sf/japi/log/Logger.java 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,97 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.log; + +import java.util.ResourceBundle; + +/** + * Logger is a logger which logs to {@link System#err}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class Logger { + + /** The minimum enabled level. */ + private Level enabledLevel = Level.ERROR; // TODO: Get this from somewhere + + /** The ResourceBundle to get messages from. */ + private final ResourceBundle bundle; + + /** + * Create a Logger. + * @param name Name of the logger, used for retrieving the resource bundle + */ + public Logger(final String name) { + bundle = ResourceBundle.getBundle(name); + } + + /** {@inheritDoc} */ + public void log(final Level level, final String key) { + if (level.ordinal() >= enabledLevel.ordinal()) { + logImpl(level, null, bundle.getString(key)); + } + } + + /** {@inheritDoc} */ + public void log(final Level level, final String key, final Object... params) { + if (level.ordinal() >= enabledLevel.ordinal()) { + // TODO: alternatively use MessageFormat + logImpl(level, null, String.format(bundle.getString(key), params)); + } + } + + /** {@inheritDoc} */ + public void log(final Level level, final Throwable t, final String key) { + if (level.ordinal() >= enabledLevel.ordinal()) { + logImpl(level, t, bundle.getString(key)); + } + } + + /** {@inheritDoc} */ + public void log(final Level level, final Throwable t, final String key, final Object... params) { + if (level.ordinal() >= enabledLevel.ordinal()) { + // TODO: alternatively use MessageFormat + logImpl(level, t, String.format(bundle.getString(key), params)); + } + } + + /** {@inheritDoc} */ + public void setLevel(final Level level) { + enabledLevel = level; + } + + /** {@inheritDoc} */ + public boolean isEnabled(final Level level) { + return level.ordinal() >= enabledLevel.ordinal(); + } + + /** + * Format and print a log message. + * @param level Log Level + * @param t Throwable to log (maybe null) + * @param message Message to log + */ + private void logImpl(final Level level, final Throwable t, final String message) { + final LogEntry logEntry = new LogEntry(level, message, t); + System.err.format("%s:%d: %s: %s %s", logEntry.getFilename(), logEntry.getLineNumber(), level, t, message); + } + +} // class Logger Property changes on: trunk/src/app/net/sf/japi/log/Logger.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/japi/log/LoggerFactory.java =================================================================== --- trunk/src/app/net/sf/japi/log/LoggerFactory.java (rev 0) +++ trunk/src/app/net/sf/japi/log/LoggerFactory.java 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,129 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.log; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.HashMap; +import static java.lang.Class.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * The LoggerFactory is used to instanciate a Logger of a specific implementation. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class LoggerFactory { + + /** Singleton Instance. */ + @NotNull public static final LoggerFactory INSTANCE = new LoggerFactory(); + + /** + * The implementations. + * Key: logger name, as with {@link java.util.logging.LogManager#getLogger(String)}. + * Value: Logger associated with the Key + */ + @NotNull private Map<String, Logger> loggers = new HashMap<String, Logger>(); + + /** + * Private Singleton Constructor. + */ + private LoggerFactory() { + } + + /** + * Method to find a named logger. + * @param name Name of the logger to find + * @return matching logger (a new logger will be created if none could be found) + * @throws LogConfigurationError in case the logger couldn't be created + */ + @NotNull public Logger getLogger(final String name) throws LogConfigurationError { + @Nullable Logger logger = loggers.get(name); + if (logger == null) { + logger = createLogger(name); + loggers.put(name, logger); + } + return logger; + } + + /** + * Convenience method to find a named logger. + * This is the same as calling {@link #getLogger(String)} with <code>c.getName()</code> as argument. + * @param c Class name of the Logger to find + * @return matching logger (a new logger will be created if none could be found) + * @throws LogConfigurationError in case the logger couldn't be created + */ + @NotNull public Logger getLogger(final Class c) throws LogConfigurationError { + return getLogger(c.getName()); + } + + /** + * Creates a Logger. + * @param name Name for the logger to create + * @return matching logger + * @throws LogConfigurationError in case the logger couldn't be created + */ + @NotNull private Logger createLogger(final String name) throws LogConfigurationError { + // 1 Find configuration for name + // 1a Find explicit configuration for name + // 1b Use default configuration for name + // 2 Use configuration to instanciate Logger + @NotNull final String loggerClassName = getLoggerClassName(name); + try { + //noinspection unchecked + final Class<? extends Logger> loggerClass = (Class<? extends Logger>) forName(loggerClassName); + final Constructor<? extends Logger> constructor = loggerClass.getConstructor(String.class); + return constructor.newInstance(name); + } catch (final InstantiationException e) { + throw new LogConfigurationError("Logger class not instantiatable.", e); + } catch (final IllegalAccessException e) { + throw new LogConfigurationError("Logger class or it's constructor not accessible.", e); + } catch (final ClassNotFoundException e) { + throw new LogConfigurationError("Logger class not found while instantiating logger.", e); + } catch (final ClassCastException e) { + throw new LogConfigurationError("Specified Logger class doesn't implement net.sf.japi.log.Logger interface.", e); + } catch (final ExceptionInInitializerError e) { + throw new LogConfigurationError("Exception in Initializer during Logger instantiation.", e.getException()); + } catch (final NoSuchMethodException e) { + throw new LogConfigurationError("Specified Logger class doesn't provide a constructor of type (String).", e); + } catch (final InvocationTargetException e) { + throw new LogConfigurationError("Exception in Constructor during Logger instantiation.", e.getTargetException()); + } catch (final IllegalArgumentException e) { + // This shouldn't happen because if we get a constructor of type String and then use it of type String there shouldn't be any problems. + assert false; + throw new Error(e); + } + } + + /** + * Finds the class name of the logger that should be used for a specific name. + * @param name Name of the logger the class name should be found for + * @return class name of the logger for <var>name</var> + */ + @NotNull private String getLoggerClassName(final String name) { + // Currently, simply return the system property + return System.getProperty("net.sf.japi.Logger", "net.sf.japi.Logger"); + } + +} // class LogFactory Property changes on: trunk/src/app/net/sf/japi/log/LoggerFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/japi/log/package.html =================================================================== --- trunk/src/app/net/sf/japi/log/package.html (rev 0) +++ trunk/src/app/net/sf/japi/log/package.html 2006-08-13 20:46:49 UTC (rev 134) @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<!-- + ~ JAPI - (Yet another (hopefully) useful) Java API + ~ + ~ Copyright (C) 2006 Christian Hujer + ~ + ~ This program is free software; you can redistribute it and/or + ~ modify it under the terms of the GNU General Public License as + ~ published by the Free Software Foundation; either version 2 of the + ~ License, or (at your option) any later version. + ~ + ~ This program is distributed in the hope that it will be useful, but + ~ WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License + ~ along with this program; if not, write to the Free Software + ~ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + ~ 02111-1307, USA. + --> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Package net.sf.japi.log</title> + </head> + <body> + <p> + <code>net.sf.japi.log</code> provides a simple framework for logging. + Underlying implementations can map the actual logging that occurs to other frameworks like <code>java.util.logging</code> or Log4J. + </p> + <p> + Currently nothing but a simple logging facility to log to STDOUT is provided. + Future versions will include more logging facilities. + </p> + </body> +</html> Property changes on: trunk/src/app/net/sf/japi/log/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |