Dear Nick Stuart,
Thanks for you reply. I appreciate it very much.
I attach herewith the developer and developers java sources.
Cheers,
Ng Keng Yap
package com.smml.castor.bean;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.util.Enumeration;
import java.util.Vector;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;
/**
* Class Developers.
*
* @version $Revision$ $Date$
*/
public class Developers implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field _developerList
*/
private java.util.Vector _developerList;
//----------------/
//- Constructors -/
//----------------/
public Developers() {
super();
_developerList = new Vector();
} //-- com.smml.castor.bean.Developers()
//-----------/
//- Methods -/
//-----------/
/**
* Method addDeveloper
*
* @param vDeveloper
*/
public void addDeveloper(com.smml.castor.bean.Developer vDeveloper)
throws java.lang.IndexOutOfBoundsException
{
_developerList.addElement(vDeveloper);
} //-- void addDeveloper(com.smml.castor.bean.Developer)
/**
* Method addDeveloper
*
* @param index
* @param vDeveloper
*/
public void addDeveloper(int index, com.smml.castor.bean.Developer
vDeveloper)
throws java.lang.IndexOutOfBoundsException
{
_developerList.insertElementAt(vDeveloper, index);
} //-- void addDeveloper(int, com.smml.castor.bean.Developer)
/**
* Method enumerateDeveloper
*/
public java.util.Enumeration enumerateDeveloper()
{
return _developerList.elements();
} //-- java.util.Enumeration enumerateDeveloper()
/**
* Method getDeveloper
*
* @param index
*/
public com.smml.castor.bean.Developer getDeveloper(int index)
throws java.lang.IndexOutOfBoundsException
{
//-- check bounds for index
if ((index < 0) || (index > _developerList.size())) {
throw new IndexOutOfBoundsException();
}
return (com.smml.castor.bean.Developer) _developerList
elementAt(index);
} //-- com.smml.castor.bean.Developer getDeveloper(int)
/**
* Method getDeveloper
*/
public com.smml.castor.bean.Developer[] getDeveloper()
{
int size = _developerList.size();
com.smml.castor.bean.Developer[] mArray = new com.smml.castor.bean
Developer[size];
for (int index = 0; index < size; index++) {
mArray[index] = (com.smml.castor.bean.Developer) _developerList
elementAt(index);
}
return mArray;
} //-- com.smml.castor.bean.Developer[] getDeveloper()
/**
* Method getDeveloperCount
*/
public int getDeveloperCount()
{
return _developerList.size();
} //-- int getDeveloperCount()
/**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid()
/**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml
ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer)
/**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler)
/**
* Method removeAllDeveloper
*/
public void removeAllDeveloper()
{
_developerList.removeAllElements();
} //-- void removeAllDeveloper()
/**
* Method removeDeveloper
*
* @param index
*/
public com.smml.castor.bean.Developer removeDeveloper(int index)
{
java.lang.Object obj = _developerList.elementAt(index);
_developerList.removeElementAt(index);
return (com.smml.castor.bean.Developer) obj;
} //-- com.smml.castor.bean.Developer removeDeveloper(int)
/**
* Method setDeveloper
*
* @param index
* @param vDeveloper
*/
public void setDeveloper(int index, com.smml.castor.bean.Developer
vDeveloper)
throws java.lang.IndexOutOfBoundsException
{
//-- check bounds for index
if ((index < 0) || (index > _developerList.size())) {
throw new IndexOutOfBoundsException();
}
_developerList.setElementAt(vDeveloper, index);
} //-- void setDeveloper(int, com.smml.castor.bean.Developer)
/**
* Method setDeveloper
*
* @param developerArray
*/
public void setDeveloper(com.smml.castor.bean.Developer[]
developerArray)
{
//-- copy array
_developerList.removeAllElements();
for (int i = 0; i < developerArray.length; i++) {
_developerList.addElement(developerArray[i]);
}
} //-- void setDeveloper(com.smml.castor.bean.Developer)
/**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml
ValidationException
{
return (com.smml.castor.bean.Developers) Unmarshaller.unmarshal(com
smml.castor.bean.Developers.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader)
/**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor
xml.Validator();
validator.validate(this);
} //-- void validate()
}
/*
* This class was automatically generated with
* <a href="http://www.castor.org">Castor 0.9.5.3</a>, using an XML
* Schema.
* $Id$
*/
package com.smml.castor.bean;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;
/**
* Class Developer.
*
* @version $Revision$ $Date$
*/
public class Developer implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field _id
*/
private int _id;
/**
* keeps track of state for field: _id
*/
private boolean _has_id;
/**
* Field _name
*/
private java.lang.String _name;
/**
* Field _address
*/
private java.lang.String _address;
/**
* @sql-size 255
*/
private java.lang.String _email;
/**
* Field _organization
*/
private com.smml.castor.bean.Organization _organization;
/**
* @sql-size 255
*/
private java.lang.String _contact;
//----------------/
//- Constructors -/
//----------------/
public Developer() {
super();
} //-- com.smml.castor.bean.Developer()
//-----------/
//- Methods -/
//-----------/
/**
* Method deleteId
*/
public void deleteId()
{
this._has_id= false;
} //-- void deleteId()
/**
* Returns the value of field 'address'.
*
* @return the value of field 'address'.
*/
public java.lang.String getAddress()
{
return this._address;
} //-- java.lang.String getAddress()
/**
* Returns the value of field 'contact'. The field 'contact'
* has the following description: @sql-size 255
*
* @return the value of field 'contact'.
*/
public java.lang.String getContact()
{
return this._contact;
} //-- java.lang.String getContact()
/**
* Returns the value of field 'email'. The field 'email' has
* the following description: @sql-size 255
*
* @return the value of field 'email'.
*/
public java.lang.String getEmail()
{
return this._email;
} //-- java.lang.String getEmail()
/**
* Returns the value of field 'id'.
*
* @return the value of field 'id'.
*/
public int getId()
{
return this._id;
} //-- int getId()
/**
* Returns the value of field 'name'.
*
* @return the value of field 'name'.
*/
public java.lang.String getName()
{
return this._name;
} //-- java.lang.String getName()
/**
* Returns the value of field 'organization'.
*
* @return the value of field 'organization'.
*/
public com.smml.castor.bean.Organization getOrganization()
{
return this._organization;
} //-- com.smml.castor.bean.Organization getOrganization()
/**
* Method hasId
*/
public boolean hasId()
{
return this._has_id;
} //-- boolean hasId()
/**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid()
/**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml
ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer)
/**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler)
/**
* Sets the value of field 'address'.
*
* @param address the value of field 'address'.
*/
public void setAddress(java.lang.String address)
{
this._address = address;
} //-- void setAddress(java.lang.String)
/**
* Sets the value of field 'contact'. The field 'contact' has
* the following description: @sql-size 255
*
* @param contact the value of field 'contact'.
*/
public void setContact(java.lang.String contact)
{
this._contact = contact;
} //-- void setContact(java.lang.String)
/**
* Sets the value of field 'email'. The field 'email' has the
* following description: @sql-size 255
*
* @param email the value of field 'email'.
*/
public void setEmail(java.lang.String email)
{
this._email = email;
} //-- void setEmail(java.lang.String)
/**
* Sets the value of field 'id'.
*
* @param id the value of field 'id'.
*/
public void setId(int id)
{
this._id = id;
this._has_id = true;
} //-- void setId(int)
/**
* Sets the value of field 'name'.
*
* @param name the value of field 'name'.
*/
public void setName(java.lang.String name)
{
this._name = name;
} //-- void setName(java.lang.String)
/**
* Sets the value of field 'organization'.
*
* @param organization the value of field 'organization'.
*/
public void setOrganization(com.smml.castor.bean.Organization
organization)
{
this._organization = organization;
} //-- void setOrganization(com.smml.castor.bean.Organization)
/**
* Method unmarshal
*
* @param reader
*/
public static java.lang.Object unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml
ValidationException
{
return (com.smml.castor.bean.Developer) Unmarshaller.unmarshal(com
smml.castor.bean.Developer.class, reader);
} //-- java.lang.Object unmarshal(java.io.Reader)
/**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor
xml.Validator();
validator.validate(this);
} //-- void validate()
}
-------Original Message-------
From: [EMAIL PROTECTED]
Date: 13 Oktober 2004 22:10:51
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] Fw: My Castor Usage
Having not used the Castor source generator before who are the
developers wrapped? Is the Developers.java file an extension of a
vector, collection, something else? If so this could be a fairly
simple problem to solve.
On Wed, 13 Oct 2004 21:28:27 +0800, Ng Keng Yap <[EMAIL PROTECTED]>
wrote:
> Dear all gurus in this group,
>
> I honestly seeking for help in helping solving this problem. Please refer
to
> the below scenario, any of you have a good suggestion?
>
> Is my question too simple or naive? But i am really helpless. For the
whole
> week, i spent day and night referring to the manual and search in google.
I
> really had a sleepless week. Anyway, I dont think Castor is such difficult
> as it should simplify works, just feel that something is missing...
>
> I would appreciate for your help.
>
> Thanks.
>
> Cheers,
> Ng Keng Yap
>
> -------Original Message-------
>
> From: Ng Keng Yap
> Date: 13 Oktober 2004 20:23:30
> To: [EMAIL PROTECTED]
> Subject: My Castor Usage
>
> Dear all,
>
> I between the questions and answer regarding the OR Mapping, I think it is
> necessary for me to tell you the scenario...
>
> I am in the midst of developing a tool that can edit XML data, and load
the
> XML data to the relational database. I find that Castor has the capability
> to cater XML (Castor XML) and relational database (Castor JDO). To date, i
> have already successfully generated java objects using the source
generator
> that Castor provides. My tool will load the XML data to the java objects
and
> to be loaded to the relational database using JDO
create(rootElementObject)
> to the database.
>
> Here the problem arise. I notice that I dont need to use XML to Java
mapping
> but I think I still need the OR mapping right? I use the third party tool
> (JDOMapper) in helping me to simplify the mapping. However, when it comes
to
> a relation shown below, I can't handle it with castor although with the
help
> of the myapp example that show 1:N, N:1 and M:N cardinalities.
>
> <project id="id">
> <name>Project A</name>
> <developers>
> <developer name="id">
> <name>Ng Keng Yap</name>
> <email&gt;[EMAIL PROTECTED]</email>
>
>
> </developer>
> <developers>
> </project>
>
> In the above sample xml database, we can see there will be 3 java objects
to
> be created by the source generator, namely: project.java, developer.java
and
> developers.java
>
> In fact, developers.java is the wrapper of developer collection.
Developers
> java will have getter and setter for developer in array. Here is the
problem
> how can I map this to the database as:
>
> project(id, name);
> developer(id, project_id, name, email)
>
> the relationship between project:developer is 1:N.
>
> Can anybody here tell me how to do this in JDO? What is the mapping then?
>
> THANKS for your patient in reading thru this long-winded email.
>
> Best regards,
> Ng Keng Yap
>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
>
>
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user