///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
//
// All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License and GNU Library
// General Public License as published by the Free Software Foundation;
// either version 2, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License and GNU Library General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// and GNU Library General Public License along with this program; if
// not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
// MA 02139, USA.
//
///////////////////////////////////////////////////////////////////////////////
package org.myoodb;
public class MyOodbObject implements MyOodbLocal
{
private transient boolean m_convertFlag = true;
private transient org.myoodb.core.AbstractObjectContainer m_container = null;
public MyOodbObject()
{
}
public void onCreate()
{
}
public void onDelete()
{
}
public final void setConvertFlag(boolean convertFlag)
{
m_convertFlag = convertFlag;
}
public final boolean getConvertFlag()
{
return m_convertFlag;
}
public final void setContainer(org.myoodb.core.AbstractObjectContainer container)
{
m_container = container;
}
public final org.myoodb.core.AbstractObjectContainer getContainer()
{
if (m_container == null)
{
throw new org.myoodb.exception.PermissionException("Invalid access (" + this.getClass() + " is not (yet) associated to a database");
}
return m_container;
}
public final MyOodbProxy getSelf()
{
return getContainer().getProxy();
}
public final org.myoodb.core.Identifier getDatabaseHandle()
{
return getContainer().getObjectIdentifier();
}
public final org.myoodb.core.AbstractDatabase getDatabase()
{
return org.myoodb.core.MyOodbManager.getTheManager().getDatabase();
}
public final Object writeReplace() throws java.io.ObjectStreamException
{
if (m_convertFlag == false)
{
m_convertFlag = true;
return this;
}
else
{
return getSelf();
}
}
public final void setBean(MyOodbBean bean)
{
getDatabase().setBean(getDatabaseHandle(), bean);
}
public final MyOodbBean getBean()
{
return getDatabase().getBean(getDatabaseHandle());
}
public final void setXML(String xml)
{
getDatabase().setXML(getDatabaseHandle(), xml);
}
public final String getXML()
{
return getDatabase().getXML(getDatabaseHandle());
}
public int hashCode()
{
return getDatabaseHandle().hashCode();
}
public boolean equals(Object obj)
{
if (obj == this)
{
return true;
}
else if (obj instanceof MyOodbObject)
{
return getDatabaseHandle().equals(((MyOodbObject) obj).getDatabaseHandle());
}
else if (obj instanceof MyOodbProxy)
{
return getDatabaseHandle().equals(((MyOodbProxy) obj).getDatabaseHandle());
}
else if (obj instanceof org.myoodb.core.Identifier)
{
return getDatabaseHandle().equals(obj);
}
else
{
return false;
}
}
public int compareTo(Object obj)
{
if (obj instanceof MyOodbObject)
{
return getDatabaseHandle().compareTo(((MyOodbObject) obj).getDatabaseHandle());
}
else if (obj instanceof MyOodbProxy)
{
return getDatabaseHandle().compareTo(((MyOodbProxy) obj).getDatabaseHandle());
}
else if (obj instanceof org.myoodb.core.Identifier)
{
return getDatabaseHandle().compareTo(obj);
}
else
{
return -1;
}
}
public String toString()
{
return "Object Handle: " + getDatabaseHandle();
}
}
|