예제 #1
0
 /**
  * Write a character array to the output Writer, properly handling newlines and, if needed,
  * wrapping lines as they are output.
  *
  * @since 1.3
  */
 protected void write(char[] data, int start, int len) throws IOException {
   if (getCanWrapLines()) {
     // FIXME: should we be handling newlines specially here?
     for (int i = 0; i < len; ) {
       int start_i = i;
       // Find next space.
       while (i < len && data[start + i] != ' ') ++i;
       if (i < len && lineLength + i - start_i >= maxLineLength) writeLineSeparator();
       else if (i < len) {
         // Write the trailing space.
         ++i;
       }
       // Write out the text.
       output(data, start + start_i, start + i - start_i);
     }
   } else {
     int saved_i = start;
     for (int i = start; i < start + len; ++i) {
       if (data[i] == NEWLINE) {
         output(data, saved_i, i - saved_i);
         writeLineSeparator();
       }
     }
     if (saved_i < start + len - 1) output(data, saved_i, start + len - saved_i);
   }
 }
예제 #2
0
 /** Print the given AttributeSet as a sequence of assignment-like strings, e.g. "key=value". */
 protected void writeAttributes(AttributeSet attrs) throws IOException {
   Enumeration e = attrs.getAttributeNames();
   while (e.hasMoreElements()) {
     Object name = e.nextElement();
     Object val = attrs.getAttribute(name);
     write(name + "=" + val);
     writeLineSeparator();
   }
 }
예제 #3
0
 /**
  * Writes the line separator. This is overriden to make sure we don't replace the newline content
  * in case it is outside normal ascii.
  */
 protected void writeLineSeparator() throws IOException {
   boolean oldReplace = replaceEntities;
   replaceEntities = false;
   super.writeLineSeparator();
   replaceEntities = oldReplace;
 }