src/share/classes/javax/swing/text/html/HTMLWriter.java

Print this page




 237         segment.array = null;
 238     }
 239 
 240 
 241     /**
 242      * Writes out the attribute set.  Ignores all
 243      * attributes with a key of type HTML.Tag,
 244      * attributes with a key of type StyleConstants,
 245      * and attributes with a key of type
 246      * HTML.Attribute.ENDTAG.
 247      *
 248      * @param attr   an AttributeSet
 249      * @exception IOException on any I/O error
 250      *
 251      */
 252     protected void writeAttributes(AttributeSet attr) throws IOException {
 253         // translate css attributes to html
 254         convAttr.removeAttributes(convAttr);
 255         convertToHTML32(attr, convAttr);
 256 
 257         Enumeration names = convAttr.getAttributeNames();
 258         while (names.hasMoreElements()) {
 259             Object name = names.nextElement();
 260             if (name instanceof HTML.Tag ||
 261                 name instanceof StyleConstants ||
 262                 name == HTML.Attribute.ENDTAG) {
 263                 continue;
 264             }
 265             write(" " + name + "=\"" + convAttr.getAttribute(name) + "\"");
 266         }
 267     }
 268 
 269     /**
 270      * Writes out all empty elements (all tags that have no
 271      * corresponding end tag).
 272      *
 273      * @param elem   an Element
 274      * @exception IOException on any I/O error
 275      * @exception BadLocationException if pos represents an invalid
 276      *            location within the document.
 277      */


 510                 }
 511                 replaceEntities = true;
 512                 setCanWrapLines(!inPre);
 513                 write(segment.array, segment.offset, segment.count);
 514                 setCanWrapLines(false);
 515                 replaceEntities = false;
 516             }
 517         }
 518     }
 519 
 520     /**
 521      * Writes out the content of the SELECT form element.
 522      *
 523      * @param attr the AttributeSet associated with the form element
 524      * @exception IOException on any I/O error
 525      */
 526     protected void selectContent(AttributeSet attr) throws IOException {
 527         Object model = attr.getAttribute(StyleConstants.ModelAttribute);
 528         incrIndent();
 529         if (model instanceof OptionListModel) {

 530             OptionListModel<Option> listModel = (OptionListModel<Option>) model;
 531             int size = listModel.getSize();
 532             for (int i = 0; i < size; i++) {
 533                 Option option = listModel.getElementAt(i);
 534                 writeOption(option);
 535             }
 536         } else if (model instanceof OptionComboBoxModel) {

 537             OptionComboBoxModel<Option> comboBoxModel = (OptionComboBoxModel<Option>) model;
 538             int size = comboBoxModel.getSize();
 539             for (int i = 0; i < size; i++) {
 540                 Option option = comboBoxModel.getElementAt(i);
 541                 writeOption(option);
 542             }
 543         }
 544         decrIndent();
 545     }
 546 
 547 
 548     /**
 549      * Writes out the content of the Option form element.
 550      * @param option  an Option
 551      * @exception IOException on any I/O error
 552      *
 553      */
 554     protected void writeOption(Option option) throws IOException {
 555 
 556         indentSmart();


 640     void writeComment(String string) throws IOException {
 641         write("<!--");
 642         if (string != null) {
 643             write(string);
 644         }
 645         write("-->");
 646         writeLineSeparator();
 647         indentSmart();
 648     }
 649 
 650 
 651     /**
 652      * Writes out any additional comments (comments outside of the body)
 653      * stored under the property HTMLDocument.AdditionalComments.
 654      */
 655     void writeAdditionalComments() throws IOException {
 656         Object comments = getDocument().getProperty
 657                                         (HTMLDocument.AdditionalComments);
 658 
 659         if (comments instanceof Vector) {
 660             Vector v = (Vector)comments;
 661             for (int counter = 0, maxCounter = v.size(); counter < maxCounter;
 662                  counter++) {
 663                 writeComment(v.elementAt(counter).toString());
 664             }
 665         }
 666     }
 667 
 668 
 669     /**
 670      * Returns true if the element is a
 671      * synthesized element.  Currently we are only testing
 672      * for the p-implied tag.
 673      */
 674     protected boolean synthesizedElement(Element elem) {
 675         if (matchNameAttribute(elem.getAttributes(), HTML.Tag.IMPLIED)) {
 676             return true;
 677         }
 678         return false;
 679     }
 680 


 690             if (name == tag) {
 691                 return true;
 692             }
 693         }
 694         return false;
 695     }
 696 
 697     /**
 698      * Searches for embedded tags in the AttributeSet
 699      * and writes them out.  It also stores these tags in a vector
 700      * so that when appropriate the corresponding end tags can be
 701      * written out.
 702      *
 703      * @exception IOException on any I/O error
 704      */
 705     protected void writeEmbeddedTags(AttributeSet attr) throws IOException {
 706 
 707         // translate css attributes to html
 708         attr = convertToHTML(attr, oConvAttr);
 709 
 710         Enumeration names = attr.getAttributeNames();
 711         while (names.hasMoreElements()) {
 712             Object name = names.nextElement();
 713             if (name instanceof HTML.Tag) {
 714                 HTML.Tag tag = (HTML.Tag)name;
 715                 if (tag == HTML.Tag.FORM || tags.contains(tag)) {
 716                     continue;
 717                 }
 718                 write('<');
 719                 write(tag.toString());
 720                 Object o = attr.getAttribute(tag);
 721                 if (o != null && o instanceof AttributeSet) {
 722                     writeAttributes((AttributeSet)o);
 723                 }
 724                 write('>');
 725                 tags.addElement(tag);
 726                 tagValues.addElement(o);
 727             }
 728         }
 729     }
 730 


 831      */
 832     private boolean indentNext = false;
 833     private boolean indentNeedsIncrementing(Element current, Element next) {
 834         if ((next.getParentElement() == current) && !inPre) {
 835             if (indentNext) {
 836                 indentNext = false;
 837                 return true;
 838             } else if (synthesizedElement(next)) {
 839                 indentNext = true;
 840             } else if (!synthesizedElement(current)){
 841                 return true;
 842             }
 843         }
 844         return false;
 845     }
 846 
 847     /**
 848      * Outputs the maps as elements. Maps are not stored as elements in
 849      * the document, and as such this is used to output them.
 850      */
 851     void writeMaps(Enumeration maps) throws IOException {
 852         if (maps != null) {
 853             while(maps.hasMoreElements()) {
 854                 Map map = (Map)maps.nextElement();
 855                 String name = map.getName();
 856 
 857                 incrIndent();
 858                 indentSmart();
 859                 write("<map");
 860                 if (name != null) {
 861                     write(" name=\"");
 862                     write(name);
 863                     write("\">");
 864                 }
 865                 else {
 866                     write('>');
 867                 }
 868                 writeLineSeparator();
 869                 incrIndent();
 870 
 871                 // Output the areas


 879                         write("></area>");
 880                         writeLineSeparator();
 881                     }
 882                 }
 883                 decrIndent();
 884                 indentSmart();
 885                 write("</map>");
 886                 writeLineSeparator();
 887                 decrIndent();
 888             }
 889         }
 890     }
 891 
 892     /**
 893      * Outputs the styles as a single element. Styles are not stored as
 894      * elements, but part of the document. For the time being styles are
 895      * written out as a comment, inside a style tag.
 896      */
 897     void writeStyles(StyleSheet sheet) throws IOException {
 898         if (sheet != null) {
 899             Enumeration styles = sheet.getStyleNames();
 900             if (styles != null) {
 901                 boolean outputStyle = false;
 902                 while (styles.hasMoreElements()) {
 903                     String name = (String)styles.nextElement();
 904                     // Don't write out the default style.
 905                     if (!StyleContext.DEFAULT_STYLE.equals(name) &&
 906                         writeStyle(name, sheet.getStyle(name), outputStyle)) {
 907                         outputStyle = true;
 908                     }
 909                 }
 910                 if (outputStyle) {
 911                     writeStyleEndTag();
 912                 }
 913             }
 914         }
 915     }
 916 
 917     /**
 918      * Outputs the named style. <code>outputStyle</code> indicates
 919      * whether or not a style has been output yet. This will return
 920      * true if a style is written.
 921      */
 922     boolean writeStyle(String name, Style style, boolean outputStyle)
 923                  throws IOException{
 924         boolean didOutputStyle = false;
 925         Enumeration attributes = style.getAttributeNames();
 926         if (attributes != null) {
 927             while (attributes.hasMoreElements()) {
 928                 Object attribute = attributes.nextElement();
 929                 if (attribute instanceof CSS.Attribute) {
 930                     String value = style.getAttribute(attribute).toString();
 931                     if (value != null) {
 932                         if (!outputStyle) {
 933                             writeStyleStartTag();
 934                             outputStyle = true;
 935                         }
 936                         if (!didOutputStyle) {
 937                             didOutputStyle = true;
 938                             indentSmart();
 939                             write(name);
 940                             write(" {");
 941                         }
 942                         else {
 943                             write(";");
 944                         }
 945                         write(' ');


1015      * Buffer for the purpose of attribute conversion
1016      */
1017     private MutableAttributeSet convAttr = new SimpleAttributeSet();
1018 
1019     /**
1020      * Buffer for the purpose of attribute conversion. This can be
1021      * used if convAttr is being used.
1022      */
1023     private MutableAttributeSet oConvAttr = new SimpleAttributeSet();
1024 
1025     /**
1026      * Create an older style of HTML attributes.  This will
1027      * convert character level attributes that have a StyleConstants
1028      * mapping over to an HTML tag/attribute.  Other CSS attributes
1029      * will be placed in an HTML style attribute.
1030      */
1031     private static void convertToHTML32(AttributeSet from, MutableAttributeSet to) {
1032         if (from == null) {
1033             return;
1034         }
1035         Enumeration keys = from.getAttributeNames();
1036         String value = "";
1037         while (keys.hasMoreElements()) {
1038             Object key = keys.nextElement();
1039             if (key instanceof CSS.Attribute) {
1040                 if ((key == CSS.Attribute.FONT_FAMILY) ||
1041                     (key == CSS.Attribute.FONT_SIZE) ||
1042                     (key == CSS.Attribute.COLOR)) {
1043 
1044                     createFontAttribute((CSS.Attribute)key, from, to);
1045                 } else if (key == CSS.Attribute.FONT_WEIGHT) {
1046                     // add a bold tag is weight is bold
1047                     CSS.FontWeight weightValue = (CSS.FontWeight)
1048                         from.getAttribute(CSS.Attribute.FONT_WEIGHT);
1049                     if ((weightValue != null) && (weightValue.getValue() > 400)) {
1050                         addAttribute(to, HTML.Tag.B, SimpleAttributeSet.EMPTY);
1051                     }
1052                 } else if (key == CSS.Attribute.FONT_STYLE) {
1053                     String s = from.getAttribute(key).toString();
1054                     if (s.indexOf("italic") >= 0) {
1055                         addAttribute(to, HTML.Tag.I, SimpleAttributeSet.EMPTY);


1122             fontAttr = new SimpleAttributeSet();
1123             to.addAttribute(HTML.Tag.FONT, fontAttr);
1124         }
1125         // edit the parameters to the font tag
1126         String htmlValue = from.getAttribute(a).toString();
1127         if (a == CSS.Attribute.FONT_FAMILY) {
1128             fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
1129         } else if (a == CSS.Attribute.FONT_SIZE) {
1130             fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
1131         } else if (a == CSS.Attribute.COLOR) {
1132             fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
1133         }
1134     }
1135 
1136     /**
1137      * Copies the given AttributeSet to a new set, converting
1138      * any CSS attributes found to arguments of an HTML style
1139      * attribute.
1140      */
1141     private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
1142         Enumeration keys = from.getAttributeNames();
1143         String value = "";
1144         while (keys.hasMoreElements()) {
1145             Object key = keys.nextElement();
1146             if (key instanceof CSS.Attribute) {
1147                 value = value + " " + key + "=" + from.getAttribute(key) + ";";
1148             } else {
1149                 to.addAttribute(key, from.getAttribute(key));
1150             }
1151         }
1152         if (value.length() > 0) {
1153             to.addAttribute(HTML.Attribute.STYLE, value);
1154         }
1155     }
1156 
1157     //
1158     // Overrides the writing methods to only break a string when
1159     // canBreakString is true.
1160     // In a future release it is likely AbstractWriter will get this
1161     // functionality.
1162     //




 237         segment.array = null;
 238     }
 239 
 240 
 241     /**
 242      * Writes out the attribute set.  Ignores all
 243      * attributes with a key of type HTML.Tag,
 244      * attributes with a key of type StyleConstants,
 245      * and attributes with a key of type
 246      * HTML.Attribute.ENDTAG.
 247      *
 248      * @param attr   an AttributeSet
 249      * @exception IOException on any I/O error
 250      *
 251      */
 252     protected void writeAttributes(AttributeSet attr) throws IOException {
 253         // translate css attributes to html
 254         convAttr.removeAttributes(convAttr);
 255         convertToHTML32(attr, convAttr);
 256 
 257         Enumeration<?> names = convAttr.getAttributeNames();
 258         while (names.hasMoreElements()) {
 259             Object name = names.nextElement();
 260             if (name instanceof HTML.Tag ||
 261                 name instanceof StyleConstants ||
 262                 name == HTML.Attribute.ENDTAG) {
 263                 continue;
 264             }
 265             write(" " + name + "=\"" + convAttr.getAttribute(name) + "\"");
 266         }
 267     }
 268 
 269     /**
 270      * Writes out all empty elements (all tags that have no
 271      * corresponding end tag).
 272      *
 273      * @param elem   an Element
 274      * @exception IOException on any I/O error
 275      * @exception BadLocationException if pos represents an invalid
 276      *            location within the document.
 277      */


 510                 }
 511                 replaceEntities = true;
 512                 setCanWrapLines(!inPre);
 513                 write(segment.array, segment.offset, segment.count);
 514                 setCanWrapLines(false);
 515                 replaceEntities = false;
 516             }
 517         }
 518     }
 519 
 520     /**
 521      * Writes out the content of the SELECT form element.
 522      *
 523      * @param attr the AttributeSet associated with the form element
 524      * @exception IOException on any I/O error
 525      */
 526     protected void selectContent(AttributeSet attr) throws IOException {
 527         Object model = attr.getAttribute(StyleConstants.ModelAttribute);
 528         incrIndent();
 529         if (model instanceof OptionListModel) {
 530             @SuppressWarnings("unchecked")
 531             OptionListModel<Option> listModel = (OptionListModel<Option>) model;
 532             int size = listModel.getSize();
 533             for (int i = 0; i < size; i++) {
 534                 Option option = listModel.getElementAt(i);
 535                 writeOption(option);
 536             }
 537         } else if (model instanceof OptionComboBoxModel) {
 538             @SuppressWarnings("unchecked")
 539             OptionComboBoxModel<Option> comboBoxModel = (OptionComboBoxModel<Option>) model;
 540             int size = comboBoxModel.getSize();
 541             for (int i = 0; i < size; i++) {
 542                 Option option = comboBoxModel.getElementAt(i);
 543                 writeOption(option);
 544             }
 545         }
 546         decrIndent();
 547     }
 548 
 549 
 550     /**
 551      * Writes out the content of the Option form element.
 552      * @param option  an Option
 553      * @exception IOException on any I/O error
 554      *
 555      */
 556     protected void writeOption(Option option) throws IOException {
 557 
 558         indentSmart();


 642     void writeComment(String string) throws IOException {
 643         write("<!--");
 644         if (string != null) {
 645             write(string);
 646         }
 647         write("-->");
 648         writeLineSeparator();
 649         indentSmart();
 650     }
 651 
 652 
 653     /**
 654      * Writes out any additional comments (comments outside of the body)
 655      * stored under the property HTMLDocument.AdditionalComments.
 656      */
 657     void writeAdditionalComments() throws IOException {
 658         Object comments = getDocument().getProperty
 659                                         (HTMLDocument.AdditionalComments);
 660 
 661         if (comments instanceof Vector) {
 662             Vector<?> v = (Vector)comments;
 663             for (int counter = 0, maxCounter = v.size(); counter < maxCounter;
 664                  counter++) {
 665                 writeComment(v.elementAt(counter).toString());
 666             }
 667         }
 668     }
 669 
 670 
 671     /**
 672      * Returns true if the element is a
 673      * synthesized element.  Currently we are only testing
 674      * for the p-implied tag.
 675      */
 676     protected boolean synthesizedElement(Element elem) {
 677         if (matchNameAttribute(elem.getAttributes(), HTML.Tag.IMPLIED)) {
 678             return true;
 679         }
 680         return false;
 681     }
 682 


 692             if (name == tag) {
 693                 return true;
 694             }
 695         }
 696         return false;
 697     }
 698 
 699     /**
 700      * Searches for embedded tags in the AttributeSet
 701      * and writes them out.  It also stores these tags in a vector
 702      * so that when appropriate the corresponding end tags can be
 703      * written out.
 704      *
 705      * @exception IOException on any I/O error
 706      */
 707     protected void writeEmbeddedTags(AttributeSet attr) throws IOException {
 708 
 709         // translate css attributes to html
 710         attr = convertToHTML(attr, oConvAttr);
 711 
 712         Enumeration<?> names = attr.getAttributeNames();
 713         while (names.hasMoreElements()) {
 714             Object name = names.nextElement();
 715             if (name instanceof HTML.Tag) {
 716                 HTML.Tag tag = (HTML.Tag)name;
 717                 if (tag == HTML.Tag.FORM || tags.contains(tag)) {
 718                     continue;
 719                 }
 720                 write('<');
 721                 write(tag.toString());
 722                 Object o = attr.getAttribute(tag);
 723                 if (o != null && o instanceof AttributeSet) {
 724                     writeAttributes((AttributeSet)o);
 725                 }
 726                 write('>');
 727                 tags.addElement(tag);
 728                 tagValues.addElement(o);
 729             }
 730         }
 731     }
 732 


 833      */
 834     private boolean indentNext = false;
 835     private boolean indentNeedsIncrementing(Element current, Element next) {
 836         if ((next.getParentElement() == current) && !inPre) {
 837             if (indentNext) {
 838                 indentNext = false;
 839                 return true;
 840             } else if (synthesizedElement(next)) {
 841                 indentNext = true;
 842             } else if (!synthesizedElement(current)){
 843                 return true;
 844             }
 845         }
 846         return false;
 847     }
 848 
 849     /**
 850      * Outputs the maps as elements. Maps are not stored as elements in
 851      * the document, and as such this is used to output them.
 852      */
 853     void writeMaps(Enumeration<?> maps) throws IOException {
 854         if (maps != null) {
 855             while(maps.hasMoreElements()) {
 856                 Map map = (Map)maps.nextElement();
 857                 String name = map.getName();
 858 
 859                 incrIndent();
 860                 indentSmart();
 861                 write("<map");
 862                 if (name != null) {
 863                     write(" name=\"");
 864                     write(name);
 865                     write("\">");
 866                 }
 867                 else {
 868                     write('>');
 869                 }
 870                 writeLineSeparator();
 871                 incrIndent();
 872 
 873                 // Output the areas


 881                         write("></area>");
 882                         writeLineSeparator();
 883                     }
 884                 }
 885                 decrIndent();
 886                 indentSmart();
 887                 write("</map>");
 888                 writeLineSeparator();
 889                 decrIndent();
 890             }
 891         }
 892     }
 893 
 894     /**
 895      * Outputs the styles as a single element. Styles are not stored as
 896      * elements, but part of the document. For the time being styles are
 897      * written out as a comment, inside a style tag.
 898      */
 899     void writeStyles(StyleSheet sheet) throws IOException {
 900         if (sheet != null) {
 901             Enumeration<?> styles = sheet.getStyleNames();
 902             if (styles != null) {
 903                 boolean outputStyle = false;
 904                 while (styles.hasMoreElements()) {
 905                     String name = (String)styles.nextElement();
 906                     // Don't write out the default style.
 907                     if (!StyleContext.DEFAULT_STYLE.equals(name) &&
 908                         writeStyle(name, sheet.getStyle(name), outputStyle)) {
 909                         outputStyle = true;
 910                     }
 911                 }
 912                 if (outputStyle) {
 913                     writeStyleEndTag();
 914                 }
 915             }
 916         }
 917     }
 918 
 919     /**
 920      * Outputs the named style. <code>outputStyle</code> indicates
 921      * whether or not a style has been output yet. This will return
 922      * true if a style is written.
 923      */
 924     boolean writeStyle(String name, Style style, boolean outputStyle)
 925                  throws IOException{
 926         boolean didOutputStyle = false;
 927         Enumeration<?> attributes = style.getAttributeNames();
 928         if (attributes != null) {
 929             while (attributes.hasMoreElements()) {
 930                 Object attribute = attributes.nextElement();
 931                 if (attribute instanceof CSS.Attribute) {
 932                     String value = style.getAttribute(attribute).toString();
 933                     if (value != null) {
 934                         if (!outputStyle) {
 935                             writeStyleStartTag();
 936                             outputStyle = true;
 937                         }
 938                         if (!didOutputStyle) {
 939                             didOutputStyle = true;
 940                             indentSmart();
 941                             write(name);
 942                             write(" {");
 943                         }
 944                         else {
 945                             write(";");
 946                         }
 947                         write(' ');


1017      * Buffer for the purpose of attribute conversion
1018      */
1019     private MutableAttributeSet convAttr = new SimpleAttributeSet();
1020 
1021     /**
1022      * Buffer for the purpose of attribute conversion. This can be
1023      * used if convAttr is being used.
1024      */
1025     private MutableAttributeSet oConvAttr = new SimpleAttributeSet();
1026 
1027     /**
1028      * Create an older style of HTML attributes.  This will
1029      * convert character level attributes that have a StyleConstants
1030      * mapping over to an HTML tag/attribute.  Other CSS attributes
1031      * will be placed in an HTML style attribute.
1032      */
1033     private static void convertToHTML32(AttributeSet from, MutableAttributeSet to) {
1034         if (from == null) {
1035             return;
1036         }
1037         Enumeration<?> keys = from.getAttributeNames();
1038         String value = "";
1039         while (keys.hasMoreElements()) {
1040             Object key = keys.nextElement();
1041             if (key instanceof CSS.Attribute) {
1042                 if ((key == CSS.Attribute.FONT_FAMILY) ||
1043                     (key == CSS.Attribute.FONT_SIZE) ||
1044                     (key == CSS.Attribute.COLOR)) {
1045 
1046                     createFontAttribute((CSS.Attribute)key, from, to);
1047                 } else if (key == CSS.Attribute.FONT_WEIGHT) {
1048                     // add a bold tag is weight is bold
1049                     CSS.FontWeight weightValue = (CSS.FontWeight)
1050                         from.getAttribute(CSS.Attribute.FONT_WEIGHT);
1051                     if ((weightValue != null) && (weightValue.getValue() > 400)) {
1052                         addAttribute(to, HTML.Tag.B, SimpleAttributeSet.EMPTY);
1053                     }
1054                 } else if (key == CSS.Attribute.FONT_STYLE) {
1055                     String s = from.getAttribute(key).toString();
1056                     if (s.indexOf("italic") >= 0) {
1057                         addAttribute(to, HTML.Tag.I, SimpleAttributeSet.EMPTY);


1124             fontAttr = new SimpleAttributeSet();
1125             to.addAttribute(HTML.Tag.FONT, fontAttr);
1126         }
1127         // edit the parameters to the font tag
1128         String htmlValue = from.getAttribute(a).toString();
1129         if (a == CSS.Attribute.FONT_FAMILY) {
1130             fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
1131         } else if (a == CSS.Attribute.FONT_SIZE) {
1132             fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
1133         } else if (a == CSS.Attribute.COLOR) {
1134             fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
1135         }
1136     }
1137 
1138     /**
1139      * Copies the given AttributeSet to a new set, converting
1140      * any CSS attributes found to arguments of an HTML style
1141      * attribute.
1142      */
1143     private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
1144         Enumeration<?> keys = from.getAttributeNames();
1145         String value = "";
1146         while (keys.hasMoreElements()) {
1147             Object key = keys.nextElement();
1148             if (key instanceof CSS.Attribute) {
1149                 value = value + " " + key + "=" + from.getAttribute(key) + ";";
1150             } else {
1151                 to.addAttribute(key, from.getAttribute(key));
1152             }
1153         }
1154         if (value.length() > 0) {
1155             to.addAttribute(HTML.Attribute.STYLE, value);
1156         }
1157     }
1158 
1159     //
1160     // Overrides the writing methods to only break a string when
1161     // canBreakString is true.
1162     // In a future release it is likely AbstractWriter will get this
1163     // functionality.
1164     //