001/* 002 * Copyright 2009-2017 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2009-2017 UnboundID Corp. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk; 022 023 024 025import com.unboundid.util.LDAPSDKException; 026import com.unboundid.util.NotExtensible; 027import com.unboundid.util.NotMutable; 028import com.unboundid.util.StaticUtils; 029import com.unboundid.util.ThreadSafety; 030import com.unboundid.util.ThreadSafetyLevel; 031import com.unboundid.util.Validator; 032 033 034 035/** 036 * This class defines an exception that may be thrown if a problem occurs while 037 * trying to access an entry in an entry source (e.g., because the entry source 038 * is no longer available, because an entry could not be parsed, or because the 039 * next element returned was a search result reference rather than a search 040 * result entry). 041 */ 042@NotExtensible() 043@NotMutable() 044@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 045public class EntrySourceException 046 extends LDAPSDKException 047{ 048 /** 049 * The serial version UID for this serializable class. 050 */ 051 private static final long serialVersionUID = -9221149707074845318L; 052 053 054 055 // Indicates whether it is possible to continue attempting to iterate through 056 // subsequent entries. 057 private final boolean mayContinueReading; 058 059 060 061 /** 062 * Creates a new entry source exception with the provided information. 063 * 064 * @param mayContinueReading Indicates whether it is possible to continue 065 * attempting to iterate through subsequent 066 * entries in the entry source. 067 * @param cause The underlying exception that triggered this 068 * exception. It must not be {@code null}. 069 */ 070 public EntrySourceException(final boolean mayContinueReading, 071 final Throwable cause) 072 { 073 super(StaticUtils.getExceptionMessage(cause), cause); 074 075 Validator.ensureNotNull(cause); 076 077 this.mayContinueReading = mayContinueReading; 078 } 079 080 081 082 /** 083 * Creates a new entry source exception with the provided information. 084 * 085 * @param mayContinueReading Indicates whether it is possible to continue 086 * attempting to iterate through subsequent 087 * entries in the entry source. 088 * @param message A message explaining the problem that occurred. 089 * It must not be {@code null}. 090 * @param cause The underlying exception that triggered this 091 * exception. It must not be {@code null}. 092 */ 093 public EntrySourceException(final boolean mayContinueReading, 094 final String message, final Throwable cause) 095 { 096 super(message, cause); 097 098 Validator.ensureNotNull(message, cause); 099 100 this.mayContinueReading = mayContinueReading; 101 } 102 103 104 105 /** 106 * Indicates whether it is possible to continue attempting to iterate through 107 * subsequent entries in the entry source. 108 * 109 * @return {@code true} if it is possible to continue attempting to read from 110 * the entry source, or {@code false} if it is not possible to 111 * continue. 112 */ 113 public final boolean mayContinueReading() 114 { 115 return mayContinueReading; 116 } 117 118 119 120 /** 121 * {@inheritDoc} 122 */ 123 @Override() 124 public void toString(final StringBuilder buffer) 125 { 126 buffer.append("EntrySourceException(message='"); 127 buffer.append(getMessage()); 128 buffer.append("', mayContinueReading="); 129 buffer.append(mayContinueReading); 130 buffer.append(", cause='"); 131 buffer.append(StaticUtils.getExceptionMessage(getCause())); 132 buffer.append("')"); 133 } 134}