/* $Header: PERSON.java 15-mar-00.09:06:53 rbhyrava Exp $ */

/* Copyright (c) Oracle Corporation 2000. All Rights Reserved. */

/*
   DESCRIPTION
    <short description of component this file declares/defines>

   PRIVATE CLASSES
    <list of private classes defined - with one-line descriptions>

   NOTES
    <other useful comments, qualifications, etc.>

   MODIFIED    (MM/DD/YY)
    rbhyrava    03/15/00 - AQ API demo -Jpub generated class for PERSON Type
    rbhyrava    03/15/00 - Creation
 */

/**
 *  @version $Header: PERSON.java 15-mar-00.09:06:53 rbhyrava Exp $
 *  @author  rbhyrava
 *  @since   release specific (what release of product did this appear in)
 */

/****
 * Jpub generated class for for ADDRESS object type 
 * Used in aqorademo02.java                     
 ***/
import java.sql.SQLException;
import oracle.jdbc.driver.OracleConnection;
import oracle.jdbc.driver.OracleTypes;
import oracle.sql.CustomDatum;
import oracle.sql.CustomDatumFactory;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.jpub.runtime.MutableStruct;

public class PERSON implements CustomDatum, CustomDatumFactory
{
  public static final String _SQL_NAME = "AQJAVA.PERSON";
  public static final int _SQL_TYPECODE = OracleTypes.STRUCT;

  MutableStruct _struct;

  static int[] _sqlType =
  {
    12, 2002
  };

  static CustomDatumFactory[] _factory = new CustomDatumFactory[2];
  static
  {
    _factory[1] = ADDRESS.getFactory();
  }

  static final PERSON _PERSONFactory = new PERSON();
  public static CustomDatumFactory getFactory()
  {
    return _PERSONFactory;
  }

  /* constructor */
  public PERSON()
  {
    _struct = new MutableStruct(new Object[2], _sqlType, _factory);
  }

  /* CustomDatum interface */
  public Datum toDatum(OracleConnection c) throws SQLException
  {
    return _struct.toDatum(c, _SQL_NAME);
  }

  /* CustomDatumFactory interface */
  public CustomDatum create(Datum d, int sqlType) throws SQLException
  {
    if (d == null) return null;
    PERSON o = new PERSON();
    o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
    return o;
  }

  /* accessor methods */
  public String getName() throws SQLException
  { return (String) _struct.getAttribute(0); }

  public void setName(String name) throws SQLException
  { _struct.setAttribute(0, name); }


  public ADDRESS getHome() throws SQLException
  { return (ADDRESS) _struct.getAttribute(1); }

  public void setHome(ADDRESS home) throws SQLException
  { _struct.setAttribute(1, home); }

}
