Update of /cvsroot/jaxme/JaxMe2/src/net/sf/jaxme
In directory sc8-pr-cvs1:/tmp/cvs-serv9150/src/net/sf/jaxme
Added Files:
PM.java PMParams.java
Log Message:
Added the JdbcSchemaWriter; see examples/jdbc/session.xsd and
docs/Reference.html. Added xs:schema/xs:annotation/xs:appinfo/jm:schema.
--- NEW FILE: PM.java ---
package net.sf.jaxme;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import net.sf.jaxme.impl.JAXBContextImpl;
/** <p>The <code>persistence manager</code> (or <code>PM</code>
* for short) is responsible for reading objects from the
* database or storing them into the database.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public interface PM {
/** <p>Initializes the PM. Called from the
* [EMAIL PROTECTED] net.sf.jaxme.impl.JAXBContextImpl} upon initialization.</p>
*/
public void init(JAXBContextImpl pFactory, QName pQName) throws JAXBException;
/** <p>Returns fully qualified name of the document type handled
* by this manager.</p>
*/
public QName getQName();
/** <p>Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.</p>
*
* @param pObserver This Observer is notified for any matching document.
* The document is added as an argument.
* @param pQuery The query to perform.
*/
public void select(Observer pObserver, String pQuery) throws JAXBException;
/** <p>Reads documents matching the given query. For any document
* matching, the Observer's notify method is executed with the
* matching document as an argument.</p>
* <p>The query may contain placeholders. If it does, you have
* to supply an instance of [EMAIL PROTECTED] PMParams} with the placeholder
* values. Example:
* <pre>
* manager.select("Name = ? and Id = ?",
* new PMParams().addString("Someone").addInt(4));
* </pre></p>
*
* @param pObserver This Observer is notified for any matching document.
* The document is added as an argument.
* @param pQuery The query to perform. May contain placeholders.
* @param pPlaceHolderArgs An array of objects or null, if the
* query doesn't contain any placeholders.
*/
public void select(Observer pObserver, String pQuery,
PMParams pPlaceHolderArgs) throws JAXBException;
/** <p>Returns an iterator to all documents matching the given query.</p>
*
* @param pQuery The query to perform.
*/
public java.util.Iterator select(String pQuery) throws JAXBException;
/** <p>Returns an iterator to all documents matching the given query.
* The query may contain placeholders. If it does, you have
* to supply an instance of [EMAIL PROTECTED] PMParams} with the placeholder
* values. Example:
* <pre>
* manager.select("Name = ? and Id = ?",
* new PMParams().addString("Someone").addInt(4));
* </pre></p>
*
* @param pQuery The query to perform. May contain placeholders.
* @param pPlaceHolderArgs An array of objects or null, if the
* query doesn't contain any placeholders.
*/
public java.util.Iterator select(String pQuery,
PMParams pPlaceHolderArgs)
throws JAXBException;
/** <p>Inserts the given document into the database.</p>
*/
public void insert(JMElement element) throws JAXBException;
/** <p>Updates the given document in the database.</p>
*/
public void update(JMElement element) throws JAXBException;
/** <p>Deletes the given document from the database.</p>
*/
public void delete(JMElement element) throws JAXBException;
/** <p>Creates a new, empty element.</p>
*/
public JMElement create() throws JAXBException;
}
--- NEW FILE: PMParams.java ---
package net.sf.jaxme;
import java.io.Serializable;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/** <p>Implementation of a parameter object for use in
* [EMAIL PROTECTED] PM#select(Observer, String, PMParams)}.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public class PMParams implements Serializable {
public static final Integer INTEGER = new Integer(Types.INTEGER);
public static final Integer BIGINT = new Integer(Types.BIGINT);
public static final Integer VARCHAR = new Integer(Types.VARCHAR);
public static final Integer SMALLINT = new Integer(Types.SMALLINT);
public static final Integer TINYINT = new Integer(Types.TINYINT);
public static final Integer TIMESTAMP = new Integer(Types.TIMESTAMP);
public static final Integer DATE = new Integer(Types.DATE);
public static final Integer TIME = new Integer(Types.TIME);
public static final Integer VARBINARY = new Integer(Types.VARBINARY);
private List params;
private int max, start;
private void addParam(Integer pType, Object o) {
if (params == null) { params = new ArrayList(); }
params.add(pType);
params.add(o);
}
/** <p>Adds a String parameter.</p>
*/
public PMParams addParam(String pParam) {
addParam(VARCHAR, pParam);
return this;
}
/** <p>Adds a Long parameter.</p>
*/
public PMParams addParam(Long pParam) {
addParam(BIGINT, pParam);
return this;
}
/** <p>Adds a long parameter.</p>
*/
public PMParams addParam(long pParam) {
addParam(BIGINT, new Long(pParam));
return this;
}
/** <p>Adds an Integer parameter.</p>
*/
public PMParams addParam(Integer pParam) {
addParam(INTEGER, pParam);
return this;
}
/** <p>Adds an int parameter.</p>
*/
public PMParams addParam(int pParam) {
addParam(INTEGER, new Integer(pParam));
return this;
}
/** <p>Adds a Short parameter.</p>
*/
public PMParams addParam(Short pParam) {
addParam(SMALLINT, pParam);
return this;
}
/** <p>Adds an int parameter.</p>
*/
public PMParams addParam(short pParam) {
addParam(SMALLINT, new Short(pParam));
return this;
}
/** <p>Adds a Byte parameter.</p>
*/
public PMParams addParam(Byte pParam) {
addParam(TINYINT, pParam);
return this;
}
/** <p>Adds an int parameter.</p>
*/
public PMParams addParam(byte pParam) {
addParam(TINYINT, new Byte(pParam));
return this;
}
/** <p>Adds a DateTime parameter.</p>
*/
public PMParams addDateTimeParam(Calendar pParam) {
addParam(TIMESTAMP, pParam);
return this;
}
/** <p>Adds a VARBINARY parameter.</p>
*/
public PMParams addParam(byte[] pParam) {
addParam(VARBINARY, pParam);
return this;
}
/** <p>Adds a Date parameter.</p>
*/
public PMParams addDateParam(Calendar pParam) {
addParam(DATE, pParam);
return this;
}
/** <p>Adds a Time parameter.</p>
*/
public PMParams addTimeParam(Calendar pParam) {
addParam(TIME, pParam);
return this;
}
/** <p>Sets the maximum number of result documents.</p>
*/
public void setMaxResultDocuments(int pMax) {
max = pMax;
}
/** <p>Returns the maximum number of result documents
* or 0 (default) for an unlimited number.</p>
*/
public int getMaxResultDocuments() {
return max;
}
/** <p>Sets the maximum number of documents to skip
* at the beginning (soft cursoring).</p>
*/
public void setSkippedResultDocuments(int pStart) {
start = pStart;
}
/** <p>Sets the maximum number of documents to skip
* at the beginning or 0 (default) to skip no documents.</p>
*/
public int getSkippedResultDocuments() {
return start;
}
}
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
Jaxme-jaxb-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxme-jaxb-dev