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.types; 028 029 030 031 /** 032 * This class defines a data structure for providing information about 033 * the state of a completed LDIF import, including the total number of 034 * entries read, skipped, and rejected. 035 */ 036 @org.opends.server.types.PublicAPI( 037 stability=org.opends.server.types.StabilityLevel.VOLATILE, 038 mayInstantiate=false, 039 mayExtend=false, 040 mayInvoke=true) 041 public final class LDIFImportResult 042 { 043 // The total number of entries read during the import. 044 private final long entriesRead; 045 046 // The total number of entries rejected during the import. 047 private final long entriesRejected; 048 049 // The total number of entries skipped during the import. 050 private final long entriesSkipped; 051 052 053 054 /** 055 * Creates a new LDIF import result object with the provided 056 * information. 057 * 058 * @param entriesRead The total number of entries read 059 * during the import, including those that 060 * were later rejected or skipped. 061 * @param entriesRejected The total number of entries rejected 062 * during the import. 063 * @param entriesSkipped The total number of entries skipped 064 * during the import. 065 */ 066 public LDIFImportResult(long entriesRead, long entriesRejected, 067 long entriesSkipped) 068 { 069 this.entriesRead = entriesRead; 070 this.entriesRejected = entriesRejected; 071 this.entriesSkipped = entriesSkipped; 072 } 073 074 075 076 /** 077 * Retrieves the total number of entries read during the import, 078 * including those that were later rejected or skipped. 079 * 080 * @return The total number of entries read during the import, 081 * including those that were later rejected or skipped. 082 */ 083 public long getEntriesRead() 084 { 085 return entriesRead; 086 } 087 088 089 090 /** 091 * Retrieves the total number of entries that were successfully 092 * imported. 093 * 094 * @return The total number of entries that were successfully 095 * imported. 096 */ 097 public long getEntriesImported() 098 { 099 return entriesRead - entriesRejected - entriesSkipped; 100 } 101 102 103 104 /** 105 * Retrieves the total number of entries rejected during the import. 106 * 107 * @return The total number of entries rejected during the import. 108 */ 109 public long getEntriesRejected() 110 { 111 return entriesRejected; 112 } 113 114 115 116 /** 117 * Retrieves the total number of entries skipped during the import. 118 * 119 * @return The total number of entries skipped during the import. 120 */ 121 public long getEntriesSkipped() 122 { 123 return entriesSkipped; 124 } 125 126 127 128 /** 129 * Retrieves a string representation of this LDIF import result 130 * object. 131 * 132 * @return A string representation of this LDIF import result 133 * object. 134 */ 135 public String toString() 136 { 137 StringBuilder buffer = new StringBuilder(); 138 toString(buffer); 139 return buffer.toString(); 140 } 141 142 143 144 /** 145 * Appends a string representation of this LDIF import result object 146 * to the provided buffer. 147 * 148 * @param buffer The buffer to which the information should be 149 * appended. 150 */ 151 public void toString(StringBuilder buffer) 152 { 153 buffer.append("LDIFImportResult(entriesRead="); 154 buffer.append(entriesRead); 155 buffer.append(", entriesRejected="); 156 buffer.append(entriesRejected); 157 buffer.append(", entriesSkipped="); 158 buffer.append(entriesSkipped); 159 buffer.append(")"); 160 } 161 } 162