Commit 51af83eb authored by Steve Sonntag's avatar Steve Sonntag

Undo split of wrong lines, generated DSML is invalid

parent 7357a04d
/* **************************************************************************
* $Novell: DSMLWriter.java,v 1.34 2003/01/28 23:52:25 $
* $Novell: DSMLWriter.java,v 1.33 2003/01/22 22:30:27 $
*
* Copyright (C) 2002 Novell, Inc. All Rights Reserved.
*
......@@ -44,7 +44,6 @@ public class DSMLWriter implements LDAPWriter {
"<batchRequest xmlns=\"urn:oasis:names:tc:DSML:2:0:core\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
private static final String BATCH_RESPONSE_START =
"<batchResponse xmlns=\"urn:oasis:names:tc:DSML:2:0:core\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
private int MAX_DOC_WIDTH = 75;
/**
* Initializes this writer by opening the specified file to write DSML into.
......@@ -550,10 +549,6 @@ public class DSMLWriter implements LDAPWriter {
/**
* Used to write an attribute and its values.
*
* <p>If the value to be written is over MAX_DOC_WIDTH characters AND
* newLines is set to true, then the value will be wrapped</p>
*
* @param attr Attribute to be written.
*/
private void writeAttribute(LDAPAttribute attr) throws IOException
......@@ -566,42 +561,22 @@ public class DSMLWriter implements LDAPWriter {
byte bytevalues[][] = attr.getByteValueArray();
for(int i=0; i<values.length; i++){
newLine(4);
String toWrite;
if (Base64.isValidUTF8(bytevalues[i], false)){
out.write("<value>");
newLine(0);
toWrite = values[i];
out.write(values[i]);
out.write("</value>");
} else {
// Base 64 encode this
out.write("<value xsi:type=\"xsd:base64Binary\">");
newLine(0);
toWrite = Base64.encode(bytevalues[i]);
out.write(Base64.encode(bytevalues[i]));
out.write("</value>");
}
int lineLength = toWrite.length();
//test it the value should be wrapped
if ( (this.indent == false) ||
(lineLength <= this.MAX_DOC_WIDTH) ) {
out.write(toWrite);
} else {
//Add new lines into each attribute value
int offset = 0;
while( (lineLength - offset) > this.MAX_DOC_WIDTH){
out.write(toWrite, offset, this.MAX_DOC_WIDTH);
newLine(0);
offset += this.MAX_DOC_WIDTH;
}
out.write(toWrite, offset, lineLength - offset);
newLine(4);
}
out.write("</value>");
}
newLine(3);
out.write("</attr>");
return;
}
/**
* Tests the current state with a new message that is either a response or
* request. If the state is NEW_BATCH, check_state will print an
......@@ -663,8 +638,7 @@ public class DSMLWriter implements LDAPWriter {
* make output more readable.
*
* <p>For efficiency, useIndent is set to false by default. The size of an
* indentation can be set using the method <tt>setIndent</tt>. This also
* will cause attributes over 76 characters to be continued on a new line.
* indentation can be set using the method <tt>setIndent</tt>.
* @param useIndent Indicates whether indentation and newlines should be
* written to make the output DSML more readable.
* @see #setIndent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment