Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 90858 invoked from network); 14 Nov 2002 18:48:53 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 14 Nov 2002 18:48:53 -0000 Received: (qmail 18488 invoked by uid 97); 14 Nov 2002 18:49:31 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 18378 invoked by uid 97); 14 Nov 2002 18:49:30 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 22824 invoked by uid 98); 14 Nov 2002 17:53:07 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Content-Type: text/plain; charset="iso-8859-1" From: Janek Bogucki Reply-To: yan@studylink.com To: "Jakarta Commons Developers List" Subject: Re: Conversion utilities Date: Thu, 14 Nov 2002 17:52:02 +0000 X-Mailer: KMail [version 1.2] References: <1382604.1037247667875.JavaMail.SYSTEM@bodisafa> In-Reply-To: <1382604.1037247667875.JavaMail.SYSTEM@bodisafa> MIME-Version: 1.0 Message-Id: <02111410584001.00971@bogucki.demon.co.uk> Content-Transfer-Encoding: 8bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi Travis, On Thursday 14 November 2002 4:21 am, travis@thinkvirtual.com wrote: > I also have a package of conversion classes that convert different > measurements from imperial to metric and vice versa for things like Length, > Pressure, Force, etc. > > And along with that I have a Fraction and FractionFormat class that deals > with fractions (parsing, formatting, etc). > > Wonder if commons might be a good fit for that? > > Travis Reeder > > > -- > To unsubscribe, e-mail: > For additional > commands, e-mail: Let me add some more stuff that might be the basis for something. I need to represent currency ranges (in various currencies using the ISO 4217 currency codes), and duration ranges (with various units: hours, days, months, years). I imagine the CurrencyRange would go like this CONCEPTUAL API: public interface CurrencyRange { // --------------------------- // Property Getters // --------------------------- Currency getCurrency(); o.a.c.lang.NumberRange getRange (); } The Currency class would be similar to java.util.Currency, but would be available for JDK 1.3.1 users (me). CurrencyRange would be immutable and possibly final (I've sketched it as an interface above for discussion). Since my needs are completely covered by the two properties above I have not added any further operations. The DurationRange would be similar: CONCEPTUAL APIs: public interface DurationRange { // --------------------------- // Property Getters // --------------------------- DurationUnitEnum getUnit(); o.a.c.lang.NumberRange getRange (); } The constructor could be like this DurationRange ( DurationUnitEnum, NumberRange range ) ; (Once again DurationRange is likely to be a final class, not an interface.) Travis' CalenderUtils.getRange ( int field, Date from, Date to ) method could be used in a factory method on DurationRange /** * Return a DurationRange where min==max and min == to - from, and field is * from Calender. */ public static DurationRange getInstance ( int field, Date from, Date to ) /** * Return a DurationRange where field is from Calender. */ public static DurationRange getInstance ( int field, long min, long ) ; For DurationUnitEnum: import java.util.Calendar ; public final class DurationUnitEnum extends ValuedEnum { // enums based on code in Travis' CalendarUtils.getRange public static final int DURATION_UNIT_SECOND_VALUE = Calendar.SECOND ; public static final int DURATION_UNIT_MINUTE_VALUE = Calendar.MINUTE ; public static final int DURATION_UNIT_HOUR_VALUE = Calendar.HOUR ; public static final int DURATION_UNIT_DAY_VALUE = Calendar.DAY ; public static final int DURATION_UNIT_WEEK_VALUE = Calendar.WEEK ; public static final int DURATION_UNIT_MONTH_VALUE = Calendar.MONTH ; public static final int DURATION_UNIT_YEAR_VALUE = Calendar.YEAR ; public static final DurationUnitEnum DURATION_UNIT_SECOND = new DurationUnitEnum ( "Seconds", DURATION_UNIT_SECOND_VALUE ); public static final DurationUnitEnum DURATION_UNIT_YEAR = new DurationUnitEnum ( "Years", DURATION_UNIT_YEAR_VALUE ); private DurationUnitEnum name, int value) { super( name, value ); } public static DurationUnitEnum getEnum(String durationUnit) { return (DurationUnitEnum) getEnum(DurationUnitEnum.class, durationUnit); } public static DurationUnitEnum getEnum(int durationUnit) { return (DurationUnitEnum) getEnum(DurationUnitEnum.class, durationUnit); } public static Map getEnumMap() { return getEnumMap(DurationUnitEnum.class); } public static List getEnumList() { return getEnumList(DurationUnitEnum.class); } public static Iterator iterator() { return iterator(DurationUnitEnum.class); } } I'd be happy to contribute the basic attempt at CurrencyRange, if there is interest and it doesn't overlap with anything else already in existance. If anyone can point at a quantities library with this in already i'd be very happy. -Janek -- To unsubscribe, e-mail: For additional commands, e-mail: