Return-Path: Delivered-To: apmail-lucene-mahout-dev-archive@locus.apache.org Received: (qmail 50731 invoked from network); 19 Apr 2008 01:37:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2008 01:37:43 -0000 Received: (qmail 69268 invoked by uid 500); 19 Apr 2008 01:37:44 -0000 Delivered-To: apmail-lucene-mahout-dev-archive@lucene.apache.org Received: (qmail 69241 invoked by uid 500); 19 Apr 2008 01:37:44 -0000 Mailing-List: contact mahout-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mahout-dev@lucene.apache.org Delivered-To: mailing list mahout-dev@lucene.apache.org Received: (qmail 69232 invoked by uid 99); 19 Apr 2008 01:37:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 18:37:44 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Apr 2008 01:36:59 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 12CBF234C0E2 for ; Fri, 18 Apr 2008 18:34:28 -0700 (PDT) Message-ID: <795203154.1208568868075.JavaMail.jira@brutus> Date: Fri, 18 Apr 2008 18:34:28 -0700 (PDT) From: "Karl Wettin (JIRA)" To: mahout-dev@lucene.apache.org Subject: [jira] Commented: (MAHOUT-49) ParameterEnumerable In-Reply-To: <2050892619.1208568745778.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MAHOUT-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590661#action_12590661 ] Karl Wettin commented on MAHOUT-49: ----------------------------------- Something like this: {code:java} public interface ParameterEnumerable { public abstract int numberOfParameters(); public abstract Enumeration enumerateParameters(); public interface Parameter { /** @return */ public abstract String name(); /** @return */ public abstract String description(); /** @return */ public abstract Class type(); /** @param stringValue */ public abstract void setStringValue(String stringValue); /** @return */ public abstract String getStringValue(); /** @param value*/ public abstract void setValue(T value); /** @return */ public abstract T getValue(); /** @return */ public abstract T defaultValue(); } public abstract class AbstractParameter implements Parameter { private T value; private String name; private String description; private Class type; private T defaultValue; protected AbstractParameter(Class type, T value, T defaultValue, String name, String description) { this.type = type; this.value = value; this.defaultValue = defaultValue; this.name = name; this.description = description; } public String name() { return name; } public String description() { return description; } public Class type() { return type; } public T defaultValue() { return defaultValue; } public T getValue() { return value; } public void setValue(T value) { this.value = value; } } public static class Generalizations { public static String help(ParameterEnumerable enumerable) { int numChars = 100; // just to be sure int longestName = 0; for (Enumeration parameters = enumerable.enumerateParameters(); parameters.hasMoreElements();) { Parameter parameter = parameters.nextElement(); int parameterNameLength = parameter.name().length(); if (parameterNameLength > longestName) { longestName = parameterNameLength; } numChars += parameter.description().length(); } int distanceBetweenNameAndDescription = 4; numChars += (longestName + distanceBetweenNameAndDescription) * enumerable.numberOfParameters(); StringBuilder sb = new StringBuilder(numChars); for (Enumeration parameters = enumerable.enumerateParameters(); parameters.hasMoreElements();) { Parameter parameter = parameters.nextElement(); sb.append(parameter.name()); for (int i = 0; i < longestName - parameter.name().length() + distanceBetweenNameAndDescription; i++) { sb.append(' '); } sb.append(parameter.description()); sb.append('\n'); } return sb.toString(); } } } {code} > ParameterEnumerable > ------------------- > > Key: MAHOUT-49 > URL: https://issues.apache.org/jira/browse/MAHOUT-49 > Project: Mahout > Issue Type: New Feature > Reporter: Karl Wettin > Assignee: Karl Wettin > > A utility package used to > * configure class > * create default configuration files > * parse main method arguments > * produce human readable help > * getters and setters for value as object and string, for future generic reflection based GUI. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.