From f09afe103c9bd8540483fbdafab92df1cdf049e2 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 29 Aug 2001 16:01:51 +0000 Subject: [PATCH] i18n'ed TaskContext implementation. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269646 13f79535-47bb-0310-9956-ffa450edef68 --- .../workspace/DefaultTaskContext.java | 39 ++++++++++++------- .../components/workspace/Resources.properties | 10 ++++- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java index 6b9c3c324..a0982ff53 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java @@ -9,6 +9,8 @@ package org.apache.myrmidon.components.workspace; import java.io.File; 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.property.PropertyException; import org.apache.avalon.excalibur.property.PropertyUtil; @@ -27,6 +29,9 @@ public class DefaultTaskContext extends DefaultContext implements TaskContext { + private static final Resources REZ = + ResourceManager.getPackageResources( DefaultTaskContext.class ); + /** * Constructor for Context with no parent contexts. */ @@ -61,7 +66,8 @@ public class DefaultTaskContext try { return (JavaVersion)get( JAVA_VERSION ); } 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 ); } 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 ); } 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() ) { - 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 { @@ -172,7 +180,8 @@ public class DefaultTaskContext } 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 ) ) { - 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 ) ) { - 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 ) ) { - 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 ); } } } diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties index 15f3f1da9..8f75f3430 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/workspace/Resources.properties @@ -8,4 +8,12 @@ no-target.error=Target {0} not found. skip-target.notice=Skipping target {0} as it does not satisfy condition. condition-eval.error=Error evaluating Condition for target {0}. exec-target.notice=Executing target {0}. -exec-task.notice=Executing task {0}. \ No newline at end of file +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}. \ No newline at end of file