roxspring 2004/02/08 06:01:46
Modified: cli/src/java/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING PropertyOption.java
ArgumentImpl.java ParentImpl.java GroupImpl.java
cli/src/java/org/apache/commons/cli2 Tag:
RESEARCH_CLI_2_ROXSPRING Option.java
HelpFormatter.java HelpLine.java
Added: cli/src/java/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING HelpLineImpl.java
Log:
Extracted interface and implementation from HelpLine class
Revision Changes Path
No revision
No revision
1.1.2.5 +1 -1
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/PropertyOption.java
Index: PropertyOption.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/PropertyOption.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- PropertyOption.java 8 Feb 2004 13:08:59 -0000 1.1.2.4
+++ PropertyOption.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -185,7 +185,7 @@
final Set helpSettings,
final Comparator comp) {
if (helpSettings.contains(HelpSetting.DISPLAY_PROPERTY_OPTION)) {
- final HelpLine helpLine = new HelpLine(this, depth);
+ final HelpLine helpLine = new HelpLineImpl(this, depth);
return Collections.singletonList(helpLine);
}
else {
1.1.2.5 +1 -1
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java
Index: ArgumentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- ArgumentImpl.java 8 Feb 2004 13:08:59 -0000 1.1.2.4
+++ ArgumentImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -418,7 +418,7 @@
final int depth,
final Set helpSettings,
final Comparator comp) {
- final HelpLine helpLine = new HelpLine(this, depth);
+ final HelpLine helpLine = new HelpLineImpl(this, depth);
return Collections.singletonList(helpLine);
}
1.1.2.4 +1 -2
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ParentImpl.java
Index: ParentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ParentImpl.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- ParentImpl.java 8 Feb 2004 13:08:59 -0000 1.1.2.3
+++ ParentImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.4
@@ -24,7 +24,6 @@
import org.apache.commons.cli2.Argument;
import org.apache.commons.cli2.Group;
-import org.apache.commons.cli2.HelpLine;
import org.apache.commons.cli2.HelpSetting;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.Parent;
@@ -175,7 +174,7 @@
final Set helpSettings,
final Comparator comp) {
final List helpLines = new ArrayList();
- helpLines.add(new HelpLine(this, depth));
+ helpLines.add(new HelpLineImpl(this, depth));
if (helpSettings.contains(HelpSetting.DISPLAY_PARENT_ARGUMENT)
&& argument != null) {
1.1.2.5 +1 -1
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java
Index: GroupImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- GroupImpl.java 8 Feb 2004 13:08:59 -0000 1.1.2.4
+++ GroupImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -370,7 +370,7 @@
final Comparator comp) {
final List helpLines = new ArrayList();
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_NAME)) {
- final HelpLine helpLine = new HelpLine(this, depth);
+ final HelpLine helpLine = new HelpLineImpl(this, depth);
helpLines.add(helpLine);
}
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_EXPANDED)) {
No revision
Index: GroupImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- GroupImpl.java 8 Feb 2004 13:08:59 -0000 1.1.2.4
+++ GroupImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -370,7 +370,7 @@
final Comparator comp) {
final List helpLines = new ArrayList();
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_NAME)) {
- final HelpLine helpLine = new HelpLine(this, depth);
+ final HelpLine helpLine = new HelpLineImpl(this, depth);
helpLines.add(helpLine);
}
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_EXPANDED)) {
No revision
Index: GroupImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- GroupImpl.java 8 Feb 2004 13:08:59 -0000 1.1.2.4
+++ GroupImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -370,7 +370,7 @@
final Comparator comp) {
final List helpLines = new ArrayList();
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_NAME)) {
- final HelpLine helpLine = new HelpLine(this, depth);
+ final HelpLine helpLine = new HelpLineImpl(this, depth);
helpLines.add(helpLine);
}
if (helpSettings.contains(HelpSetting.DISPLAY_GROUP_EXPANDED)) {
1.1.2.1 +109 -0
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/HelpLineImpl.java
No revision
No revision
1.1.2.7 +2 -2
jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java
Index: Option.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- Option.java 8 Feb 2004 13:08:58 -0000 1.1.2.6
+++ Option.java 8 Feb 2004 14:01:46 -0000 1.1.2.7
@@ -106,7 +106,7 @@
throws OptionException;
/**
- * Builds up a list of HelpLine instances to be presented by HelpFormatter.
+ * Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
*
* @see HelpLine
* @see HelpFormatter
@@ -116,7 +116,7 @@
* the HelpSettings that should be applied
* @param comp
* a comparator used to sort options when applicable.
- * @return a List of HelpLine objects
+ * @return a List of HelpLineImpl objects
*/
List helpLines(
final int depth,
1.1.2.6 +5 -5
jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpFormatter.java
Index: HelpFormatter.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpFormatter.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- HelpFormatter.java 8 Feb 2004 13:08:58 -0000 1.1.2.5
+++ HelpFormatter.java 8 Feb 2004 14:01:46 -0000 1.1.2.6
@@ -146,10 +146,10 @@
else {
option = group;
}
-
- final List lines = option.helpLines(0, displaySettings, comparator);
+
+ final List helpLines = option.helpLines(0, displaySettings, comparator);
int usageWidth = 0;
- for (final Iterator i = lines.iterator(); i.hasNext();) {
+ for (final Iterator i = helpLines.iterator(); i.hasNext();) {
final HelpLine helpLine = (HelpLine)i.next();
final String usage = helpLine.usage(lineUsageSettings, comparator);
usageWidth = Math.max(usageWidth, usage.length());
@@ -160,14 +160,14 @@
}
final int descriptionWidth =
pageWidth - gutterCenter.length() - usageWidth;
- for (final Iterator i = lines.iterator(); i.hasNext();) {
+ for (final Iterator i = helpLines.iterator(); i.hasNext();) {
final HelpLine helpLine = (HelpLine)i.next();
final List descriptionLines =
wrap(helpLine.getDescription(), descriptionWidth);
final Iterator j = descriptionLines.iterator();
printGutterLeft(out);
- pad(helpLine.getUsage(), usageWidth, out);
+ pad(helpLine.usage(lineUsageSettings, comparator), usageWidth, out);
out.print(gutterCenter);
pad((String)j.next(), descriptionWidth, out);
printGutterRight(out);
1.1.2.5 +16 -49
jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpLine.java
Index: HelpLine.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpLine.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- HelpLine.java 8 Feb 2004 13:08:58 -0000 1.1.2.4
+++ HelpLine.java 8 Feb 2004 14:01:46 -0000 1.1.2.5
@@ -18,65 +18,32 @@
import java.util.Comparator;
import java.util.Set;
-/**
- * Represents a line in the help screen.
- */
-public class HelpLine {
-
- /** The option that this HelpLine describes */
- private final Option option;
-
- /** The level of indenting for this item */
- private final int indent;
-
- private String usage;
-
- /**
- * Creates a new HelpLine to represent a particular Option in the online
- * help.
- *
- * @param option
- * Option that the HelpLine describes
- * @param indent
- * Level of indentation for this line
- */
- public HelpLine(final Option option, final int indent) {
- this.option = option;
- this.indent = indent;
- }
+public interface HelpLine {
/**
* @return The description of the option
*/
- public String getDescription() {
- return option.getDescription();
- }
+ String getDescription();
/**
* @return The level of indentation for this line
*/
- public int getIndent() {
- return indent;
- }
+ int getIndent();
/**
* @return The Option that the help line relates to
*/
- public Option getOption() {
- return option;
- }
-
- public String usage(final Set helpSettings, final Comparator comparator) {
- final StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < indent; ++i) {
- buffer.append(" ");
- }
- option.appendUsage(buffer, helpSettings, comparator);
- usage = buffer.toString();
- return usage;
- }
+ Option getOption();
- public String getUsage() {
- return usage;
- }
-}
+ /**
+ * Builds a usage string for the option using the specified settings and
+ * comparator.
+ *
+ * @param helpSettings
+ * the settings to apply
+ * @param comparator
+ * a comparator to sort options when applicable
+ * @return the usage string
+ */
+ String usage(final Set helpSettings, final Comparator comparator);
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]