// 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 

package oracle.net.TNSAddress;

import java.util.Vector;
import oracle.net.nl.*;

// Referenced classes of package oracle.net.TNSAddress:
//            SOException, SchemaObject, SchemaObjectFactoryInterface

public class Description
    implements SchemaObject
{

    public Description(SchemaObjectFactoryInterface schemaobjectfactoryinterface)
    {
        children = new Vector();
        f = null;
        sourceRoute = false;
        loadBalance = false;
        failover = true;
        protocolStacks = new Vector();
        authParams = new Vector();
        extraConnInfo = new Vector();
        extraInfo = new Vector();
        f = schemaobjectfactoryinterface;
    }

    protected void init()
    {
        children.removeAllElements();
        child = null;
        childnv = null;
        sourceRoute = false;
        loadBalance = false;
        failover = true;
        protocolStacks.removeAllElements();
        SDU = null;
        SID = null;
        server = null;
        serviceName = null;
        instanceName = null;
        handlerName = null;
        oracleHome = null;
        authTypes = null;
        authParams.removeAllElements();
        extraConnInfo.removeAllElements();
        extraInfo.removeAllElements();
    }

    public void initFromNVPair(NVPair nvpair)
        throws SOException
    {
        init();
        int i = nvpair.getListSize();
        if(i == 0)
            throw new SOException();
        for(int j = 0; j < i; j++)
        {
            childnv = nvpair.getListElement(j);
            if(childnv.getName().equalsIgnoreCase("SOURCE_ROUTE"))
                sourceRoute = childnv.getAtom().equalsIgnoreCase("yes") || childnv.getAtom().equalsIgnoreCase("on") || childnv.getAtom().equalsIgnoreCase("true");
            else
            if(childnv.getName().equalsIgnoreCase("LOAD_BALANCE"))
                loadBalance = childnv.getAtom().equalsIgnoreCase("yes") || childnv.getAtom().equalsIgnoreCase("on") || childnv.getAtom().equalsIgnoreCase("true");
            else
            if(childnv.getName().equalsIgnoreCase("FAILOVER"))
                failover = childnv.getAtom().equalsIgnoreCase("yes") || childnv.getAtom().equalsIgnoreCase("on") || childnv.getAtom().equalsIgnoreCase("true");
            else
            if(childnv.getName().equalsIgnoreCase("PROTOCOL_STACK"))
                protocolStacks.addElement(childnv.toString());
            else
            if(childnv.getName().equalsIgnoreCase("ADDRESS"))
            {
                child = f.create(0);
                child.initFromNVPair(childnv);
                children.addElement(child);
            } else
            if(childnv.getName().equalsIgnoreCase("ADDRESS_LIST"))
            {
                child = f.create(1);
                child.initFromNVPair(childnv);
                children.addElement(child);
            } else
            if(childnv.getName().equalsIgnoreCase("SDU"))
                SDU = childnv.getAtom();
            else
            if(childnv.getName().equalsIgnoreCase("CONNECT_DATA"))
            {
                connectData = childnv.valueToString();
                int k = childnv.getListSize();
                if(k == 0)
                    throw new SOException();
                for(int i1 = 0; i1 < k; i1++)
                {
                    NVPair nvpair1 = childnv.getListElement(i1);
                    if(nvpair1.getName().equalsIgnoreCase("SID"))
                        SID = nvpair1.getAtom();
                    else
                    if(nvpair1.getName().equalsIgnoreCase("SERVER"))
                        server = nvpair1.getAtom();
                    else
                    if(nvpair1.getName().equalsIgnoreCase("SERVICE_NAME"))
                        serviceName = nvpair1.getAtom();
                    else
                    if(nvpair1.getName().equalsIgnoreCase("INSTANCE_NAME"))
                        instanceName = nvpair1.getAtom();
                    else
                    if(nvpair1.getName().equalsIgnoreCase("HANDLER_NAME"))
                        handlerName = nvpair1.getAtom();
                    else
                    if(nvpair1.getName().equalsIgnoreCase("ORACLE_HOME"))
                    {
                        oracleHome = nvpair1.getAtom();
                    } else
                    {
                        String s1 = nvpair1.toString().trim();
                        s1 = s1.substring(1, s1.length() - 1);
                        extraConnInfo.addElement(s1);
                    }
                }

            } else
            if(childnv.getName().equalsIgnoreCase("SECURITY"))
            {
                int l = childnv.getListSize();
                if(l == 0)
                    throw new SOException();
                for(int j1 = 0; j1 < l; j1++)
                {
                    NVPair nvpair2 = childnv.getListElement(j1);
                    if(nvpair2.getName().equalsIgnoreCase("AUTHENTICATION"))
                        authTypes = nvpair2.toString();
                    else
                        authParams.addElement(nvpair2.toString());
                }

            } else
            {
                String s = childnv.toString().trim();
                s = s.substring(1, s.length() - 1);
                extraInfo.addElement(s);
            }
        }

    }

    public void initFromString(String s)
        throws NLException, SOException
    {
        NVPair nvpair = (new NVFactory()).createNVPair(s);
        if(nvpair == null)
        {
            throw new NLException((short)100);
        } else
        {
            initFromNVPair(nvpair);
            return;
        }
    }

    public int isA()
    {
        return 2;
    }

    public String isA_String()
    {
        return "DESCRIPTION";
    }

    public String toString()
    {
        String s = new String("");
        s = s + "(DESCRIPTION=";
        if(protocolStacks.size() != 0)
        {
            for(int i = 0; i < protocolStacks.size(); i++)
                s = s + (String)protocolStacks.elementAt(i);

        }
        for(int j = 0; j < children.size(); j++)
            s = s + ((SchemaObject)children.elementAt(j)).toString();

        if(sourceRoute)
            s = s + "(SOURCE_ROUTE=yes)";
        if(loadBalance)
            s = s + "(LOAD_BALANCE=yes)";
        if(!failover)
            s = s + "(FAILOVER=false)";
        if(SDU != null)
            s = s + "(SDU=" + SDU + ")";
        if(SID != null || server != null || serviceName != null || instanceName != null || handlerName != null || extraConnInfo.size() != 0 || oracleHome != null)
        {
            s = s + "(CONNECT_DATA=";
            if(SID != null)
                s = s + "(SID=" + SID + ")";
            if(server != null)
                s = s + "(SERVER=" + server + ")";
            if(serviceName != null)
                s = s + "(SERVICE_NAME=" + serviceName + ")";
            if(instanceName != null)
                s = s + "(INSTANCE_NAME=" + instanceName + ")";
            if(handlerName != null)
                s = s + "(HANDLER_NAME=" + handlerName + ")";
            if(oracleHome != null)
                s = s + "(ORACLE_HOME=" + oracleHome + ")";
            for(int k = 0; k < extraConnInfo.size(); k++)
                s = s + "(" + (String)extraConnInfo.elementAt(k) + ")";

            s = s + ")";
        }
        if(authTypes != null || authParams.size() != 0)
        {
            s = s + "(SECURITY=";
            if(authTypes != null)
                s = s + "(AUTHENTICATION=" + authTypes + ")";
            for(int l = 0; l < authParams.size(); l++)
                s = s + (String)authParams.elementAt(l);

            s = s + ")";
        }
        for(int i1 = 0; i1 < extraInfo.size(); i1++)
            s = s + "(" + (String)extraInfo.elementAt(i1) + ")";

        s = s + ")";
        return s;
    }

    public Vector children;
    private SchemaObject child;
    private NVPair childnv;
    protected SchemaObjectFactoryInterface f;
    public boolean sourceRoute;
    public boolean loadBalance;
    public boolean failover;
    public String SDU;
    public Vector protocolStacks;
    public String connectData;
    public String SID;
    public String server;
    public String serviceName;
    public String instanceName;
    public String handlerName;
    public String oracleHome;
    public String authTypes;
    public Vector authParams;
    public Vector extraConnInfo;
    public Vector extraInfo;
}
