// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   DocImpl.java

package com.sun.tools.javadoc;

import com.sun.javadoc.*;
import java.io.IOException;
import java.io.InputStream;
import java.text.CollationKey;
import java.text.Collator;

// Referenced classes of package com.sun.tools.javadoc:
//            Comment, DocEnv, DocLocale, Messager, 
//            SourcePositionImpl

abstract class DocImpl
    implements Doc, Comparable
{

    public boolean isClass()
    {
        return false;
    }

    public boolean isConstructor()
    {
        return false;
    }

    public boolean isError()
    {
        return false;
    }

    public boolean isException()
    {
        return false;
    }

    public boolean isField()
    {
        return false;
    }

    public abstract boolean isIncluded();

    public boolean isInterface()
    {
        return false;
    }

    public boolean isMethod()
    {
        return false;
    }

    public boolean isOrdinaryClass()
    {
        return false;
    }

    public SeeTag[] seeTags()
    {
        return comment().seeTags();
    }

    public SourcePosition position()
    {
        return null;
    }

    public Tag[] firstSentenceTags()
    {
        return Comment.firstSentenceTags(this, commentText());
    }

    public Tag[] inlineTags()
    {
        return Comment.getInlineTags(this, commentText());
    }

    public Tag[] tags()
    {
        return comment().tags();
    }

    Comment comment()
    {
        if(comment == null)
            comment = new Comment(this, documentation());
        return comment;
    }

    public int compareTo(Object obj)
    {
        return key().compareTo(((DocImpl)obj).key());
    }

    public String commentText()
    {
        return comment().commentText();
    }

    String documentation()
    {
        if(documentation == null)
            documentation = "";
        return documentation;
    }

    public String getRawCommentText()
    {
        return documentation();
    }

    public abstract String name();

    public abstract String qualifiedName();

    String toQualifiedString()
    {
        return toString();
    }

    public String toString()
    {
        return qualifiedName();
    }

    public void setRawCommentText(String s)
    {
        documentation = s;
        comment = null;
    }

    CollationKey generateKey()
    {
        String s = name();
        return env.doclocale.collator.getCollationKey(s);
    }

    CollationKey key()
    {
        if(collationkey == null)
            collationkey = generateKey();
        return collationkey;
    }

    public Tag[] tags(String s)
    {
        return comment().tags(s);
    }

    DocImpl(DocEnv docenv, String s)
    {
        collationkey = null;
        documentation = s;
        env = docenv;
    }

    String readHTMLDocumentation(InputStream inputstream, String s)
        throws IOException
    {
        int i = inputstream.available();
        byte abyte0[] = new byte[i];
        inputstream.read(abyte0, 0, i);
        inputstream.close();
        String s1 = env.getEncoding();
        String s2 = s1 == null ? new String(abyte0) : new String(abyte0, s1);
        String s3 = null;
        int j = s2.indexOf("<body");
        if(j == -1)
        {
            j = s2.indexOf("<BODY");
            if(j == -1)
            {
                s3 = s2.toUpperCase();
                j = s3.indexOf("<BODY");
                if(j == -1)
                {
                    env.messager.error(SourcePositionImpl.make(s, 0), "javadoc.Body_missing_from_html_file");
                    return "";
                }
            }
        }
        j = s2.indexOf('>', j);
        if(j == -1)
        {
            env.messager.error(SourcePositionImpl.make(s, 0), "javadoc.Body_missing_from_html_file");
            return "";
        }
        j++;
        int k = s2.indexOf("</body", j);
        if(k == -1)
        {
            k = s2.indexOf("</BODY", j);
            if(k == -1)
            {
                if(s3 == null)
                    s3 = s2.toUpperCase();
                k = s3.indexOf("</BODY", j);
                if(k == -1)
                {
                    env.messager.error(SourcePositionImpl.make(s, 0), "javadoc.End_body_missing_from_html_file");
                    return "";
                }
            }
        }
        return s2.substring(j, k);
    }

    protected final DocEnv env;
    private Comment comment;
    private CollationKey collationkey;
    protected String documentation;
}
