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