Browse Source

i18n'ed Converter APIs.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269650 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
1125ea2c35
2 changed files with 13 additions and 4 deletions
  1. +11
    -4
      proposal/myrmidon/src/java/org/apache/myrmidon/converter/AbstractConverter.java
  2. +2
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/converter/Resources.properties

+ 11
- 4
proposal/myrmidon/src/java/org/apache/myrmidon/converter/AbstractConverter.java View File

@@ -7,6 +7,8 @@
*/
package org.apache.myrmidon.converter;

import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.context.Context;

/**
@@ -17,6 +19,9 @@ import org.apache.avalon.framework.context.Context;
public abstract class AbstractConverter
implements Converter
{
private static final Resources REZ =
ResourceManager.getPackageResources( AbstractConverter.class );

private final Class m_source;
private final Class m_destination;

@@ -46,14 +51,16 @@ public abstract class AbstractConverter
{
if( m_destination != destination )
{
throw new IllegalArgumentException( "Destination type " + destination.getName() +
" is not equal to " + m_destination );
final String message =
REZ.getString( "bad-destination.error", destination.getName(), m_destination );
throw new IllegalArgumentException( message );
}

if( !m_source.isInstance( original ) )
{
throw new IllegalArgumentException( "Object '" + original + "' is not an " +
"instance of " + m_source.getName() );
final String message =
REZ.getString( "bad-instance.error", original, m_source.getName() );
throw new IllegalArgumentException( message );
}

return convert( original, context );


+ 2
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/converter/Resources.properties View File

@@ -0,0 +1,2 @@
bad-destination.error=Destination type ({0}) is not equal to {1}.
bad-instance.error=Object {0} is not an instance of {1}.

Loading…
Cancel
Save