From 093afc236cd341a9eb046bc9acd95a0533d543af Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Thu, 11 Feb 2016 13:46:49 +0000
Subject: [PATCH] OPENDJSDK-42 Code cleanup
---
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java | 30 -
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java | 140 ----------
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/DocDescriptionSupplement.java | 6
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/IntegerArgument.java | 84 +-----
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java | 180 ------------
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Argument.java | 126 ---------
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java | 101 -------
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java | 18 -
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java | 9
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/MultiChoiceArgument.java | 25 -
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/StringArgument.java | 22 -
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java | 2
12 files changed, 58 insertions(+), 685 deletions(-)
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Argument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Argument.java
index c13b120..8044d1d 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Argument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Argument.java
@@ -22,15 +22,15 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions copyright 2014-2015 ForgeRock AS.
+ * Portions copyright 2014-2016 ForgeRock AS.
*/
package com.forgerock.opendj.cli;
import static com.forgerock.opendj.cli.CliMessages.*;
-import static com.forgerock.opendj.util.StaticUtils.*;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
@@ -76,7 +76,7 @@
/**
* Indicates whether this argument was provided in the set of
- * properties found is a properties file.
+ * properties found in a properties file.
*/
private boolean isValueSetByProperty;
@@ -171,35 +171,6 @@
}
/**
- * Retrieves the value of this argument as a <CODE>Boolean</CODE>.
- *
- * @return The value of this argument as a <CODE>Boolean</CODE>.
- * @throws ArgumentException
- * If this argument cannot be interpreted as a Boolean value.
- */
- public boolean getBooleanValue() throws ArgumentException {
- if (values.isEmpty()) {
- throw new ArgumentException(ERR_ARG_NO_BOOLEAN_VALUE.get(name));
- }
-
- final Iterator<String> iterator = values.iterator();
- final String valueString = toLowerCase(iterator.next());
- if (iterator.hasNext()) {
- throw new ArgumentException(ERR_ARG_BOOLEAN_MULTIPLE_VALUES.get(name));
- }
-
- if ("true".equals(valueString) || "yes".equals(valueString)
- || "on".equals(valueString) || "1".equals(valueString)) {
- return true;
- } else if ("false".equals(valueString) || "no".equals(valueString)
- || "off".equals(valueString) || "0".equals(valueString)) {
- return false;
- } else {
- throw new ArgumentException(ERR_ARG_CANNOT_DECODE_AS_BOOLEAN.get(valueString, name));
- }
- }
-
- /**
* Retrieves the default value that will be used for this argument if it is
* not specified on the command line and it is not set from a properties
* file.
@@ -222,18 +193,14 @@
return description != null ? description : LocalizableMessage.EMPTY;
}
- /**
- * A supplement to the description intended for use in generated reference documentation.
- */
+ /** A supplement to the description intended for use in generated reference documentation. */
private LocalizableMessage docDescriptionSupplement;
- /** {@inheritDoc} */
@Override
public LocalizableMessage getDocDescriptionSupplement() {
return docDescriptionSupplement != null ? docDescriptionSupplement : LocalizableMessage.EMPTY;
}
- /** {@inheritDoc} */
@Override
public void setDocDescriptionSupplement(final LocalizableMessage docDescriptionSupplement) {
this.docDescriptionSupplement = docDescriptionSupplement;
@@ -247,52 +214,6 @@
* If there are multiple values, or the value cannot be parsed
* as an integer.
*/
- public double getDoubleValue() throws ArgumentException {
- if (values.isEmpty()) {
- throw new ArgumentException(ERR_ARG_NO_INT_VALUE.get(name));
- }
-
- final Iterator<String> iterator = values.iterator();
- final String valueString = iterator.next();
- if (iterator.hasNext()) {
- throw new ArgumentException(ERR_ARG_INT_MULTIPLE_VALUES.get(name));
- }
-
- try {
- return Double.parseDouble(valueString);
- } catch (final Exception e) {
- throw new ArgumentException(ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name), e);
- }
- }
-
- /**
- * Retrieves the set of values for this argument as a list of integers.
- *
- * @return A list of the integer representations of the values for this
- * argument.
- * @throws ArgumentException
- * If any of the values cannot be parsed as an integer.
- */
- public LinkedList<Double> getDoubleValues() throws ArgumentException {
- final LinkedList<Double> results = new LinkedList<>();
- for (String valueString : values) {
- try {
- results.add(Double.valueOf(valueString));
- } catch (final Exception e) {
- throw new ArgumentException(ERR_ARG_CANNOT_DECODE_AS_DOUBLE.get(valueString, name), e);
- }
- }
- return results;
- }
-
- /**
- * Retrieves the value of this argument as an integer.
- *
- * @return The value of this argument as an integer.
- * @throws ArgumentException
- * If there are multiple values, or the value cannot be parsed
- * as an integer.
- */
public int getIntValue() throws ArgumentException {
if (values.isEmpty()) {
throw new ArgumentException(ERR_ARG_NO_INT_VALUE.get(name));
@@ -312,26 +233,6 @@
}
/**
- * Retrieves the set of values for this argument as a list of integers.
- *
- * @return A list of the integer representations of the values for this
- * argument.
- * @throws ArgumentException
- * If any of the values cannot be parsed as an integer.
- */
- public LinkedList<Integer> getIntValues() throws ArgumentException {
- final LinkedList<Integer> results = new LinkedList<>();
- for (String valueString : values) {
- try {
- results.add(Integer.valueOf(valueString));
- } catch (final Exception e) {
- throw new ArgumentException(ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name), e);
- }
- }
- return results;
- }
-
- /**
* Retrieves the long (multi-character) identifier that may be used to
* specify the value of this argument.
*
@@ -404,7 +305,7 @@
*
* @return The set of string values for this argument.
*/
- public LinkedList<String> getValues() {
+ public List<String> getValues() {
return values;
}
@@ -525,19 +426,6 @@
}
/**
- * Specifies whether a value must be provided with this argument if it is
- * present. If this is changed from <CODE>false</CODE> to <CODE>true</CODE>,
- * then a value placeholder must also be provided.
- *
- * @param needsValue
- * Indicates whether a value must be provided with this argument
- * if it is present.
- */
- public void setNeedsValue(final boolean needsValue) {
- this.needsValue = needsValue;
- }
-
- /**
* Specifies whether this argument is present in the parsed set of
* command-line arguments.
*
@@ -609,10 +497,8 @@
* @return <CODE>true</CODE> if the value is acceptable, or
* <CODE>false</CODE> if it is not.
*/
- public abstract boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason);
+ public abstract boolean valueIsAcceptable(String valueString, LocalizableMessageBuilder invalidReason);
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
index 4a700c2..e4ac32a 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2014-2015 ForgeRock AS
+ * Copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
@@ -227,30 +227,10 @@
/** The value for the long option version. */
public static final String OPTION_LONG_PRODUCT_VERSION = "version";
- /** The value for the short option groupName attributes. */
- public static final char OPTION_SHORT_GROUPNAME = 'g';
- /** The value for the long option groupName attribute. */
- public static final String OPTION_LONG_GROUPNAME = "groupName";
-
- /** The value for the short option newGroupName attribute. */
- public static final char OPTION_SHORT_NEWGROUPNAME = 'n';
- /** The value for the long option groupName attribute. */
- public static final String OPTION_LONG_NEWGROUPNAME = "newGroupName";
-
- /** The value for the short option serverID attributes. */
- public static final String OPTION_SHORT_SERVERID = null;
- /** The value for the long option serverID attribute. */
- public static final String OPTION_LONG_SERVERID = "serverID";
-
- /** The value for the short option userID attributes. */
- public static final String OPTION_SHORT_USERID = null;
- /** The value for the long option userID attribute. */
- public static final String OPTION_LONG_USERID = "userID";
-
- /** The value for the short option set. */
- public static final Character OPTION_SHORT_SET = null;
- /** The value for the long option set. */
- public static final String OPTION_LONG_SET = "set";
+ /** The value for the long "checkStoppability" {@link Argument}. */
+ public static final String OPTION_LONG_CHECK_STOPPABILITY = "checkStoppability";
+ /** The value for the long "windowsNetStop" {@link Argument}. */
+ public static final String OPTION_LONG_WINDOWS_NET_STOP = "windowsNetStop";
/** Value for the quiet option short form. */
public static final Character OPTION_SHORT_QUIET = 'Q';
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
index 9ba847a..0cfac0c 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions copyright 2012-2015 ForgeRock AS.
+ * Portions copyright 2012-2016 ForgeRock AS.
*/
package com.forgerock.opendj.cli;
@@ -120,13 +120,11 @@
};
/** The set of arguments defined for this parser, referenced by short ID. */
- private final HashMap<Character, Argument> shortIDMap = new HashMap<>();
+ private final Map<Character, Argument> shortIDMap = new HashMap<>();
/** The set of arguments defined for this parser, referenced by long ID. */
- private final HashMap<String, Argument> longIDMap = new HashMap<>();
- /** The set of arguments defined for this parser, referenced by argument name. */
- private final HashMap<String, Argument> argumentMap = new HashMap<>();
+ private final Map<String, Argument> longIDMap = new HashMap<>();
/** The total set of arguments defined for this parser. */
- private final LinkedList<Argument> argumentList = new LinkedList<>();
+ private final List<Argument> argumentList = new LinkedList<>();
/** The maximum number of unnamed trailing arguments that may be provided. */
private final int maxTrailingArguments;
@@ -153,9 +151,6 @@
/** The display name that will be used for the trailing arguments in the usage information. */
private final String trailingArgsDisplayName;
- /** The raw set of command-line arguments that were provided. */
- private String[] rawArguments;
-
/** Set of argument groups. */
protected final Set<ArgumentGroup> argumentGroups = new TreeSet<>();
@@ -406,9 +401,8 @@
return null;
}
- // check if the properties file argument has been set. If not
- // look for default location.
- String propertiesFilePath = null;
+ // check if the properties file argument has been set. If not look for default location.
+ String propertiesFilePath;
if (filePropertiesPathArgument.isPresent()) {
propertiesFilePath = filePropertiesPathArgument.getValue();
} else {
@@ -457,18 +451,6 @@
}
/**
- * Retrieves the argument with the specified name.
- *
- * @param name
- * The name of the argument to retrieve.
- * @return The argument with the specified name, or <CODE>null</CODE> if
- * there is no such argument.
- */
- Argument getArgument(final String name) {
- return argumentMap.get(name);
- }
-
- /**
* Retrieves the argument with the specified long identifier.
*
* @param longID
@@ -481,53 +463,17 @@
}
/**
- * Retrieves the argument with the specified short identifier.
- *
- * @param shortID
- * The short ID for the argument to retrieve.
- * @return The argument with the specified short identifier, or
- * <CODE>null</CODE> if there is no such argument.
- */
- Argument getArgumentForShortID(final Character shortID) {
- return shortIDMap.get(shortID);
- }
-
- /**
* Retrieves the list of all arguments that have been defined for this
* argument parser.
*
* @return The list of all arguments that have been defined for this
* argument parser.
*/
- public LinkedList<Argument> getArgumentList() {
+ public List<Argument> getArgumentList() {
return argumentList;
}
/**
- * Retrieves the set of arguments mapped by the long identifier that may be
- * used to reference them. Note that arguments that do not have a long
- * identifier will not be present in this list.
- *
- * @return The set of arguments mapped by the long identifier that may be
- * used to reference them.
- */
- HashMap<String, Argument> getArgumentsByLongID() {
- return longIDMap;
- }
-
- /**
- * Retrieves the set of arguments mapped by the short identifier that may be
- * used to reference them. Note that arguments that do not have a short
- * identifier will not be present in this list.
- *
- * @return The set of arguments mapped by the short identifier that may be
- * used to reference them.
- */
- HashMap<Character, Argument> getArgumentsByShortID() {
- return shortIDMap;
- }
-
- /**
* Retrieves the fully-qualified name of the Java class that should be
* invoked to launch the program with which this argument parser is
* associated.
@@ -541,40 +487,6 @@
}
/**
- * Retrieves the maximum number of unnamed trailing arguments that may be
- * provided.
- *
- * @return The maximum number of unnamed trailing arguments that may be
- * provided, or a value less than or equal to zero if no maximum
- * will be enforced.
- */
- int getMaxTrailingArguments() {
- return maxTrailingArguments;
- }
-
- /**
- * Retrieves the minimum number of unnamed trailing arguments that must be
- * provided.
- *
- * @return The minimum number of unnamed trailing arguments that must be
- * provided, or a value less than or equal to zero if no minimum
- * will be enforced.
- */
- int getMinTrailingArguments() {
- return minTrailingArguments;
- }
-
- /**
- * Retrieves the raw set of arguments that were provided.
- *
- * @return The raw set of arguments that were provided, or <CODE>null</CODE>
- * if the argument list has not yet been parsed.
- */
- String[] getRawArguments() {
- return rawArguments;
- }
-
- /**
* Given an argument, returns an appropriate group. Arguments may be part of
* one of the special groups or the default group.
*
@@ -1039,18 +951,6 @@
return usageArgument != null && usageArgument.getName().equals(a.getName());
}
- /**
- * Retrieves a message containing usage information based on the defined
- * arguments.
- *
- * @return A string containing usage information based on the defined
- * arguments.
- */
- public LocalizableMessage getUsageMessage() {
- // TODO: rework getUsage(OutputStream) to work with messages framework
- return LocalizableMessage.raw(getUsage());
- }
-
/** Prints the version. */
void printVersion() {
versionPresent = true;
@@ -1118,10 +1018,7 @@
* If a problem was encountered while parsing the provided
* arguments.
*/
- public void parseArguments(final String[] rawArguments, Properties argumentProperties)
- throws ArgumentException {
- this.rawArguments = rawArguments;
-
+ public void parseArguments(final String[] rawArguments, Properties argumentProperties) throws ArgumentException {
boolean inTrailingArgs = false;
final int numArguments = rawArguments.length;
@@ -1154,12 +1051,11 @@
String argName = arg.substring(2);
String argValue = null;
final int equalPos = argName.indexOf('=');
- if (equalPos < 0) {
- // This is fine. The value is not part of the argument name token.
- } else if (equalPos == 0) {
+ // If equalsPos < 0, this is fine. The value is not part of the argument name token.
+ if (equalPos == 0) {
// The argument starts with "--=", which is not acceptable.
throw new ArgumentException(ERR_ARGPARSER_LONG_ARG_WITHOUT_NAME.get(arg));
- } else {
+ } else if (equalPos > 0) {
// The argument is in the form --name=value, so parse them both out.
argValue = argName.substring(equalPos + 1);
argName = argName.substring(0, equalPos);
@@ -1379,8 +1275,6 @@
*/
public void parseArguments(final String[] rawArguments, final String propertiesFile,
final boolean requirePropertiesFile) throws ArgumentException {
- this.rawArguments = rawArguments;
-
Properties argumentProperties = null;
try (final FileInputStream fis = new FileInputStream(propertiesFile)) {
@@ -1416,16 +1310,6 @@
}
/**
- * Sets the usage group description for the default argument group.
- *
- * @param description
- * for the default group
- */
- void setDefaultArgumentGroupDescription(final LocalizableMessage description) {
- this.defaultArgGroup.setDescription(description);
- }
-
- /**
* Sets the provided argument which will be used to identify the file
* properties.
*
@@ -1438,36 +1322,6 @@
}
/**
- * Sets the usage group description for the general argument group.
- *
- * @param description
- * for the general group
- */
- void setGeneralArgumentGroupDescription(final LocalizableMessage description) {
- this.generalArgGroup.setDescription(description);
- }
-
- /**
- * Sets the usage group description for the input/output argument group.
- *
- * @param description
- * for the input/output group
- */
- void setInputOutputArgumentGroupDescription(final LocalizableMessage description) {
- this.ioArgGroup.setDescription(description);
- }
-
- /**
- * Sets the usage group description for the LDAP argument group.
- *
- * @param description
- * for the LDAP group
- */
- void setLdapArgumentGroupDescription(final LocalizableMessage description) {
- this.ldapArgGroup.setDescription(description);
- }
-
- /**
* Sets the provided argument which will be used to identify the file
* properties.
*
@@ -1480,15 +1334,6 @@
}
/**
- * Sets the raw set of arguments.
- *
- * @param rawArguments the raw set of arguments to set
- */
- void setRawArguments(String[] rawArguments) {
- this.rawArguments = rawArguments;
- }
-
- /**
* Sets the provided argument as one which will automatically trigger the
* output of usage information if it is provided on the command line and no
* further argument validation will be performed. Note that the caller will
@@ -1740,8 +1585,7 @@
final String value = argumentProperties.getProperty(a.getPropertyName().toLowerCase());
final LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
if (value != null) {
- boolean addValue = (a instanceof BooleanArgument) ? true
- : a.valueIsAcceptable(value, invalidReason);
+ boolean addValue = (a instanceof BooleanArgument) || a.valueIsAcceptable(value, invalidReason);
if (addValue) {
a.addValue(value);
if (a.needsValue()) {
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
index e8efc58..55a8ec9 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions copyright 2014 ForgeRock AS
+ * Portions copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
@@ -74,27 +74,13 @@
}
}
- /** {@inheritDoc} */
@Override
public final void setPresent(final boolean isPresent) {
addValue(String.valueOf(isPresent));
}
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString
- * The value for which to make the determination.
- * @param invalidReason
- * A buffer into which the invalid reason may be written if the
- * value is not acceptable.
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
@Override
- public boolean valueIsAcceptable(final String valueString,
- final LocalizableMessageBuilder invalidReason) {
+ public boolean valueIsAcceptable(final String valueString, final LocalizableMessageBuilder invalidReason) {
// This argument type should never have a value, so any value
// provided will be unacceptable.
invalidReason.append(ERR_BOOLEANARG_NO_VALUE_ALLOWED.get(getName()));
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
index ba719ec..c5502f2 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2014-2015 ForgeRock AS.
+ * Copyright 2014-2016 ForgeRock AS.
*/
package com.forgerock.opendj.cli;
@@ -102,31 +102,6 @@
}
/**
- * Returns the "postreadattrs" string argument.
- *
- * @return The "postreadattrs" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static StringArgument getPostReadAttributes() throws ArgumentException {
- return new StringArgument("postreadattrs", null, "postReadAttributes", false, false, true,
- INFO_ATTRIBUTE_LIST_PLACEHOLDER.get(), null, "postReadAttributes",
- INFO_DESCRIPTION_POSTREAD_ATTRS.get());
- }
-
- /**
- * Returns the "prereadattrs" string argument.
- *
- * @return The "prereadattrs" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static StringArgument getPreReadAttributes() throws ArgumentException {
- return new StringArgument("prereadattrs", null, "preReadAttributes", false, false, true,
- INFO_ATTRIBUTE_LIST_PLACEHOLDER.get(), null, "preReadAttributes", INFO_DESCRIPTION_PREREAD_ATTRS.get());
- }
-
- /**
* Returns the "propertiesFilePath" string argument.
*
* @return The "propertiesFilePath" argument.
@@ -208,20 +183,6 @@
}
/**
- * Returns the "windowsnetstop" boolean argument.
- *
- * @return The "windowsnetstop" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static BooleanArgument getWindowsNetStop() throws ArgumentException {
- final BooleanArgument netStop = new BooleanArgument("windowsnetstop", null, "windowsNetStop",
- INFO_DESCRIPTION_WINDOWS_NET_STOP.get());
- netStop.setHidden(true);
- return netStop;
- }
-
- /**
* Returns the "quiet" boolean argument.
*
* @return The "quiet" argument.
@@ -274,22 +235,6 @@
}
/**
- * Returns the "targetldif" string argument.
- * <br><i> N.B : the 't' short option is also used by timelimit,
- * testonly, trustmanagerproviderdn, stoptime, start(dateTime).</i>
- *
- * @param description
- * The description of this argument.
- * @return The "targetldif" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static StringArgument getTargetLDIF(final LocalizableMessage description) throws ArgumentException {
- return new StringArgument("targetldif", 't', "targetLDIF", true, false, true, INFO_LDIFFILE_PLACEHOLDER.get(),
- null, null, description);
- }
-
- /**
* Returns the "timelimit" boolean argument. <br>
* <i> N.B : the 't' short option is also used by targetldif, testonly, trustmanagerproviderdn, stoptime,
* start(dateTime).</i>
@@ -432,20 +377,6 @@
}
/**
- * Returns the "checkstoppability" boolean argument.
- *
- * @return The "checkstoppability" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static BooleanArgument getCheckStoppability() throws ArgumentException {
- final BooleanArgument cs = new BooleanArgument("checkstoppability", null, "checkStoppability",
- INFO_CHECK_STOPPABILITY.get());
- cs.setHidden(true);
- return cs;
- }
-
- /**
* Returns the "configfile" string argument. <br>
* <i> N.B : the 'f' short option is also used by filename</i>
*
@@ -504,30 +435,6 @@
}
/**
- * Returns the "backupID" string argument.
- *
- * @return The "backupID" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static StringArgument getBackupId() throws ArgumentException {
- return new StringArgument("backupid", 'I', "backupID", false, false, true,
- INFO_BACKUPID_PLACEHOLDER.get(), null, null, INFO_DESCRIPTION_BACKUP_ID.get());
- }
-
- /**
- * Returns the "backupall" boolean argument. <br><i> N.B : the 'a' short option is also used by addbaseentry,
- * defaultAdd.</i>
- *
- * @return The "backupall" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static BooleanArgument getBackupAll() throws ArgumentException {
- return new BooleanArgument("backupall", 'a', "backUpAll", INFO_DESCRIPTION_BACKUP_ALL.get());
- }
-
- /**
* Returns the "baseDN" string argument.
*
* @return The "baseDN" argument.
@@ -713,7 +620,7 @@
* @throws ArgumentException
* If there is a problem with any of the parameters used to create this argument.
*/
- public static MultiChoiceArgument<SearchScope> getSearchScope() throws ArgumentException {
+ public static MultiChoiceArgument<SearchScope> getSearchScope() throws ArgumentException {
final MultiChoiceArgument<SearchScope> searchScope = new MultiChoiceArgument<>(
OPTION_LONG_SEARCHSCOPE, OPTION_SHORT_SEARCHSCOPE, OPTION_LONG_SEARCHSCOPE, false, true,
INFO_SEARCH_SCOPE_PLACEHOLDER.get(), SearchScope.values(), false,
@@ -853,21 +760,6 @@
}
/**
- * Returns the "sourceldif" string argument. <br>
- * <i> N.B : the 's' short option is also used by searchScope, servicestate, randomSeed, script-friendly.</i>
- *
- * @param description
- * The description of this argument.
- * @return The "sourceldif" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static StringArgument getSourceLDIF(final LocalizableMessage description) throws ArgumentException {
- return new StringArgument("sourceldif", 's', "sourceLDIF", true, false, true, INFO_LDIFFILE_PLACEHOLDER.get(),
- null, null, description);
- }
-
- /**
* Returns the "startTLS" boolean argument.
*
* @return The "startTLS" argument.
@@ -989,18 +881,6 @@
}
/**
- * Returns the "defaultAdd" boolean argument.
- * <br><i> N.B : the 'a' short option is also used by addbaseentry, defaultAdd.</i>
- *
- * @return The "defaultAdd" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static BooleanArgument getDefaultAdd() throws ArgumentException {
- return new BooleanArgument("defaultAdd", 'a', "defaultAdd", INFO_MODIFY_DESCRIPTION_DEFAULT_ADD.get());
- }
-
- /**
* Returns the "disableservice" boolean argument. <br>
* <i> N.B : the 'd' short option is also used by backupdirectory, sampledata.</i>
*
@@ -1197,21 +1077,6 @@
}
/**
- * Returns the "useSASLExternal" boolean argument. <br>
- * <i> N.B : the 'r' short option is also used by stopreason, remote.</i>
- *
- * @return The "useSASLExternal" argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used to create this argument.
- */
- public static BooleanArgument getUseSASLExternal() throws ArgumentException {
- final BooleanArgument useSASLExternal = new BooleanArgument("useSASLExternal", 'r', "useSASLExternal",
- INFO_DESCRIPTION_USE_SASL_EXTERNAL.get());
- useSASLExternal.setPropertyName("useSASLExternal");
- return useSASLExternal;
- }
-
- /**
* Returns the "useSSL" boolean argument. <br>
* <i> N.B : the 'Z' short option is also used by ldapsport.</i>
*
@@ -1304,5 +1169,4 @@
OPTION_LONG_CERT_NICKNAME, false, true, true, INFO_NICKNAME_PLACEHOLDER.get(), null,
OPTION_LONG_CERT_NICKNAME, INFO_ARGUMENT_DESCRIPTION_CERT_NICKNAME.get());
}
-
}
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/DocDescriptionSupplement.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/DocDescriptionSupplement.java
index 09562e6..9285b50 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/DocDescriptionSupplement.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/DocDescriptionSupplement.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2015 ForgeRock AS.
+ * Copyright 2015-2016 ForgeRock AS.
*/
package com.forgerock.opendj.cli;
@@ -38,7 +38,7 @@
* @return The supplement to the description for use in generated reference documentation,
* or LocalizableMessage.EMPTY if there is no supplement.
*/
- public LocalizableMessage getDocDescriptionSupplement();
+ LocalizableMessage getDocDescriptionSupplement();
/**
* Sets a supplement to the description intended for use in generated reference documentation.
@@ -46,5 +46,5 @@
* @param docDescriptionSupplement The supplement to the description
* for use in generated reference documentation.
*/
- public void setDocDescriptionSupplement(final LocalizableMessage docDescriptionSupplement);
+ void setDocDescriptionSupplement(final LocalizableMessage docDescriptionSupplement);
}
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
index 8d71a38..6ac905c 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions copyright 2014-2015 ForgeRock AS
+ * Portions copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
@@ -35,6 +35,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedHashMap;
+import java.util.Map;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
@@ -45,7 +46,7 @@
* command line, it will be treated as the path to the file containing the
* actual value rather than the value itself. <BR>
* <BR>
- * Note that if if no filename is provided on the command line but a default
+ * Note that if no filename is provided on the command line but a default
* value is specified programmatically or if the default value is read from a
* specified property, then that default value will be taken as the actual value
* rather than a filename. <BR>
@@ -56,7 +57,7 @@
*/
public final class FileBasedArgument extends Argument {
/** The mapping between filenames specified and the first lines read from those files. */
- private final LinkedHashMap<String, String> namesToValues = new LinkedHashMap<>();
+ private final Map<String, String> namesToValues = new LinkedHashMap<>();
/**
* Creates a new file-based argument with the provided information.
@@ -163,7 +164,7 @@
* @return A map between the filenames specified on the command line and the
* first lines read from those files.
*/
- public LinkedHashMap<String, String> getNameToValueMap() {
+ public Map<String, String> getNameToValueMap() {
return namesToValues;
}
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/IntegerArgument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/IntegerArgument.java
index 90e41a0..d832e75 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/IntegerArgument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/IntegerArgument.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions copyright 2014 ForgeRock AS
+ * Portions copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
@@ -274,48 +274,6 @@
}
/**
- * Retrieves the lower bound that may be enforced for values of this
- * argument.
- *
- * @return The lower bound that may be enforced for values of this argument.
- */
- public int getLowerBound() {
- return lowerBound;
- }
-
- /**
- * Retrieves the upper bound that may be enforced for values of this
- * argument.
- *
- * @return The upper bound that may be enforced for values of this argument.
- */
- public int getUpperBound() {
- return upperBound;
- }
-
- /**
- * Indicates whether a lower bound should be enforced for values of this
- * argument.
- *
- * @return <CODE>true</CODE> if a lower bound should be enforced for values
- * of this argument, or <CODE>false</CODE> if not.
- */
- public boolean hasLowerBound() {
- return hasLowerBound;
- }
-
- /**
- * Indicates whether a upper bound should be enforced for values of this
- * argument.
- *
- * @return <CODE>true</CODE> if a upper bound should be enforced for values
- * of this argument, or <CODE>false</CODE> if not.
- */
- public boolean hasUpperBound() {
- return hasUpperBound;
- }
-
- /**
* Indicates whether the provided value is acceptable for use in this
* argument.
*
@@ -328,35 +286,23 @@
* <CODE>false</CODE> if it is not.
*/
@Override
- public boolean valueIsAcceptable(final String valueString,
- final LocalizableMessageBuilder invalidReason) {
- // First, the value must be decodable as an integer.
- int intValue;
+ public boolean valueIsAcceptable(final String valueString, final LocalizableMessageBuilder invalidReason) {
try {
- intValue = Integer.parseInt(valueString);
- } catch (final Exception e) {
+ final int intValue = Integer.parseInt(valueString);
+ if (hasLowerBound && intValue < lowerBound) {
+ invalidReason.append(ERR_INTARG_VALUE_BELOW_LOWER_BOUND.get(getPropertyName(), intValue, lowerBound));
+ return false;
+ }
+
+ if (hasUpperBound && intValue > upperBound) {
+ invalidReason.append(ERR_INTARG_VALUE_ABOVE_UPPER_BOUND.get(getPropertyName(), intValue, upperBound));
+ return false;
+ }
+
+ return true;
+ } catch (final NumberFormatException e) {
invalidReason.append(ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, getPropertyName()));
return false;
}
-
- // If there is a lower bound, then the value must be greater than or
- // equal to it.
- if (hasLowerBound && (intValue < lowerBound)) {
- invalidReason.append(ERR_INTARG_VALUE_BELOW_LOWER_BOUND.get(getPropertyName(), intValue,
- lowerBound));
- return false;
- }
-
- // If there is an upper bound, then the value must be less than or
- // equal to it.
- if (hasUpperBound && (intValue > upperBound)) {
-
- invalidReason.append(ERR_INTARG_VALUE_ABOVE_UPPER_BOUND.get(getPropertyName(), intValue,
- upperBound));
- return false;
- }
-
- // At this point, the value should be acceptable.
- return true;
}
}
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/MultiChoiceArgument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/MultiChoiceArgument.java
index e33bea4..92b3b9e 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/MultiChoiceArgument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/MultiChoiceArgument.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions copyright 2014 ForgeRock AS
+ * Portions copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
@@ -155,17 +155,7 @@
}
/**
- * Retrieves the set of allowed values for this argument. The contents of
- * this set must not be altered by the caller.
- *
- * @return The set of allowed values for this argument.
- */
- public Collection<T> getAllowedValues() {
- return allowedValues;
- }
-
- /**
- * Retrieves the string vale for this argument. If it has multiple values,
+ * Retrieves the string value for this argument. If it has multiple values,
* then the first will be returned. If it does not have any values, then the
* default value will be returned.
*
@@ -189,17 +179,6 @@
}
/**
- * Indicates whether the set of allowed values for this argument should be
- * treated in a case-sensitive manner.
- *
- * @return <CODE>true</CODE> if the values are to be treated in a
- * case-sensitive manner, or <CODE>false</CODE> if not.
- */
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
- /**
* Specifies the default value that will be used for this argument if it is
* not specified on the command line and it is not set from a properties
* file.
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/StringArgument.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/StringArgument.java
index 7c5fb6d..70b52c4 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/StringArgument.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/StringArgument.java
@@ -22,16 +22,14 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions copyright 2014 ForgeRock AS
+ * Portions copyright 2014-2016 ForgeRock AS
*/
package com.forgerock.opendj.cli;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
-/**
- * This class defines an argument type that will accept any string value.
- */
+/** This class defines an argument type that will accept any string value. */
public final class StringArgument extends Argument {
/**
* Creates a new string argument with the provided information.
@@ -115,21 +113,9 @@
valuePlaceholder, null, null, description);
}
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString
- * The value for which to make the determination.
- * @param invalidReason
- * A buffer into which the invalid reason may be written if the
- * value is not acceptable.
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
+
@Override
- public boolean valueIsAcceptable(final String valueString,
- final LocalizableMessageBuilder invalidReason) {
+ public boolean valueIsAcceptable(final String valueString, final LocalizableMessageBuilder invalidReason) {
// All values will be acceptable for this argument.
return true;
}
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
index 56788b0..2c0ef33 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2015 ForgeRock AS.
+ * Portions Copyright 2011-2016 ForgeRock AS.
*/
package com.forgerock.opendj.cli;
@@ -100,15 +100,6 @@
}
/**
- * Retrieves the list of all global arguments that have been defined for this argument parser.
- *
- * @return The list of all global arguments that have been defined for this argument parser.
- */
- public List<Argument> getGlobalArgumentList() {
- return globalArgumentList;
- }
-
- /**
* Indicates whether this argument parser contains a global argument with the specified name.
*
* @param argumentName
@@ -120,38 +111,6 @@
}
/**
- * Retrieves the global argument with the specified name.
- *
- * @param name
- * The name of the global argument to retrieve.
- * @return The global argument with the specified name, or <CODE>null</CODE> if there is no such argument.
- */
- public Argument getGlobalArgument(String name) {
- return globalArgumentMap.get(name);
- }
-
- /**
- * Retrieves the set of global arguments mapped by the short identifier that may be used to reference them. Note
- * that arguments that do not have a short identifier will not be present in this list.
- *
- * @return The set of global arguments mapped by the short identifier that may be used to reference them.
- */
- public Map<Character, Argument> getGlobalArgumentsByShortID() {
- return globalShortIDMap;
- }
-
- /**
- * Indicates whether this argument parser has a global argument with the specified short ID.
- *
- * @param shortID
- * The short ID character for which to make the determination.
- * @return <CODE>true</CODE> if a global argument exists with the specified short ID, or <CODE>false</CODE> if not.
- */
- public boolean hasGlobalArgumentWithShortID(Character shortID) {
- return globalShortIDMap.containsKey(shortID);
- }
-
- /**
* Retrieves the global argument with the specified short identifier.
*
* @param shortID
@@ -164,27 +123,6 @@
}
/**
- * Retrieves the set of global arguments mapped by the long identifier that may be used to reference them. Note that
- * arguments that do not have a long identifier will not be present in this list.
- *
- * @return The set of global arguments mapped by the long identifier that may be used to reference them.
- */
- public Map<String, Argument> getGlobalArgumentsByLongID() {
- return globalLongIDMap;
- }
-
- /**
- * Indicates whether this argument parser has a global argument with the specified long ID.
- *
- * @param longID
- * The long ID string for which to make the determination.
- * @return <CODE>true</CODE> if a global argument exists with the specified long ID, or <CODE>false</CODE> if not.
- */
- public boolean hasGlobalArgumentWithLongID(String longID) {
- return globalLongIDMap.containsKey(longID);
- }
-
- /**
* Retrieves the global argument with the specified long identifier.
*
* @param longID
@@ -197,15 +135,6 @@
}
/**
- * Retrieves the set of subcommands defined for this argument parser, referenced by subcommand name.
- *
- * @return The set of subcommands defined for this argument parser, referenced by subcommand name.
- */
- public SortedMap<String, SubCommand> getSubCommands() {
- return subCommands;
- }
-
- /**
* Indicates whether this argument parser has a subcommand with the specified name.
*
* @param name
@@ -351,33 +280,6 @@
}
/**
- * Removes the provided argument from the set of global arguments handled by this parser.
- *
- * @param argument
- * The argument to be removed.
- */
- protected void removeGlobalArgument(Argument argument) {
- String argumentName = argument.getName();
- globalArgumentMap.remove(argumentName);
-
- Character shortID = argument.getShortIdentifier();
- if (shortID != null) {
- globalShortIDMap.remove(shortID);
- }
-
- String longID = argument.getLongIdentifier();
- if (longID != null) {
- if (!longArgumentsCaseSensitive()) {
- longID = toLowerCase(longID);
- }
-
- globalLongIDMap.remove(longID);
- }
-
- globalArgumentList.remove(argument);
- }
-
- /**
* Sets the provided argument as one which will automatically trigger the output of full usage information if it is
* provided on the command line and no further argument validation will be performed.
* <p>
@@ -445,7 +347,6 @@
*/
@Override
public void parseArguments(String[] rawArguments, Properties argumentProperties) throws ArgumentException {
- setRawArguments(rawArguments);
this.subCommand = null;
final ArrayList<String> trailingArguments = getTrailingArguments();
trailingArguments.clear();
diff --git a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java b/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
index b98fc19..1dcc3fa 100644
--- a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
+++ b/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -673,7 +673,7 @@
}
if (matchedValuesFilter.isPresent()) {
- final LinkedList<String> mvFilterStrings = matchedValuesFilter.getValues();
+ final List<String> mvFilterStrings = matchedValuesFilter.getValues();
final List<Filter> mvFilters = new ArrayList<>();
for (final String s : mvFilterStrings) {
try {
--
Gitblit v1.10.0