// 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:   PackageDocImpl.java

package com.sun.tools.javadoc;

import com.sun.javadoc.*;
import com.sun.tools.javac.v8.code.Scope;
import com.sun.tools.javac.v8.code.Symbol;
import com.sun.tools.javac.v8.util.*;
import java.io.*;
import java.util.zip.ZipFile;

// Referenced classes of package com.sun.tools.javadoc:
//            DocImpl, ClassDocImpl, DocEnv, SourcePositionImpl

public class PackageDocImpl extends DocImpl
    implements PackageDoc
{

    public boolean isIncluded()
    {
        return isIncluded;
    }

    public ClassDoc[] allClasses()
    {
        return allClasses(true);
    }

    public ClassDoc[] errors()
    {
        ListBuffer listbuffer = new ListBuffer();
        for(List list = getClasses(true); list.nonEmpty(); list = list.tail)
        {
            ClassDocImpl classdocimpl = (ClassDocImpl)list.head;
            if(classdocimpl.isError())
                listbuffer.append(classdocimpl);
        }

        return (ClassDoc[])listbuffer.toArray(new ClassDocImpl[listbuffer.length()]);
    }

    public ClassDoc[] exceptions()
    {
        ListBuffer listbuffer = new ListBuffer();
        for(List list = getClasses(true); list.nonEmpty(); list = list.tail)
        {
            ClassDocImpl classdocimpl = (ClassDocImpl)list.head;
            if(classdocimpl.isException())
                listbuffer.append(classdocimpl);
        }

        return (ClassDoc[])listbuffer.toArray(new ClassDocImpl[listbuffer.length()]);
    }

    public ClassDoc[] interfaces()
    {
        ListBuffer listbuffer = new ListBuffer();
        for(List list = getClasses(true); list.nonEmpty(); list = list.tail)
        {
            ClassDocImpl classdocimpl = (ClassDocImpl)list.head;
            if(classdocimpl.isInterface())
                listbuffer.append(classdocimpl);
        }

        return (ClassDoc[])listbuffer.toArray(new ClassDocImpl[listbuffer.length()]);
    }

    public ClassDoc[] ordinaryClasses()
    {
        ListBuffer listbuffer = new ListBuffer();
        for(List list = getClasses(true); list.nonEmpty(); list = list.tail)
        {
            ClassDocImpl classdocimpl = (ClassDocImpl)list.head;
            if(classdocimpl.isOrdinaryClass())
                listbuffer.append(classdocimpl);
        }

        return (ClassDoc[])listbuffer.toArray(new ClassDocImpl[listbuffer.length()]);
    }

    public ClassDoc[] allClasses(boolean flag)
    {
        List list = getClasses(flag);
        return (ClassDoc[])list.toArray(new ClassDocImpl[list.length()]);
    }

    public SourcePosition position()
    {
        return docPath != null ? SourcePositionImpl.make(docPath, 0) : null;
    }

    private List getClasses(boolean flag)
    {
        if(allClasses != null && !flag)
            return allClasses;
        if(allClassesFiltered != null && flag)
            return allClassesFiltered;
        ListBuffer listbuffer = new ListBuffer();
        for(com.sun.tools.javac.v8.code.Scope.Entry entry = sym.members().elems; entry != null; entry = entry.sibling)
        {
            if(entry.sym == null)
                continue;
            com.sun.tools.javac.v8.code.Symbol.ClassSymbol classsymbol = (com.sun.tools.javac.v8.code.Symbol.ClassSymbol)entry.sym;
            ClassDocImpl classdocimpl = env.getClassDoc(classsymbol);
            if(classdocimpl != null && !classdocimpl.isSynthetic())
                classdocimpl.addAllClasses(listbuffer, flag);
        }

        if(flag)
            return allClassesFiltered = listbuffer.toList();
        else
            return allClasses = listbuffer.toList();
    }

    public void addAllClassesTo(ListBuffer listbuffer)
    {
        listbuffer.appendList(getClasses(true));
    }

    String documentation()
    {
        if(documentation != null)
            return documentation;
        if(zipDocPath == null)
            break MISSING_BLOCK_LABEL_141;
        java.io.InputStream inputstream;
        ZipFile zipfile = new ZipFile(zipDocPath);
        java.util.zip.ZipEntry zipentry = zipfile.getEntry(zipDocEntry);
        if(zipentry == null)
            break MISSING_BLOCK_LABEL_141;
        inputstream = zipfile.getInputStream(zipentry);
        return documentation = readHTMLDocumentation(inputstream, zipDocPath + File.separatorChar + zipDocEntry);
        IOException ioexception;
        ioexception;
        documentation = "";
        env.error(null, "javadoc.File_Read_Error", zipDocPath + File.separatorChar + zipDocEntry);
        if(docPath != null)
            try
            {
                FileInputStream fileinputstream = new FileInputStream(docPath);
                documentation = readHTMLDocumentation(fileinputstream, docPath);
            }
            catch(IOException ioexception1)
            {
                documentation = "";
                env.error(null, "javadoc.File_Read_Error", docPath);
            }
        else
            documentation = "";
        return documentation;
    }

    public String name()
    {
        String s = sym.fullName().toString();
        if(s.equals("unnamed package"))
            s = "";
        return s;
    }

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

    public void setDocPath(String s)
    {
        docPath = s + File.separatorChar + "package.html";
    }

    public ClassDoc findClass(String s)
    {
        for(List list = getClasses(true); list.nonEmpty(); list = list.tail)
        {
            ClassDocImpl classdocimpl = (ClassDocImpl)list.head;
            if(classdocimpl.name().equals(s))
                return classdocimpl;
        }

        return null;
    }

    public PackageDocImpl(DocEnv docenv, com.sun.tools.javac.v8.code.Symbol.PackageSymbol packagesymbol)
    {
        DocImpl(docenv, null);
        docPath = null;
        zipDocPath = null;
        zipDocEntry = null;
        isIncluded = false;
        allClassesFiltered = null;
        allClasses = null;
        sym = packagesymbol;
    }

    public void setDocPath(String s, String s1)
    {
        zipDocPath = s;
        zipDocEntry = s1 + "package.html";
    }

    private static final String PACKAGE_FILE_NAME = "package.html";
    protected com.sun.tools.javac.v8.code.Symbol.PackageSymbol sym;
    public String docPath;
    public String zipDocPath;
    public String zipDocEntry;
    boolean isIncluded;
    private List allClassesFiltered;
    private List allClasses;
}
