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 * docs/licenses/cddl.txt 011 * or http://www.opensource.org/licenses/cddl1.php. 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 * docs/licenses/cddl.txt. 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 2010-2014 UnboundID Corp. 026 */ 027 package com.unboundid.directory.sdk.ds.types; 028 029 030 031 import java.io.Serializable; 032 033 import com.unboundid.util.NotMutable; 034 import com.unboundid.util.ThreadSafety; 035 import com.unboundid.util.ThreadSafetyLevel; 036 037 038 039 /** 040 * This class defines a structure which may be used to provide information about 041 * the result of the processing performed by an LDIF import or export plugin. 042 */ 043 @NotMutable() 044 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 045 public final class LDIFPluginResult 046 implements Serializable 047 { 048 /** 049 * A predefined result instance that indicates all processing completed 050 * successfully. 051 */ 052 public static final LDIFPluginResult SUCCESS = 053 new LDIFPluginResult(true, true, null); 054 055 056 057 /** 058 * The serial version UID for this serializable class. 059 */ 060 private static final long serialVersionUID = -5261599290257098170L; 061 062 063 064 // Indicates whether the server should continue processing other LDIF import 065 // or export plugins. 066 private final boolean continuePluginProcessing; 067 068 // Indicates whether the associated entry should continue to be included in 069 // the LDIF import or export. 070 private final boolean includeEntry; 071 072 // A message providing additional information about the reason the entry 073 // should be excluded. 074 private final String excludeReason; 075 076 077 078 /** 079 * Creates a new LDIF plugin result with the provided information. 080 * 081 * @param continuePluginProcessing Indicates whether to continue processing 082 * other LDIF import or export plugins. 083 * @param includeEntry Indicates whether the associated entry 084 * should continue to be included in the 085 * LDIF import or export. 086 * @param excludeReason An optional message providing additional 087 * information about the reason the entry 088 * should be excluded from the import or 089 * export. It may be {@code null} if the 090 * entry should still be included. 091 */ 092 public LDIFPluginResult(final boolean continuePluginProcessing, 093 final boolean includeEntry, 094 final CharSequence excludeReason) 095 { 096 this.continuePluginProcessing = continuePluginProcessing; 097 this.includeEntry = includeEntry; 098 099 if (excludeReason == null) 100 { 101 this.excludeReason = null; 102 } 103 else 104 { 105 this.excludeReason = excludeReason.toString(); 106 } 107 } 108 109 110 111 /** 112 * Indicates whether to continue processing other LDIF import or export 113 * plugins for the entry. 114 * 115 * @return {@code true} if the server should continue processing other LDIF 116 * import or export plugins for the entry, or {@code false} if not. 117 */ 118 public boolean continuePluginProcessing() 119 { 120 return continuePluginProcessing; 121 } 122 123 124 125 /** 126 * Indicates whether the associated entry should be still be included in the 127 * LDIF import or export. 128 * 129 * @return {@code true} if the associated entry should be still be included 130 * in the LDIF import or export, or {@code false} if it should be 131 * excluded. 132 */ 133 public boolean includeEntry() 134 { 135 return includeEntry; 136 } 137 138 139 140 /** 141 * Retrieves a message with additional information about the reason the entry 142 * should be excluded, if applicable. 143 * 144 * @return A message with additional information about the reason the entry 145 * should be excluded, or {@code null} if none is available or the 146 * entry should be included in the import or export. 147 */ 148 public String getExcludeReason() 149 { 150 return excludeReason; 151 } 152 153 154 155 /** 156 * Retrieves a string representation of this LDIF plugin result. 157 * 158 * @return A string representation of this LDIF plugin result. 159 */ 160 @Override() 161 public String toString() 162 { 163 final StringBuilder buffer = new StringBuilder(); 164 165 buffer.append("LDIFPluginResult(continuePluginProcessing="); 166 buffer.append(continuePluginProcessing); 167 buffer.append(", includeEntry="); 168 buffer.append(includeEntry); 169 170 if (excludeReason != null) 171 { 172 buffer.append(", excludeReason='"); 173 buffer.append(excludeReason); 174 buffer.append('\''); 175 } 176 177 buffer.append(')'); 178 179 return buffer.toString(); 180 } 181 }