TAddress.~jav 5.11 KB
Newer Older
O'Reilly Media, Inc. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/*@lineinfo:filename=TAddress*//*@lineinfo:user-code*//*@lineinfo:1^1*/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;
import sqlj.runtime.ref.DefaultContext;
import sqlj.runtime.ConnectionContext;
import java.sql.Connection;

public class TAddress implements CustomDatum, CustomDatumFactory
{
  public static final String _SQL_NAME = "OBJECT_USER.T_ADDRESS";
  public static final int _SQL_TYPECODE = OracleTypes.STRUCT;

  /*@lineinfo:generated-code*//*@lineinfo:18^3*/

//  ************************************************************
//  SQLJ context declaration:
//  ************************************************************

static class _Ctx 
extends sqlj.runtime.ref.ConnectionContextImpl
implements sqlj.runtime.ConnectionContext
{
  public _Ctx(java.sql.Connection conn) 
    throws java.sql.SQLException 
  {
    super(profiles, conn);
  }
  public _Ctx(java.lang.String url, java.lang.String user, java.lang.String password, boolean autoCommit) 
    throws java.sql.SQLException 
  {
    super(profiles, url, user, password, autoCommit);
  }
  public _Ctx(java.lang.String url, java.util.Properties info, boolean autoCommit) 
    throws java.sql.SQLException 
  {
    super(profiles, url, info, autoCommit);
  }
  public _Ctx(java.lang.String url, boolean autoCommit) 
    throws java.sql.SQLException 
  {
    super(profiles, url, autoCommit);
  }
  public _Ctx(sqlj.runtime.ConnectionContext other) 
    throws java.sql.SQLException 
  {
    super(profiles, other);
  }
  public static _Ctx getDefaultContext() 
  {
    if (defaultContext == null)
    {
      java.sql.Connection conn = sqlj.runtime.RuntimeContext.getRuntime().getDefaultConnection();
      if (conn != null)
      {
        try 
        {
          defaultContext = new _Ctx(conn);
        }
        catch (java.sql.SQLException e) 
        {
        }
      }
    }
    return defaultContext;
  }
  public static void setDefaultContext(_Ctx ctx) 
  {
    defaultContext = ctx;
  }
  private static _Ctx defaultContext = null;
  public static java.lang.Object getProfileKey(sqlj.runtime.profile.Loader loader, java.lang.String profileName) 
    throws java.sql.SQLException 
  {
    return profiles.getProfileKey(loader, profileName);
  }
  private static final sqlj.runtime.ref.ProfileGroup profiles = new sqlj.runtime.ref.ProfileGroup();
  public static sqlj.runtime.profile.Profile getProfile(java.lang.Object profileKey) 
  {
    return profiles.getProfile(profileKey);
  }
}


//  ************************************************************

/*@lineinfo:user-code*//*@lineinfo:18^26*/
  _Ctx _ctx;

  MutableStruct _struct;

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

  static CustomDatumFactory[] _factory = new CustomDatumFactory[4];

  static final TAddress _TAddressFactory = new TAddress();
  public static CustomDatumFactory getFactory()
  {
    return _TAddressFactory;
  }

  /* constructors */
  public TAddress()
  {
    _struct = new MutableStruct(new Object[4], _sqlType, _factory);
    try
    {
      _ctx = new _Ctx(DefaultContext.getDefaultContext());
    }
    catch (Exception e)
    {
      _ctx = null;
    }
  }

  public TAddress(ConnectionContext c) throws SQLException
  {
    _struct = new MutableStruct(new Object[4], _sqlType, _factory);
    _ctx = new _Ctx(c == null ? DefaultContext.getDefaultContext()
                              : c);
  }
  public TAddress(Connection c) throws SQLException
  {
    _struct = new MutableStruct(new Object[4], _sqlType, _factory);
    _ctx = new _Ctx(c);
  }

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

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

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

  public void setStreet(String street) throws SQLException
  { _struct.setAttribute(0, street); }


  public String getCity() throws SQLException
  { return (String) _struct.getAttribute(1); }

  public void setCity(String city) throws SQLException
  { _struct.setAttribute(1, city); }


  public String getState() throws SQLException
  { return (String) _struct.getAttribute(2); }

  public void setState(String state) throws SQLException
  { _struct.setAttribute(2, state); }


  public String getZip() throws SQLException
  { return (String) _struct.getAttribute(3); }

  public void setZip(String zip) throws SQLException
  { _struct.setAttribute(3, zip); }

}/*@lineinfo:generated-code*/