Closed
Bug 150865
Opened 23 years ago
Closed 6 years ago
LDIFWriter doesn't like windows
Categories
(Directory :: LDAP Java SDK, defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: bemtya, Assigned: erhyuan)
Details
The LDIFWriter class does not use the operating system separator to separate
out ldif records. The work around I used is below.
import netscape.ldap.util.*;
import java.io.*;
public class GALDIFWriter extends netscape.ldap.util.LDIFWriter {
static String m_lineSep = null;
private boolean m_foldLines;
private static final int MAX_LINE = 77;
private static GALDIF m_LDIF = null;
public GALDIFWriter( PrintWriter pw ) throws IOException {
super( pw );
m_lineSep = System.getProperty( "line.separator" );
m_foldLines = true;
m_LDIF = new GALDIF();
}
public GALDIFWriter( PrintWriter pw, boolean attrsOnly,
String separator, boolean foldLines,
boolean toFiles ) throws
IOException {
super( pw, attrsOnly, separator, foldLines, toFiles );
m_lineSep = System.getProperty( "line.separator" );
m_foldLines = foldLines;
m_LDIF = new GALDIF();
}
protected void printString( String value ) {
if ( m_foldLines ) {
m_LDIF.breakString( m_pw, value, MAX_LINE );
} else {
m_pw.print( value );
m_pw.print( m_lineSep );
}
}
}
import netscape.ldap.util.*;
import java.io.*;
public class GALDIF extends netscape.ldap.util.LDIF {
static String m_lineSep = null;
public GALDIF() throws IOException {
super();
m_lineSep = System.getProperty( "line.separator" );
}
public GALDIF(String file) throws IOException {
super( file );
m_lineSep = System.getProperty( "line.separator" );
}
public GALDIF(DataInputStream ds) throws IOException {
super( ds );
m_lineSep = System.getProperty( "line.separator" );
}
public static void breakString( PrintWriter pw, String value, int max) {
int leftToGo = value.length();
int written = 0;
int maxChars = max;
/* Limit to 77 characters per line */
while( leftToGo > 0 ) {
int toWrite = Math.min( maxChars, leftToGo );
String s = value.substring( written, written+toWrite);
if ( written != 0 ) {
pw.print( " " + s );
} else {
pw.print( s );
maxChars -= 1;
}
written += toWrite;
leftToGo -= toWrite;
/* Don't use pw.println, because it outputs an extra CR
in Win32 */
pw.print( m_lineSep );
}
}
}
Comment 3•21 years ago
|
||
Reassign LDAP JDK bugs owned by Miodrag (miodrag@formerly-netscape.com.tld) to
E-Y (erhyuan@pacbell.net)
Assignee: miodrag → erhyuan
Comment 4•6 years ago
|
||
Not activity for at least 6 years, closing.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•