Browse Source

i18n'ed TaskContext implementation.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269646 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
f09afe103c
2 changed files with 33 additions and 16 deletions
  1. +24
    -15
      proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  2. +9
    -1
      proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties

+ 24
- 15
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java View File

@@ -9,6 +9,8 @@ package org.apache.myrmidon.components.workspace;


import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.excalibur.io.FileUtil; import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.excalibur.property.PropertyException; import org.apache.avalon.excalibur.property.PropertyException;
import org.apache.avalon.excalibur.property.PropertyUtil; import org.apache.avalon.excalibur.property.PropertyUtil;
@@ -27,6 +29,9 @@ public class DefaultTaskContext
extends DefaultContext extends DefaultContext
implements TaskContext implements TaskContext
{ {
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultTaskContext.class );

/** /**
* Constructor for Context with no parent contexts. * Constructor for Context with no parent contexts.
*/ */
@@ -61,7 +66,8 @@ public class DefaultTaskContext
try { return (JavaVersion)get( JAVA_VERSION ); } try { return (JavaVersion)get( JAVA_VERSION ); }
catch( final ContextException ce ) catch( final ContextException ce )
{ {
throw new IllegalStateException( "No JavaVersion in Context" );
final String message = REZ.getString( "no-version.error" );
throw new IllegalStateException( message );
} }
} }


@@ -76,7 +82,8 @@ public class DefaultTaskContext
try { return (String)get( NAME ); } try { return (String)get( NAME ); }
catch( final ContextException ce ) catch( final ContextException ce )
{ {
throw new IllegalStateException( "No Name in Context" );
final String message = REZ.getString( "no-name.error" );
throw new IllegalStateException( message );
} }
} }


@@ -90,7 +97,8 @@ public class DefaultTaskContext
try { return (File)get( BASE_DIRECTORY ); } try { return (File)get( BASE_DIRECTORY ); }
catch( final ContextException ce ) catch( final ContextException ce )
{ {
throw new IllegalStateException( "No Base Directory in Context" );
final String message = REZ.getString( "no-dir.error" );
throw new IllegalStateException( message );
} }
} }


@@ -151,8 +159,8 @@ public class DefaultTaskContext
{ {
if( null == getParent() ) if( null == getParent() )
{ {
throw new TaskException( "Can't set a property with parent scope when context " +
" has no parent" );
final String message = REZ.getString( "no-parent.error" );
throw new TaskException( message );
} }
else else
{ {
@@ -172,7 +180,8 @@ public class DefaultTaskContext
} }
else else
{ {
throw new IllegalStateException( "Unknown property scope! (" + scope + ")" );
final String message = REZ.getString( "bad-scope.error", scope );
throw new IllegalStateException( message );
} }
} }


@@ -208,21 +217,21 @@ public class DefaultTaskContext
{ {
if( BASE_DIRECTORY.equals( name ) && !( value instanceof File ) ) if( BASE_DIRECTORY.equals( name ) && !( value instanceof File ) )
{ {
throw new TaskException( "Property " + BASE_DIRECTORY +
" must have a value of type " +
File.class.getName() );
final String message =
REZ.getString( "bad-property.error", BASE_DIRECTORY, File.class.getName() );
throw new TaskException( message );
} }
else if( NAME.equals( name ) && !( value instanceof String ) ) else if( NAME.equals( name ) && !( value instanceof String ) )
{ {
throw new TaskException( "Property " + NAME +
" must have a value of type " +
String.class.getName() );
final String message =
REZ.getString( "bad-property.error", NAME, String.class.getName() );
throw new TaskException( message );
} }
else if( JAVA_VERSION.equals( name ) && !( value instanceof JavaVersion ) ) else if( JAVA_VERSION.equals( name ) && !( value instanceof JavaVersion ) )
{ {
throw new TaskException( "Property " + JAVA_VERSION +
" must have a value of type " +
JavaVersion.class.getName() );
final String message =
REZ.getString( "bad-property.error", JAVA_VERSION, JavaVersion.class.getName() );
throw new TaskException( message );
} }
} }
} }

+ 9
- 1
proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties View File

@@ -8,4 +8,12 @@ no-target.error=Target {0} not found.
skip-target.notice=Skipping target {0} as it does not satisfy condition. skip-target.notice=Skipping target {0} as it does not satisfy condition.
condition-eval.error=Error evaluating Condition for target {0}. condition-eval.error=Error evaluating Condition for target {0}.
exec-target.notice=Executing target {0}. exec-target.notice=Executing target {0}.
exec-task.notice=Executing task {0}.
exec-task.notice=Executing task {0}.

#DefaultTaskContext
no-version.error=No JavaVersion in Context.
no-name.error=No Name in Context.
no-dir.error=No Base Directory in Context.
no-parent.error=Can't set a property with parent scope when context has no parent.
bad-scope.error=Unknown property scope! ({0}).
bad-property.error=Property {0} must have a value of type {1}.

Loading…
Cancel
Save