5046N/A * The contents of this file are subject to the terms of the 5046N/A * Common Development and Distribution License, Version 1.0 only 5046N/A * (the "License"). You may not use this file except in compliance 5046N/A * You can obtain a copy of the license at 5046N/A * See the License for the specific language governing permissions 5046N/A * and limitations under the License. 5046N/A * When distributing Covered Code, include this CDDL HEADER in each 5046N/A * file and include the License file at 5046N/A * add the following below this CDDL HEADER, with the fields enclosed 5046N/A * by brackets "[]" replaced with your own identifying information: 5046N/A * Portions Copyright [yyyy] [name of copyright owner] 5046N/A * Copyright 2010 Sun Microsystems, Inc. 5046N/A * LDAP Data Interchange Format (LDIF) is a file format used to 5046N/A * import and export directory data from an LDAP server and to 5046N/A * describe a set of changes to be applied to data in a directory. 5046N/A * This format is described in the Internet draft 5046N/A * TARGET="_blank">The LDAP Data Interchange Format (LDIF) - 5046N/A * Technical Specification</A>. 5046N/A * This class implements an LDIF file parser. You can construct 5046N/A * an object of this class to parse data in LDIF format and 5046N/A * manipulate the data as individual <CODE>LDIFRecord</CODE> objects. 5046N/A * @see netscape.ldap.util.LDIFRecord 5046N/A * Constructs an <CODE>LDIF</CODE> object to parse the 5046N/A * LDAP data read from stdin. 5046N/A * @exception IOException An I/O error has occurred. 5046N/A * Constructs an <CODE>LDIF</CODE> object to parse the 5046N/A * LDIF data read from a specified file. 5046N/A * @param file the name of the LDIF file to parse 5046N/A * @exception IOException An I/O error has occurred. 5046N/A * Constructs an <CODE>LDIF</CODE> object to parse the 5046N/A * LDIF data read from an input stream. 5046N/A * @param dstThe input stream providing the LDIF data 5046N/A * @exception IOException An I/O error has occurred. 5046N/A * Returns the next record in the LDIF data. You can call this 5046N/A * method repeatedly to iterate through all records in the LDIF data. 5046N/A * @return the next record as an <CODE>LDIFRecord</CODE> 5046N/A * object or null if there are no more records. 5046N/A * @exception IOException An I/O error has occurred. 5046N/A * @see netscape.ldap.util.LDIFRecord 5046N/A * Parses ldif content. The list of attributes is 5046N/A * terminated by \r\n or '-'. This function is 5046N/A * also used to parse the attributes in modifications. 5046N/A * @param ds data input stream 5046N/A // Skip past any blank lines 5046N/A * Parses ldif content. The list of attributes is 5046N/A * terminated by \r\n or '-'. This function is 5046N/A * also used to parse the attributes in modifications. 5046N/A * @param ds data input stream 5046N/A // if this is empty line, then we're finished reading all 5046N/A // the info for the current entry 5046N/A /* handles (changerecord) */ 5046N/A /* handles 1*(attrval-spec) */ 5046N/A /* Read lines until we're past the record */ 5046N/A /* Could be :: for binary */ 5046N/A /* Is there a previous value for this attribute? */ 5046N/A // Copy over the attributes to the record 5046N/A /* Translate from base 64 */ 5046N/A * @param ds data input stream 5046N/A * @param ds data input stream 5046N/A * Parses change modification. 5046N/A * @param ds data input stream 5046N/A // if there is no attrval-spec, go into the else statement 5046N/A * @param d data input stream 5046N/A * Parses the specification of a control<BR> 5046N/A * A control looks line one of the following: 5046N/A * control: 1.2.3.4.10.210 true 5046N/A * control: 1.2.3.4.10.210 true: someASCIIvalue 5046N/A * control: 1.2.3.4.10.210: someASCIIvalue 5046N/A * control: 1.2.3.4.10.210 true:: 44GK44GM44GV44KP44KJ 5046N/A * control: 1.2.3.4.10.210:: 44GK44GM44GV44KP44KJ 5046N/A * @param line a line containing a control spec 5046N/A * @return a parsed control. 5046N/A * @exception IOException if the line could not be parsed 5046N/A "Criticality for control must be true" +
5046N/A /* Could be :: for binary */ 5046N/A * Returns true if all the bytes in the given array are valid for output as a 5046N/A * String according to the LDIF specification. If not, the array should 5046N/A * @return <code>true</code> if all the bytes in the given array are valid for 5046N/A * output as a String according to the LDIF specification; otherwise, 5046N/A if ( (b[i] <
' ') || (b[i] >
127) ) {
5046N/A * Outputs the String in LDIF line-continuation format. No line will be longer 5046N/A * than the given max. A continuation line starts with a single blank space. 5046N/A * @param pw the printer writer 5046N/A * @param value the given string being printed out 5046N/A * @param max the maximum characters allowed in the line 5046N/A /* Limit to 77 characters per line */ 5046N/A /* Don't use pw.println, because it outputs an extra CR 5046N/A * Gets the version of LDIF used in the data. 5046N/A * @return version of LDIF used in the data. 5046N/A * Gets the string representation of the 5046N/A * @return the string representation of the entire LDIF data file. 5046N/A * Throws a LDIF file exception including the current line number. 5046N/A /* Concatenate continuation lines, if present */ 5046N/A * Reads a non-comment line. 5046N/A * @return a string or null. 5046N/A /* Leftover line from last time? */ 5046N/A /* Empty line means end of record */ 5046N/A /* Not a continuation line */ 5046N/A * Converts a byte array to a printable string following 5046N/A * the LDIF rules (encode in base64 if necessary) 5046N/A * @param b the byte array to convert 5046N/A * @return a converted string which is printable. 5046N/A * Test driver - just reads and parses an LDIF file, printing 5046N/A * each record as interpreted 5046N/A * @param args name of the LDIF file to parse