colus 02/02/06 05:35:34
Modified: src/java/org/apache/avalon/excalibur/logger/factory
FileTargetFactory.java
Log:
Fixed misstyping in javadoc.
Revision Changes Path
1.9 +72 -72
jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.java
Index: FileTargetFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/logger/factory/FileTargetFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FileTargetFactory.java 19 Dec 2001 23:34:50 -0000 1.8
+++ FileTargetFactory.java 6 Feb 2002 13:35:34 -0000 1.9
@@ -56,7 +56,7 @@
* <time>24:00:00</time>
* <time>12:00:00</time>
* </or>
- * </rotate>
+ * </rotation>
* </file>
* </pre>
*
@@ -70,7 +70,7 @@
* </dd>
* <dt><format></dt>
* <dd>
- * The type attribute of the pattern element denotes the type of
+ * The type attribute of the pattern element denotes the type of
* Formatter to be used and according to it the pattern to use for.
* This elements defaults to:
* <p>
@@ -86,10 +86,10 @@
* <dt><rotation></dt>
* <dd>
* This is an optional element.
- * The type attribute determines which FileStrategy to user
+ * The type attribute determines which FileStrategy to user
* (revolving=RevolvingFileStrategy, unique=UniqueFileStrategy).
- * The required init and max attribute are used to determine the initial
and
- * maximum rotation to use on a type="revolving" attribute.
+ * The required init and max attribute are used to determine the initial
and
+ * maximum rotation to use on a type="revolving" attribute.
* The optional pattern and suffix attribute are used to form filenames on
* a type="unique" attribute.
* </dd>
@@ -97,8 +97,8 @@
* <dd>uses the OrRotateStrategy to combine the children</dd>
* <dt><size></dt>
* <dd>
- * The number of bytes if no suffix used or kilo bytes (1024) if suffixed
with
- * 'k' or mega bytes (1024k) if suffixed with 'm' when a file rotation
should
+ * The number of bytes if no suffix used or kilo bytes (1024) if suffixed
with
+ * 'k' or mega bytes (1024k) if suffixed with 'm' when a file rotation
should
* occur. It doesn't make sense to specify more than one.
* </dd>
* <dt><time></dt>
@@ -111,51 +111,51 @@
* </dl>
*
* @author <a href="mailto:[EMAIL PROTECTED],org">Giacomo Pati</a>
- * @version CVS $Revision: 1.8 $ $Date: 2001/12/19 23:34:50 $
+ * @version CVS $Revision: 1.9 $ $Date: 2002/02/06 13:35:34 $
* @since 4.0
*/
-public class FileTargetFactory
- extends AbstractTargetFactory
+public class FileTargetFactory
+ extends AbstractTargetFactory
{
/**
* Create a LogTarget based on a Configuration
*/
- public final LogTarget createTarget( final Configuration configuration )
+ public final LogTarget createTarget( final Configuration configuration )
throws ConfigurationException
{
final Configuration conf_filename = configuration.getChild(
"filename" );
final String filename = getFilename( conf_filename.getValue() );
-
+
final Configuration conf_rotation = configuration.getChild(
"rotation", false );
-
+
final Configuration conf_format = configuration.getChild( "format" );
final Configuration conf_append = configuration.getChild( "append" );
final boolean append = conf_append.getValueAsBoolean( false );
-
+
final LogTarget logtarget;
-
+
final File file = new File( filename );
final Formatter formatter = getFormatter( conf_format );
-
- try
+
+ try
{
- if( null == conf_rotation )
+ if( null == conf_rotation )
{
logtarget = new FileTarget( file, append, formatter );
}
- else
- {
+ else
+ {
final Configuration conf_strategy =
conf_rotation.getChildren()[0];
final RotateStrategy rotateStrategy = getRotateStrategy(
conf_strategy );
final FileStrategy fileStrategy = getFileStrategy(
conf_rotation, file );
-
- logtarget =
+
+ logtarget =
new RotatingFileTarget( formatter, rotateStrategy,
fileStrategy );
}
}
- catch( final IOException ioe )
+ catch( final IOException ioe )
{
throw new ConfigurationException( "cannot create FileTarget",
ioe );
}
@@ -171,33 +171,33 @@
private final static long KILOBYTE = 1000;
private final static long MEGABYTE = 1000*KILOBYTE;
- private RotateStrategy getRotateStrategy( final Configuration conf )
+ private RotateStrategy getRotateStrategy( final Configuration conf )
{
final String type = conf.getName();
-
+
if( "or".equals( type ) )
{
- final Configuration[] configurations = conf.getChildren();
+ final Configuration[] configurations = conf.getChildren();
final int size = configurations.length;
-
- final RotateStrategy[] strategies = new RotateStrategy[size];
+
+ final RotateStrategy[] strategies = new RotateStrategy[size];
for( int i = 0; i < size; i++ )
{
strategies[i] = getRotateStrategy( configurations[i] );
}
-
- return new OrRotateStrategy( strategies );
+
+ return new OrRotateStrategy( strategies );
}
-
- if( "size".equals( type ) )
+
+ if( "size".equals( type ) )
{
final String value = conf.getValue( "2m" );
-
+
final int count = value.length();
final char end = value.charAt( count-1 );
final long no;
final long size;
-
+
switch( end )
{
case 'm':no = Long.parseLong( value.substring( 0, count-1 )
);
@@ -208,10 +208,10 @@
break;
default: size = Long.parseLong( value );
}
-
+
return new RotateStrategyBySize( size );
}
-
+
// default rotate strategy
final String value = conf.getValue( "24:00:00" );
@@ -222,60 +222,60 @@
for( int i = count; i > 0; i-- )
{
final long no = Long.parseLong( tokenizer.nextToken() );
- if( 4 == i )
- {
+ if( 4 == i )
+ {
time += no * DAY;
}
- if( 3 == i )
- {
+ if( 3 == i )
+ {
time += no * HOUR;
}
- if( 2 == i )
- {
+ if( 2 == i )
+ {
time += no * MINUTE;
}
- if( 1 == i )
- {
+ if( 1 == i )
+ {
time += no * SECOND;
}
}
- return new RotateStrategyByTime( time );
- }
-
- protected FileStrategy getFileStrategy( final Configuration conf, final
File file )
- {
+ return new RotateStrategyByTime( time );
+ }
+
+ protected FileStrategy getFileStrategy( final Configuration conf, final
File file )
+ {
final String type = conf.getAttribute( "type", "unique" );
-
+
if( "revolving".equals( type ) )
{
- final int initialRotation =
- conf.getAttributeAsInteger( "init", 5 );
- final int maxRotation =
- conf.getAttributeAsInteger( "max", 10 );
-
+ final int initialRotation =
+ conf.getAttributeAsInteger( "init", 5 );
+ final int maxRotation =
+ conf.getAttributeAsInteger( "max", 10 );
+
return new RevolvingFileStrategy( file, initialRotation,
maxRotation );
}
-
+
// default file strategy
- final String pattern = conf.getAttribute( "pattern", null );
- final String suffix = conf.getAttribute( "suffix", null );
+ final String pattern = conf.getAttribute( "pattern", null );
+ final String suffix = conf.getAttribute( "suffix", null );
if( pattern == null)
{
return new UniqueFileStrategy( file );
- }
- else
+ }
+ else
{
- if( suffix == null )
+ if( suffix == null )
{
return new UniqueFileStrategy( file, pattern );
- }
- else
+ }
+ else
{
return new UniqueFileStrategy( file, pattern, suffix );
}
- }
- }
+ }
+ }
protected Formatter getFormatter( final Configuration conf )
{
@@ -286,12 +286,12 @@
final FormatterFactory formatterFactory = new FormatterFactory();
formatter = formatterFactory.createFormatter( conf );
}
-
+
return formatter;
}
- /**
- * Process the file name
+ /**
+ * Process the file name
*
* This method scans the file name passed for occurrences of
* ${foo}. Those strings get replaced by values from the Context object
@@ -299,7 +299,7 @@
*
* @param rawFilename The filename with substitutable placeholders
* @return The processed file name
- * @exception ConfigurationException if substitutable values are not in
the
+ * @exception ConfigurationException if substitutable values are not in
the
* Context object.
*/
protected final String getFilename( String rawFilename )
@@ -310,15 +310,15 @@
int j = -1;
while( ( j = rawFilename.indexOf( "${", i ) ) > -1 )
{
- if( i < j )
+ if( i < j )
{
sb.append( rawFilename.substring( i, j ) );
}
- int k = rawFilename.indexOf( '}', j );
+ int k = rawFilename.indexOf( '}', j );
final String ctx_name = rawFilename.substring( j + 2, k );
final Object ctx;
try
- {
+ {
ctx = m_context.get( ctx_name );
}
catch( final ContextException ce )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>