From 93e26b06b1965b918f0506e778338fefdf18fa22 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 21 Feb 2002 09:23:59 +0000 Subject: [PATCH] Remove old attempt at generalizing the converter architecture git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271464 13f79535-47bb-0310-9956-ffa450edef68 --- .../aut/converter/AbstractConverter.java | 82 ------------------- .../org/apache/aut/converter/Converter.java | 34 -------- .../aut/converter/ConverterContext.java | 24 ------ .../aut/converter/ConverterException.java | 42 ---------- .../apache/aut/converter/Resources.properties | 2 - 5 files changed, 184 deletions(-) delete mode 100644 proposal/myrmidon/src/java/org/apache/aut/converter/AbstractConverter.java delete mode 100644 proposal/myrmidon/src/java/org/apache/aut/converter/Converter.java delete mode 100644 proposal/myrmidon/src/java/org/apache/aut/converter/ConverterContext.java delete mode 100644 proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java delete mode 100644 proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties diff --git a/proposal/myrmidon/src/java/org/apache/aut/converter/AbstractConverter.java b/proposal/myrmidon/src/java/org/apache/aut/converter/AbstractConverter.java deleted file mode 100644 index 4cb019023..000000000 --- a/proposal/myrmidon/src/java/org/apache/aut/converter/AbstractConverter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.aut.converter; - -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.excalibur.i18n.Resources; - -/** - * Instances of this interface are used to convert between different types. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public abstract class AbstractConverter - implements Converter -{ - private final static Resources REZ = - ResourceManager.getPackageResources( AbstractConverter.class ); - - private final Class m_source; - private final Class m_destination; - - /** - * Constructor for a converter between types source and destination - * - * @param source the source type - * @param destination the destination type - */ - public AbstractConverter( final Class source, final Class destination ) - { - m_source = source; - m_destination = destination; - } - - /** - * Convert an object from original to destination types - * - * @param destination the destination type - * @param original the original Object - * @param context the context in which to convert - * @return the converted object - * @exception ConverterException if an error occurs - */ - public Object convert( final Class destination, - final Object original, - final ConverterContext context ) - throws ConverterException - { - if( m_destination != destination ) - { - final String message = - REZ.getString( "bad-destination.error", destination.getName(), m_destination ); - throw new IllegalArgumentException( message ); - } - - if( !m_source.isInstance( original ) ) - { - final String message = - REZ.getString( "bad-instance.error", original, m_source.getName() ); - throw new IllegalArgumentException( message ); - } - - return convert( original, context ); - } - - /** - * Overide this in a particular converter to do the conversion. - * - * @param original the original Object - * @param context the context in which to convert - * @return the converted object - * @exception ConverterException if an error occurs - */ - protected abstract Object convert( Object original, ConverterContext context ) - throws ConverterException; -} - diff --git a/proposal/myrmidon/src/java/org/apache/aut/converter/Converter.java b/proposal/myrmidon/src/java/org/apache/aut/converter/Converter.java deleted file mode 100644 index f20f6f72e..000000000 --- a/proposal/myrmidon/src/java/org/apache/aut/converter/Converter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.aut.converter; - -/** - * Instances of this interface are used to convert between different types. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant:role shorthand="converter" - */ -public interface Converter -{ - String ROLE = Converter.class.getName(); - - /** - * Convert original to destination type. - * Destination is passed so that one converter can potentiall - * convert to multiple different types. - * - * @param destination the destinaiton type - * @param original the original type - * @param context the context in which to convert - * @return the converted object - * @exception ConverterException if an error occurs - */ - Object convert( Class destination, Object original, ConverterContext context ) - throws ConverterException; -} diff --git a/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterContext.java b/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterContext.java deleted file mode 100644 index c0369d127..000000000 --- a/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterContext.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.aut.converter; - -/** - * The context in which objects can be converted from one type to another type. - * - * @author Peter Donald - * @version $Revision$ $Date$ - * @ant:role shorthand="converter" - */ -public interface ConverterContext -{ - /** - * Retrieve a vlaue from the context with the specified key. - * Will return null if no such value exists. - */ - Object get( Object key ); -} diff --git a/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java b/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java deleted file mode 100644 index e483cfbeb..000000000 --- a/proposal/myrmidon/src/java/org/apache/aut/converter/ConverterException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.aut.converter; - -import org.apache.avalon.framework.CascadingException; - -/** - * ConverterException thrown when a problem occurs during convertion etc. - * - * @author Peter Donald - * @version $Revision$ $Date$ - */ -public class ConverterException - extends CascadingException -{ - /** - * Basic constructor with a message - * - * @param message the message - */ - public ConverterException( final String message ) - { - this( message, null ); - } - - /** - * Constructor that builds cascade so that other exception information can be retained. - * - * @param message the message - * @param throwable the throwable - */ - public ConverterException( final String message, final Throwable throwable ) - { - super( message, throwable ); - } -} - diff --git a/proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties b/proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties deleted file mode 100644 index d912151b4..000000000 --- a/proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties +++ /dev/null @@ -1,2 +0,0 @@ -bad-destination.error=Destination type ({0}) is not equal to {1}. -bad-instance.error=Object {0} is not an instance of {1}.