001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2015 ForgeRock AS.
016 */
017package org.opends.server.tools;
018
019import java.util.ArrayList;
020import org.opends.server.types.Control;
021
022
023/**
024 * This class defines common options for all the operations used
025 * by the tools.
026 */
027public class LDAPToolOptions
028{
029
030  private boolean showOperations;
031  private boolean verbose;
032  private boolean continueOnError;
033  private String encoding = System.getProperty("file.encoding");
034  private ArrayList<Control> controls = new ArrayList<>();
035
036  /**
037   * Creates a the tool options instance.
038   *
039   */
040  public LDAPToolOptions()
041  {
042  }
043
044  /**
045   * Set whether to show what would be run but not actually do it.
046   *
047   * @param showOperations    True if we need to show what needs to be done.
048   *
049   */
050
051  public void setShowOperations(boolean showOperations)
052  {
053    this.showOperations = showOperations;
054  }
055
056  /**
057   * Return the showOperations flag value.
058   *
059   * @return  <CODE>true</CODE> if the operations should only be displayed, or
060   *          <CODE>false</CODE> if they should actually be performed.
061   */
062  public boolean showOperations()
063  {
064    return showOperations;
065  }
066
067  /**
068   * Set verbose flag.
069   *
070   * @param  verbose  Indicates whether the tool should operate in verbose mode.
071   */
072
073  public void setVerbose(boolean verbose)
074  {
075    this.verbose = verbose;
076  }
077
078  /**
079   * Return the verbose flag value.
080   *
081   * @return  <CODE>true</CODE> if the tool should operate in verbose mode, or
082   *          <CODE>false</CODE> if not.
083   */
084  public boolean getVerbose()
085  {
086    return verbose;
087  }
088
089  /**
090   * Set whether to use continue on error or not.
091   *
092   * @param continueOnError    True if processing should continue on
093   *                           error, false otherwise.
094   *
095   */
096
097  public void setContinueOnError(boolean continueOnError)
098  {
099    this.continueOnError = continueOnError;
100  }
101
102  /**
103   * Return the continueOnError flag value.
104   *
105   * @return  <CODE>true</CODE> if the tool should continue processing
106   *          operations if an error occurs with a previous operation, or
107   *          <CODE>false</CODE> if not.
108   */
109  public boolean continueOnError()
110  {
111    return continueOnError;
112  }
113
114  /**
115   * Return the controls to apply to the operation.
116   *
117   * @return  The controls to apply to the operation.
118   */
119  public ArrayList<Control> getControls()
120  {
121    return controls;
122  }
123
124  /**
125   * Specifies the set of controls to apply to the operation.
126   *
127   * @param  controls  The set of controls to apply to the operation.
128   */
129  public void setControls(ArrayList<Control> controls)
130  {
131    this.controls = controls;
132  }
133
134  /**
135   * Set the encoding.
136   *
137   * @param  encodingStr  The encoding to use for string values.
138   */
139  public void setEncoding(String encodingStr)
140  {
141    this.encoding = encodingStr;
142  }
143
144  /**
145   * Return the encoding value.
146   *
147   * @return  The encoding to use for string values.
148   */
149  public String getEncoding()
150  {
151    return encoding;
152  }
153
154}
155