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

import java.sql.SQLException;
import oracle.sql.CustomDatum;
import oracle.sql.CustomDatumFactory;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.jpub.runtime.MutableStruct;
import sqlj.runtime.ConnectionContext;
import java.sql.Connection;

public class MyRationalO extends JPubRationalO
                      implements CustomDatum, CustomDatumFactory
{
  /* _SQL_NAME inherited from JPubRationalO */

  /* _SQL_TYPECODE inherited from JPubRationalO */

  /* _ctx inherited from JPubRationalO */

  /* _sqlType inherited from JPubRationalO */ 

  /* _factory inherited from JPubRationalO */

  /* _struct inherited from JPubRationalO */

  static final MyRationalO _MyRationalOFactory = new MyRationalO();
  public static CustomDatumFactory getFactory()
  {
    return _MyRationalOFactory;
  }

  /* constructors */
  public MyRationalO()
  {
    super();
  }

  public MyRationalO(ConnectionContext c) throws SQLException  
  {
    super(c);
  }

  public MyRationalO(Connection c) throws SQLException  
  {
    super(c);
  }

  /* CustomDatum interface */
  /* toDatum() inherited from JPubRationalO */

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

  /* shallow copy method inherited from JPubRationalO */

  /* accessor methods inherited from JPubRationalO */

  /* additional method not in base class */
  public String toString()
  {
    try
    {
       return getNumerator().toString() + "/" + getDenominator().toString();
    }
    catch (SQLException e)
    {
       return null;
    }
  }
}
