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