//# 2 errors, 235 messages
//#
/*
    //#Line.java:1:1: class: com.dmdirc.addons.ui_swing.textpane.Line
    //#Line.java:1:1: method: com.dmdirc.addons.ui_swing.textpane.Line.com.dmdirc.addons.ui_swing.textpane.Line__static_init
 * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.dmdirc.addons.ui_swing.textpane;

import com.dmdirc.config.ConfigManager;
import com.dmdirc.logger.ErrorLevel;
import com.dmdirc.logger.Logger;
import com.dmdirc.ui.messages.IRCTextAttribute;
import com.dmdirc.ui.messages.Styliser;

import java.awt.Font;
import java.awt.font.TextAttribute;
import java.text.AttributedString;
import java.util.Arrays;
import java.util.Enumeration;

import javax.swing.UIManager;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.StyleConstants.CharacterConstants;
import javax.swing.text.StyleConstants.ColorConstants;
import javax.swing.text.StyleConstants.FontConstants;
import javax.swing.text.StyledDocument;

/**
 * Represents a line of text in IRC.
 */
public class Line {

    private final String[] lineParts;
    private final ConfigManager config;
    private int lineHeight;

    /**
     * Creates a new line.
     * 
     * @param lineParts Parts of the line
     * @param config Configuration manager for this line
     */
    public Line(final String[] lineParts, final ConfigManager config) {
    //#Line.java:60: method: void com.dmdirc.addons.ui_swing.textpane.Line.com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)
    //#input(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): config
    //#input(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): lineParts
    //#input(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this
    //#output(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this.config
    //#output(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this.lineHeight
    //#output(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this.lineParts
    //#presumption(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): javax.swing.UIManager:getFont(...)@63 != null
    //#post(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this.config == config
    //#post(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): init'ed(this.config)
    //#post(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): init'ed(this.lineHeight)
    //#post(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): this.lineParts == lineParts
    //#post(void com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)): init'ed(this.lineParts)
        this.lineParts = lineParts;
        this.config = config;
        this.lineHeight = UIManager.getFont("TextPane.font").getSize();
    }
    //#Line.java:64: end of method: void com.dmdirc.addons.ui_swing.textpane.Line.com.dmdirc.addons.ui_swing.textpane.Line(String[], ConfigManager)

    /**
     * Returns the line parts of this line.
     *
     * @return Lines parts
     */
    public String[] getLineParts() {
        return lineParts;
    //#Line.java:72: method: String[] com.dmdirc.addons.ui_swing.textpane.Line.getLineParts()
    //#input(String[] getLineParts()): this
    //#input(String[] getLineParts()): this.lineParts
    //#output(String[] getLineParts()): return_value
    //#post(String[] getLineParts()): return_value == this.lineParts
    //#post(String[] getLineParts()): init'ed(return_value)
    //#Line.java:72: end of method: String[] com.dmdirc.addons.ui_swing.textpane.Line.getLineParts()
    }

    /**
     * Returns the length of the specified line
     * 
     * @return Length of the line
     */
    public int getLength() {
        int length = 0;
    //#Line.java:81: method: int com.dmdirc.addons.ui_swing.textpane.Line.getLength()
    //#input(int getLength()): this
    //#input(int getLength()): this.lineParts
    //#input(int getLength()): this.lineParts.length
    //#input(int getLength()): this.lineParts[0..4_294_967_295]
    //#output(int getLength()): return_value
    //#pre[2] (int getLength()): this.lineParts != null
    //#pre[3] (int getLength()): this.lineParts.length <= 4_294_967_295
    //#pre[4] (int getLength()): (soft) this.lineParts[0..4_294_967_295] != null
    //#post(int getLength()): init'ed(return_value)
        for (String linePart : lineParts) {
            length += linePart.length();
    //#Line.java:83: ?overflow
    //#    length + java/lang/String:length(...) in {-2_147_483_648..4_294_967_295}
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: int getLength()
    //#    basic block: bb_3
    //#    assertion: length + java/lang/String:length(...) in {-2_147_483_648..4_294_967_295}
    //#    VN: java.lang.String:length(...)@83 + length
    //#    Expected: {-2_147_483_648..4_294_967_295, Invalid}
    //#    Bad: {4_294_967_296..8_589_934_590}
    //#    Attribs:  Int  Bad > Exp
        }
        return length;
    //#Line.java:85: end of method: int com.dmdirc.addons.ui_swing.textpane.Line.getLength()
    }

