// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:42:03
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/api/Serial

package com.macromedia.generator.api;

import com.macromedia.generator.api.peer.SerialPeer;

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, GeneratorApiRuntimeException

public class Serial extends GenObject
{

    public Serial()
    {
        peer = SerialPeer.New();
        if(peer == 0)
            throw new GeneratorApiRuntimeException("unable to create peer");
        else
            return;
    }

    protected Serial(int i)
    {
        peer = i;
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        else
            return;
    }

    protected void finalize()
        throws Throwable
    {
        String s = System.getProperty("com.macromedia.generator.offline", "0");
        if(s.equalsIgnoreCase("0"))
        {
            if(peer != 0)
                SerialPeer.Release(peer);
            peer = 0;
        }
    }

    public int flush(boolean flag)
    {
        return getAPICall(flag);
    }

    public int getAPICall(boolean flag)
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetSerialNumberExpires(peer, ai, flag);
        if(i == 0)
            ai[0] = 0;
        return ai[0];
    }

    public String getFirstName()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetFirstName(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public String getLastName()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetLastName(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public boolean getLimited()
    {
        boolean aflag[] = {
            true
        };
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetLimited(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting limited setting");
        else
            return aflag[0];
    }

    public String getMiddleName()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetMiddleName(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public String getOrganization()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetOrganization(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public boolean getPublished()
    {
        boolean aflag[] = {
            true
        };
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetPublished(peer, aflag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error getting serial publish setting");
        else
            return aflag[0];
    }

    public String getSerialNumber()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetSerialNumber(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public boolean getSerialNumberOK()
    {
        boolean aflag[] = new boolean[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetSerialNumberOK(peer, aflag);
        if(i == 0)
            aflag[0] = false;
        return aflag[0];
    }

    public String getServerNumber()
    {
        String as[] = new String[1];
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.GetServerNumber(peer, as);
        if(i == 0)
            as[0] = null;
        return as[0];
    }

    public void release()
    {
        if(peer != 0)
            SerialPeer.Release(peer);
        peer = 0;
    }

    public void reset()
    {
        if(peer == 0)
        {
            throw new GeneratorApiRuntimeException("invalid peer");
        } else
        {
            SerialPeer.Reset(peer);
            return;
        }
    }

    public void setFirstName(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetFirstName(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting first name value");
        else
            return;
    }

    public void setLastName(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetLastName(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting last name value");
        else
            return;
    }

    public void setMiddleName(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetMiddleName(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting middle name value");
        else
            return;
    }

    public void setOrganization(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetOrganization(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting organization value");
        else
            return;
    }

    public void setPeer(int i)
    {
        peer = i;
    }

    public void setPublished(boolean flag)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        int i = SerialPeer.SetPublished(peer, flag);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting serial publish settings");
        else
            return;
    }

    public void setSerialNumber(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetSerialNumber(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting serial number value");
        else
            return;
    }

    public void setServerNumber(String s)
    {
        if(peer == 0)
            throw new GeneratorApiRuntimeException("invalid peer");
        if(s == null)
            s = "";
        int i = SerialPeer.SetServerNumber(peer, s);
        if(i == 0)
            throw new GeneratorApiRuntimeException("error setting server number value");
        else
            return;
    }
}