685 callIndent = true; 686 } 687 writeStartTag("<span style=\"" + style + "\">"); 688 if (callIndent) { 689 indent(); 690 } 691 } 692 693 /** 694 * Writes out an end tag for the <span> tag. 695 * 696 * @exception IOException on any I/O error 697 */ 698 private void endSpanTag() throws IOException { 699 write(NEWLINE); 700 writeEndTag("</span>"); 701 fontAttributes = null; 702 } 703 704 /** 705 * Adds the style named <code>style</code> to the style mapping. This 706 * returns the name that should be used when outputting. CSS does not 707 * allow the full Unicode set to be used as a style name. 708 */ 709 private String addStyleName(String style) { 710 if (styleNameMapping == null) { 711 return style; 712 } 713 StringBuilder sb = null; 714 for (int counter = style.length() - 1; counter >= 0; counter--) { 715 if (!isValidCharacter(style.charAt(counter))) { 716 if (sb == null) { 717 sb = new StringBuilder(style); 718 } 719 sb.setCharAt(counter, 'a'); 720 } 721 } 722 String mappedName = (sb != null) ? sb.toString() : style; 723 while (styleNameMapping.get(mappedName) != null) { 724 mappedName = mappedName + 'x'; 725 } 726 styleNameMapping.put(style, mappedName); 727 return mappedName; 728 } 729 730 /** 731 * Returns the mapped style name corresponding to <code>style</code>. 732 */ 733 private String mapStyleName(String style) { 734 if (styleNameMapping == null) { 735 return style; 736 } 737 String retValue = styleNameMapping.get(style); 738 return (retValue == null) ? style : retValue; 739 } 740 741 private boolean isValidCharacter(char character) { 742 return ((character >= 'a' && character <= 'z') || 743 (character >= 'A' && character <= 'Z')); 744 } 745 } | 685 callIndent = true; 686 } 687 writeStartTag("<span style=\"" + style + "\">"); 688 if (callIndent) { 689 indent(); 690 } 691 } 692 693 /** 694 * Writes out an end tag for the <span> tag. 695 * 696 * @exception IOException on any I/O error 697 */ 698 private void endSpanTag() throws IOException { 699 write(NEWLINE); 700 writeEndTag("</span>"); 701 fontAttributes = null; 702 } 703 704 /** 705 * Adds the style named {@code style} to the style mapping. This 706 * returns the name that should be used when outputting. CSS does not 707 * allow the full Unicode set to be used as a style name. 708 */ 709 private String addStyleName(String style) { 710 if (styleNameMapping == null) { 711 return style; 712 } 713 StringBuilder sb = null; 714 for (int counter = style.length() - 1; counter >= 0; counter--) { 715 if (!isValidCharacter(style.charAt(counter))) { 716 if (sb == null) { 717 sb = new StringBuilder(style); 718 } 719 sb.setCharAt(counter, 'a'); 720 } 721 } 722 String mappedName = (sb != null) ? sb.toString() : style; 723 while (styleNameMapping.get(mappedName) != null) { 724 mappedName = mappedName + 'x'; 725 } 726 styleNameMapping.put(style, mappedName); 727 return mappedName; 728 } 729 730 /** 731 * Returns the mapped style name corresponding to {@code style}. 732 */ 733 private String mapStyleName(String style) { 734 if (styleNameMapping == null) { 735 return style; 736 } 737 String retValue = styleNameMapping.get(style); 738 return (retValue == null) ? style : retValue; 739 } 740 741 private boolean isValidCharacter(char character) { 742 return ((character >= 'a' && character <= 'z') || 743 (character >= 'A' && character <= 'Z')); 744 } 745 } |