    /**
     * Returns the height of the specified line.
     * 
     * @return Line height
     */
    public int getHeight() {
        return lineHeight;
    //#Line.java:94: method: int com.dmdirc.addons.ui_swing.textpane.Line.getHeight()
    //#input(int getHeight()): this
    //#input(int getHeight()): this.lineHeight
    //#output(int getHeight()): return_value
    //#pre[2] (int getHeight()): init'ed(this.lineHeight)
    //#post(int getHeight()): return_value == this.lineHeight
    //#post(int getHeight()): init'ed(return_value)
    //#Line.java:94: end of method: int com.dmdirc.addons.ui_swing.textpane.Line.getHeight()
    }

    /**
     * Returns the Line text at the specified number.
     *
     * @return Line at the specified number or null
     */
    public String getText() {
        StringBuilder lineText = new StringBuilder();
    //#Line.java:103: method: String com.dmdirc.addons.ui_swing.textpane.Line.getText()
    //#input(String getText()): this
    //#input(String getText()): this.lineParts
    //#input(String getText()): this.lineParts.length
    //#input(String getText()): this.lineParts[0..4_294_967_295]
    //#input(String getText()): this.lineParts[0..4_294_967_295]._tainted
    //#output(String getText()): return_value
    //#pre[2] (String getText()): this.lineParts != null
    //#pre[3] (String getText()): this.lineParts.length <= 4_294_967_295
    //#pre[4] (String getText()): (soft) init'ed(this.lineParts[0..4_294_967_295])
    //#post(String getText()): init'ed(return_value)
        for (String linePart : lineParts) {
            lineText.append(linePart);
        }
        return Styliser.stipControlCodes(lineText.toString());
    //#Line.java:107: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.ui.messages.Styliser:stipControlCodes(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: String getText()
    //#    unanalyzed callee: String com.dmdirc.ui.messages.Styliser:stipControlCodes(String)
    //#Line.java:107: end of method: String com.dmdirc.addons.ui_swing.textpane.Line.getText()
    }

    /**
     * Returns the Line text at the specified number.
     *
     * @return Line at the specified number or null
     *
     * @since 0.6.3m1
     */
    public String getStyledText() {
        StringBuilder lineText = new StringBuilder();
    //#Line.java:118: method: String com.dmdirc.addons.ui_swing.textpane.Line.getStyledText()
    //#input(String getStyledText()): this
    //#input(String getStyledText()): this.lineParts
    //#input(String getStyledText()): this.lineParts.length
    //#input(String getStyledText()): this.lineParts[0..4_294_967_295]
    //#input(String getStyledText()): this.lineParts[0..4_294_967_295]._tainted
    //#output(String getStyledText()): java.lang.StringBuilder:toString(...)._tainted
    //#output(String getStyledText()): return_value
    //#new obj(String getStyledText()): java.lang.StringBuilder:toString(...)
    //#pre[2] (String getStyledText()): this.lineParts != null
    //#pre[3] (String getStyledText()): this.lineParts.length <= 4_294_967_295
    //#pre[4] (String getStyledText()): (soft) init'ed(this.lineParts[0..4_294_967_295])
    //#post(String getStyledText()): init'ed(java.lang.StringBuilder:toString(...)._tainted)
    //#post(String getStyledText()): return_value == &java.lang.StringBuilder:toString(...)
        for (String linePart : lineParts) {
            lineText.append(linePart);
        }
        return lineText.toString();
    //#Line.java:122: end of method: String com.dmdirc.addons.ui_swing.textpane.Line.getStyledText()
    }

