/**
  * Add an attribute only if it doesn't exist so that we don't loose information replacing it with
  * SimpleAttributeSet.EMPTY
  */
 private static void addAttribute(MutableAttributeSet to, Object key, Object value) {
   Object attr = to.getAttribute(key);
   if (attr == null || attr == SimpleAttributeSet.EMPTY) {
     to.addAttribute(key, value);
   } else {
     if (attr instanceof MutableAttributeSet && value instanceof AttributeSet) {
       ((MutableAttributeSet) attr).addAttributes((AttributeSet) value);
     }
   }
 }
 @Override
 public void handleStartTag(HTML.Tag tag, MutableAttributeSet attr, int pos) {
   // <B>が出たら次の地の文はカテゴリ名。なのでフラグを立てる。
   if (tag.equals(HTML.Tag.B)) {
     start_bold = true;
     start_category_flag = true;
   }
   // <A>タグが出たらurlを保持。あとで板名とペアにする。
   if (tag.equals(HTML.Tag.A)) {
     // 頭についてる広告タグは無視。
     if (parse_2ch_start_flag) {
       String href = (String) attr.getAttribute(HTML.Attribute.HREF);
       next_board_url = href;
     }
   }
 }
 /**
  * Create/update an HTML &lt;font&gt; tag attribute. The value of the attribute should be a
  * MutableAttributeSet so that the attributes can be updated as they are discovered.
  */
 private static void createFontAttribute(
     CSS.Attribute a, AttributeSet from, MutableAttributeSet to) {
   MutableAttributeSet fontAttr = (MutableAttributeSet) to.getAttribute(HTML.Tag.FONT);
   if (fontAttr == null) {
     fontAttr = new SimpleAttributeSet();
     to.addAttribute(HTML.Tag.FONT, fontAttr);
   }
   // edit the parameters to the font tag
   String htmlValue = from.getAttribute(a).toString();
   if (a == CSS.Attribute.FONT_FAMILY) {
     fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
   } else if (a == CSS.Attribute.FONT_SIZE) {
     fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
   } else if (a == CSS.Attribute.COLOR) {
     fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
   }
 }