    /**
     * Converts a StyledDocument into an AttributedString.
     *
     * @return AttributedString representing the specified StyledDocument
     */
    public AttributedString getStyled() {
        final StyledDocument doc = Styliser.getStyledString(lineParts);
    //#Line.java:131: method: AttributedString com.dmdirc.addons.ui_swing.textpane.Line.getStyled()
    //#Line.java:131: Warning: method not available - call not analyzed
    //#    call on StyledDocument com.dmdirc.ui.messages.Styliser:getStyledString(String[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: AttributedString getStyled()
    //#    unanalyzed callee: StyledDocument com.dmdirc.ui.messages.Styliser:getStyledString(String[])
    //#input(AttributedString getStyled()): "."._tainted
    //#input(AttributedString getStyled()): "Config option not found: "._tainted
    //#input(AttributedString getStyled()): "Unable to insert styled string: "._tainted
    //#input(AttributedString getStyled()): "textPaneFontName"._tainted
    //#input(AttributedString getStyled()): "ui"._tainted
    //#input(AttributedString getStyled()): com.dmdirc.logger.ErrorLevel.MEDIUM
    //#input(AttributedString getStyled()): com.dmdirc.ui.messages.IRCTextAttribute.CHANNEL
    //#input(AttributedString getStyled()): com.dmdirc.ui.messages.IRCTextAttribute.HYPERLINK
    //#input(AttributedString getStyled()): com.dmdirc.ui.messages.IRCTextAttribute.NICKNAME
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.__Descendant_Table[com/dmdirc/config/ConfigManager]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.__Descendant_Table[others]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.__Dispatch_Table.getOption(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.__Dispatch_Table.hasOption(Ljava/lang/String;Ljava/lang/String;)Z
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.__Dispatch_Table.hasOptionString(Ljava/lang/String;Ljava/lang/String;)Z
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigManager.stats
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Descendant_Table[com/dmdirc/config/ConfigManager]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Descendant_Table[com/dmdirc/config/ConfigSource]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Descendant_Table[com/dmdirc/config/Identity]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Descendant_Table[others]
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Dispatch_Table.getOption(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //#input(AttributedString getStyled()): com/dmdirc/config/ConfigSource.__Dispatch_Table.hasOption(Ljava/lang/String;Ljava/lang/String;)Z
    //#input(AttributedString getStyled()): com/dmdirc/config/Identity.__Descendant_Table[com/dmdirc/config/Identity]
    //#input(AttributedString getStyled()): com/dmdirc/config/Identity.__Descendant_Table[others]
    //#input(AttributedString getStyled()): com/dmdirc/config/Identity.__Dispatch_Table.getOption(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //#input(AttributedString getStyled()): com/dmdirc/config/Identity.__Dispatch_Table.hasOption(Ljava/lang/String;Ljava/lang/String;)Z
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.BACKGROUND
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.FAMILY
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.FOREGROUND
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.POSTURE
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.POSTURE_OBLIQUE
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.SIZE
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.UNDERLINE
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.UNDERLINE_ON
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.WEIGHT
    //#input(AttributedString getStyled()): java.awt.font.TextAttribute.WEIGHT_BOLD
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$CharacterConstants.Underline
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$ColorConstants.Background
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$ColorConstants.Foreground
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$FontConstants.Bold
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$FontConstants.Family
    //#input(AttributedString getStyled()): javax.swing.text.StyleConstants$FontConstants.Italic
    //#input(AttributedString getStyled()): this
    //#input(AttributedString getStyled()): this.config
    //#input(AttributedString getStyled()): this.config.__Tag
    //#input(AttributedString getStyled()): this.config.file
    //#input(AttributedString getStyled()): this.config.sources
    //#input(AttributedString getStyled()): this.lineParts
    //#output(AttributedString getStyled()): new AttributedString(getStyled#1) num objects
    //#output(AttributedString getStyled()): new AttributedString(getStyled#4) num objects
    //#output(AttributedString getStyled()): return_value
    //#output(AttributedString getStyled()): this.lineHeight
    //#new obj(AttributedString getStyled()): new AttributedString(getStyled#1)
    //#new obj(AttributedString getStyled()): new AttributedString(getStyled#4)
    //#pre[2] (AttributedString getStyled()): this.config != null
    //#pre[4] (AttributedString getStyled()): this.config.__Tag == com/dmdirc/config/ConfigManager
    //#pre[6] (AttributedString getStyled()): (soft) this.config.sources != null
    //#presumption(AttributedString getStyled()): init'ed(com.dmdirc.logger.ErrorLevel.MEDIUM)
    //#presumption(AttributedString getStyled()): init'ed(com.dmdirc.ui.messages.IRCTextAttribute.CHANNEL)
    //#presumption(AttributedString getStyled()): init'ed(com.dmdirc.ui.messages.IRCTextAttribute.HYPERLINK)
    //#presumption(AttributedString getStyled()): init'ed(com.dmdirc.ui.messages.IRCTextAttribute.NICKNAME)
    //#presumption(AttributedString getStyled()): com.dmdirc.ui.messages.Styliser:getStyledString(...)@131 != null
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.BACKGROUND)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.FAMILY)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.FOREGROUND)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.POSTURE)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.POSTURE_OBLIQUE)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.SIZE)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.UNDERLINE)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.UNDERLINE_ON)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.WEIGHT)
    //#presumption(AttributedString getStyled()): init'ed(java.awt.font.TextAttribute.WEIGHT_BOLD)
    //#presumption(AttributedString getStyled()): java.text.AttributedString:getIterator(...)@159 != null
    //#presumption(AttributedString getStyled()): java.text.AttributedString:getIterator(...)@233 != null
    //#presumption(AttributedString getStyled()): javax.swing.UIManager:getFont(...)@144 != null
    //#presumption(AttributedString getStyled()): javax.swing.text.AttributeSet:getAttributeNames(...)@169 != null
    //#presumption(AttributedString getStyled()): javax.swing.text.Element:getAttributes(...)@168 != null
    //#presumption(AttributedString getStyled()): javax.swing.text.Element:getDocument(...)@136 != null
    //#presumption(AttributedString getStyled()): javax.swing.text.Element:getDocument(...)@136 != null
    //#presumption(AttributedString getStyled()): javax.swing.text.Element:getElement(...)@166 != null
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$CharacterConstants.Underline)
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$ColorConstants.Background)
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$ColorConstants.Foreground)
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$FontConstants.Bold)
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$FontConstants.Family)
    //#presumption(AttributedString getStyled()): init'ed(javax.swing.text.StyleConstants$FontConstants.Italic)
    //#presumption(AttributedString getStyled()): javax.swing.text.StyledDocument:getParagraphElement(...)@134 != null
    //#post(AttributedString getStyled()): return_value in Addr_Set{&new AttributedString(getStyled#1),&new AttributedString(getStyled#4)}
    //#post(AttributedString getStyled()): init'ed(this.lineHeight)
    //#post(AttributedString getStyled()): new AttributedString(getStyled#1) num objects == 1
    //#post(AttributedString getStyled()): new AttributedString(getStyled#4) num objects <= 1
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:hasOption
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.Map:containsKey
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.Map:get
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.Integer:intValue
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.Integer:valueOf
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.Map:put
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:getOption
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.IllegalArgumentException
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:java.lang.String:isEmpty
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:com.dmdirc.util.ConfigFile:getKeyDomain
    //#unanalyzed(AttributedString getStyled()): Effects-of-calling:com.dmdirc.util.ConfigFile:isKeyDomain
    //#test_vector(AttributedString getStyled()): java.text.AttributedCharacterIterator:getEndIndex(...)@159: {0}, {-2_147_483_648..-1, 1..4_294_967_295}
    //#test_vector(AttributedString getStyled()): java.text.AttributedCharacterIterator:getEndIndex(...)@233: {-2_147_483_648..-1, 1..4_294_967_295}, {0}
    //#test_vector(AttributedString getStyled()): java.util.Enumeration:hasMoreElements(...)@171: {0}, {1}

        AttributedString attString = null;
        final Element line = doc.getParagraphElement(0);
        try {
            attString = new AttributedString(line.getDocument().getText(0,
                    line.getDocument().getLength()));
        } catch (BadLocationException ex) {
            Logger.userError(ErrorLevel.MEDIUM,
    //#Line.java:139: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: AttributedString getStyled()
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
                    "Unable to insert styled string: " +
                    ex.getMessage());
        }

        final Font defaultFont = UIManager.getFont("TextPane.font");
        String fontName = null;
    //#Line.java:145: Warning: unused assignment
    //#    Unused assignment into fontName
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: AttributedString getStyled()
    //#    Attribs:  Uncertain
        int fontSize = -1;
    //#Line.java:146: Warning: unused assignment
    //#    Unused assignment into fontSize
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: AttributedString getStyled()
    //#    Attribs:  Uncertain
        if (config.hasOptionString("ui", "textPaneFontName")) {
            fontName = config.getOption("ui", "textPaneFontName");
        } else {
            fontName = defaultFont.getName();
        }
        //TODO issue 2251
        //if (config.hasOptionString("ui", "textPaneFontSize")) {
        //    fontSize = config.getOptionInt("ui", "textPaneFontSize");
        //} else {
            fontSize = defaultFont.getSize();
        //}
        lineHeight = fontSize;
        if (attString.getIterator().getEndIndex() != 0) {
    //#Line.java:159: ?null dereference
    //#    attString != null
    //#    severity: MEDIUM
    //#    class: com.dmdirc.addons.ui_swing.textpane.Line
    //#    method: AttributedString getStyled()
    //#    basic block: bb_7
    //#    assertion: attString != null
    //#    VN: attString
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
            final Font font = new Font(fontName, Font.PLAIN, fontSize);
            attString.addAttribute(TextAttribute.SIZE, font.getSize());
            attString.addAttribute(TextAttribute.FAMILY, font.getFamily());
        }

        for (int i = 0; i < line.getElementCount(); i++) {
            final Element element = line.getElement(i);

            final AttributeSet as = element.getAttributes();
            final Enumeration<?> ae = as.getAttributeNames();

            while (ae.hasMoreElements()) {
                final Object attrib = ae.nextElement();

                if (attrib == IRCTextAttribute.HYPERLINK) {
                    //Hyperlink
                    attString.addAttribute(IRCTextAttribute.HYPERLINK,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == IRCTextAttribute.NICKNAME) {
                    //Nicknames
                    attString.addAttribute(IRCTextAttribute.NICKNAME,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == IRCTextAttribute.CHANNEL) {
                    //Channels
                    attString.addAttribute(IRCTextAttribute.CHANNEL,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == ColorConstants.Foreground) {
                    //Foreground
                    attString.addAttribute(TextAttribute.FOREGROUND,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == ColorConstants.Background) {
                    //Background
                    attString.addAttribute(TextAttribute.BACKGROUND,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == FontConstants.Bold) {
                    //Bold
                    attString.addAttribute(TextAttribute.WEIGHT,
                            TextAttribute.WEIGHT_BOLD, element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == FontConstants.Family) {
                    //Family
                    attString.addAttribute(TextAttribute.FAMILY,
                            as.getAttribute(attrib), element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == FontConstants.Italic) {
                    //italics
                    attString.addAttribute(TextAttribute.POSTURE,
                            TextAttribute.POSTURE_OBLIQUE,
                            element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == CharacterConstants.Underline) {
                    //Underline
                    attString.addAttribute(TextAttribute.UNDERLINE,
                            TextAttribute.UNDERLINE_ON, element.getStartOffset(),
                            element.getEndOffset());
                } else if (attrib == IRCTextAttribute.SMILEY) {
                    /* Lets avoid showing broken smileys shall we!
                    final Image image = IconManager.getIconManager().getImage((String) as.getAttribute(attrib)).
                    getScaledInstance(14, 14, Image.SCALE_DEFAULT);
                    ImageGraphicAttribute iga = new ImageGraphicAttribute(image, 
                    (int) BOTTOM_ALIGNMENT, 5, 5);
                    attString.addAttribute(TextAttribute.CHAR_REPLACEMENT, iga,
                    element.getStartOffset(), element.getEndOffset());
                     */
                }
            }
        }

        if (attString.getIterator().getEndIndex() == 0) {
            return new AttributedString("\n");
        }

        return attString;
    //#Line.java:237: end of method: AttributedString com.dmdirc.addons.ui_swing.textpane.Line.getStyled()
    }

    /** {@inheritDoc} */
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Line) {
    //#Line.java:243: method: bool com.dmdirc.addons.ui_swing.textpane.Line.equals(Object)
    //#input(bool equals(Object)): __Descendant_Table[com/dmdirc/addons/ui_swing/textpane/Line]
    //#input(bool equals(Object)): __Descendant_Table[others]
    //#input(bool equals(Object)): __Dispatch_Table.getLineParts()[Ljava/lang/String;
    //#input(bool equals(Object)): obj
    //#input(bool equals(Object)): obj.__Tag
    //#input(bool equals(Object)): obj.lineParts
    //#input(bool equals(Object)): this
    //#input(bool equals(Object)): this.__Tag
    //#input(bool equals(Object)): this.lineParts
    //#output(bool equals(Object)): return_value
    //#pre[5] (bool equals(Object)): (soft) this.__Tag == com/dmdirc/addons/ui_swing/textpane/Line
    //#post(bool equals(Object)): init'ed(return_value)
            return Arrays.equals(((Line) obj).getLineParts(), getLineParts());
        }
        return false;
    //#Line.java:246: end of method: bool com.dmdirc.addons.ui_swing.textpane.Line.equals(Object)
    }

    /** {@inheritDoc} */
    @Override
    public int hashCode() {
        return getLineParts().hashCode();
    //#Line.java:252: method: int com.dmdirc.addons.ui_swing.textpane.Line.hashCode()
    //#input(int hashCode()): __Descendant_Table[com/dmdirc/addons/ui_swing/textpane/Line]
    //#input(int hashCode()): __Descendant_Table[others]
    //#input(int hashCode()): __Dispatch_Table.getLineParts()[Ljava/lang/String;
    //#input(int hashCode()): this
    //#input(int hashCode()): this.__Tag
    //#input(int hashCode()): this.lineParts
    //#output(int hashCode()): return_value
    //#pre[2] (int hashCode()): this.__Tag == com/dmdirc/addons/ui_swing/textpane/Line
    //#pre[3] (int hashCode()): this.lineParts != null
    //#post(int hashCode()): init'ed(return_value)
    //#Line.java:252: end of method: int com.dmdirc.addons.ui_swing.textpane.Line.hashCode()
    }
}    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/textpane/Line]
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getHeight()I
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getLength()I
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getLineParts()[Ljava/lang/String;
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getStyled()Ljava/text/AttributedString;
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getStyledText()Ljava/lang/String;
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getText()Ljava/lang/String;
    //#output(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.hashCode()I
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/textpane/Line] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getHeight()I == &getHeight
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getLength()I == &getLength
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getLineParts()[Ljava/lang/String; == &getLineParts
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getStyled()Ljava/text/AttributedString; == &getStyled
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getStyledText()Ljava/lang/String; == &getStyledText
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.getText()Ljava/lang/String; == &getText
    //#post(com.dmdirc.addons.ui_swing.textpane.Line__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#Line.java:: end of method: com.dmdirc.addons.ui_swing.textpane.Line.com.dmdirc.addons.ui_swing.textpane.Line__static_init
    //#Line.java:: end of class: com.dmdirc.addons.ui_swing.textpane.Line
