db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r430936 [1/5] - in /db/ojb/trunk/proposals/jdo: ./ java/ java/org/ java/org/apache/ java/org/apache/ojb/ java/org/apache/ojb/jdo/ java/org/apache/ojb/jdo/jdoql/ java/org/apache/ojb/jdo/spi/ test/ test/org/ test/org/apache/ test/org/apache/o...
Date Sat, 12 Aug 2006 01:17:49 GMT
Author: arminw
Date: Fri Aug 11 18:17:46 2006
New Revision: 430936

URL: http://svn.apache.org/viewvc?rev=430936&view=rev
Log:
move alpha jdo2.0 source to proposals

Added:
    db/ojb/trunk/proposals/jdo/
    db/ojb/trunk/proposals/jdo/java/
    db/ojb/trunk/proposals/jdo/java/org/
    db/ojb/trunk/proposals/jdo/java/org/apache/
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/ExtentImpl.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/JDOConstants.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerFactoryImpl.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerImpl.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/QueryImpl.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/TransactionImpl.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ASTWithPositionInfo.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Acceptor.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/BinaryExpression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Expression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/FieldAccess.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Import.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLLexer.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLParser.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLParserTokenTypes.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLParserTokenTypes.txt
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLTokenTypes.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLTokenTypes.txt
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLTreeParser.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLTreeParserTokenTypes.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/JDOQLTreeParserTokenTypes.txt
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Literal.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/LocalVariable.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/LocalVariableAccess.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/MethodInvocation.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/NameExpression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/NullLiteral.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Ordering.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/PostfixExpression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/QueryParsingHelper.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/QueryTreeNode.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/QueryTreeResolver.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ThisExpression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Type.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/TypeAccess.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/UnaryExpression.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Visitor.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/VisitorBase.java
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/jdoql-ojb-lexer.g
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/jdoql-ojb-parser.g
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/jdoql-ojb-treeparser.g
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/spi/
    db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/spi/StateManagerImpl.java
    db/ojb/trunk/proposals/jdo/test/
    db/ojb/trunk/proposals/jdo/test/org/
    db/ojb/trunk/proposals/jdo/test/org/apache/
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/jdo/
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/jdo/TestJDOQL.java
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/jdo/TestPersistenceManager.java
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/jdo/TestQueries.java
    db/ojb/trunk/proposals/jdo/test/org/apache/ojb/jdo/TestTransactions.java

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/ExtentImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/ExtentImpl.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/ExtentImpl.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/ExtentImpl.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,149 @@
+package org.apache.ojb.jdo;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+
+import org.apache.ojb.broker.accesslayer.OJBIterator;
+import org.apache.ojb.broker.accesslayer.RsIterator;
+import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.QueryByCriteria;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.otm.OTMConnection;
+
+/**
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
+ * @version $Id: ExtentImpl.java 363720 2004-05-22 13:28:47 +0200 (Sa, 22 Mai 2004) brj $
+ */
+public class ExtentImpl implements Extent
+{
+	private Class m_clazz;
+	private OTMConnection m_conn;
+	private PersistenceManager m_pm;
+    private HashSet m_iterators = new HashSet();
+    private Criteria m_criteria;
+
+    /**
+	 * Constructor for ExtentImpl.
+     * @param subclasses is ignored
+	 */
+	public ExtentImpl(Class pClazz, OTMConnection conn, PersistenceManager pm, boolean subclasses)
+	{
+		m_clazz = pClazz;
+		m_conn = conn;
+		m_pm = pm;
+        m_criteria = new Criteria();
+	}
+
+    Class ojbGetClass()
+    {
+        return m_clazz;
+    }
+
+    /**
+     * @todo is this supposed to operate outside of a user specified tx? Right now it obtains one if needed
+     */
+	public Iterator iterator()
+	{
+        QueryByCriteria q = QueryFactory.newQuery(m_clazz, m_criteria);
+        ExtentIterator itty = new ExtentIterator((OJBIterator) m_conn.getIteratorByQuery(q));
+        m_iterators.add(itty);
+		return itty;
+	}
+
+	public boolean hasSubclasses()
+	{
+		ClassDescriptor cld = m_conn.getDescriptorFor(m_clazz);
+		return cld.isExtent();
+	}
+
+	public Class getCandidateClass()
+	{
+		return m_clazz;
+	}
+
+	public PersistenceManager getPersistenceManager()
+	{
+		return m_pm;
+	}
+
+	public void closeAll()
+	{
+		for (Iterator iterator = m_iterators.iterator(); iterator.hasNext();)
+        {
+            ExtentIterator itty = (ExtentIterator) iterator.next();
+            itty.close();
+            iterator.remove();
+        }
+	}
+
+	public void close(Iterator iterator)
+	{
+		if (iterator instanceof ExtentIterator && m_iterators.contains(iterator))
+        {
+            m_iterators.remove(iterator);
+            ((ExtentIterator)iterator).close();
+        }
+	}
+
+    private class ExtentIterator implements Iterator
+    {
+        private OJBIterator itty;
+        private boolean closed = false;
+
+        ExtentIterator(OJBIterator itty)
+        {
+            this.itty = itty;
+        }
+
+        public boolean hasNext()
+        {
+            if (closed) return false;
+            return itty.hasNext();
+        }
+
+        public Object next()
+        {
+            if (closed) throw new NoSuchElementException("Calling next() on closed JDO iterator");
+            try
+            {
+            return itty.next();
+            }
+            catch (RsIterator.ResourceClosedException e)
+            {
+                throw new NoSuchElementException("Calling next() on closed JDO iterator");
+            }
+        }
+
+        public void remove()
+        {
+            throw new UnsupportedOperationException("Operation Not Allowd");
+        }
+
+        private void close()
+        {
+            itty.releaseDbResources();
+            closed = true;
+        }
+    }
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/JDOConstants.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/JDOConstants.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/JDOConstants.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/JDOConstants.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,38 @@
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ojb.jdo;
+
+/**
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ */
+
+public interface JDOConstants
+{
+	public static final String PERSISTENCE_MANAGER_FACTORY_CLASS = "javax.jdo.PersistenceManagerFactoryClass";
+	public static final String OPTIMISTIC = "javax.jdo.option.Optimistic";
+	public static final String RETAIN_VALUES = "javax.jdo.option.RetainValues";
+	public static final String RESTORE_VALUES = "javax.jdo.option.RestoreValues";
+	public static final String IGNORE_CACHE = "javax.jdo.option.IgnoreCache";
+	public static final String NON_TRANSACTIONAL_READ = "javax.jdo.option.NontransactionalRead";
+	public static final String NON_TRANSACTIONAL_WRITE = "javax.jdo.option.NontransactionalWrite";
+	public static final String MULTI_THREADED = "javax.jdo.option.Multithreaded";
+	public static final String CONNECTION_USER_NAME = "javax.jdo.option.ConnectionUserName";
+	public static final String CONNECTION_PASSWORD = "javax.jdo.option.ConnectionPassword";
+	public static final String CONNECTION_URL = "javax.jdo.option.ConnectionURL";
+	public static final String CONNECTION_FACTORY_NAME = "javax.jdo.option.ConnectionFactoryName";
+	public static final String CONNECTION_FACTORY_2_NAME ="javax.jdo.option.ConnectionFactory2Name";
+	public static final String ALIAS ="javax.jdo.option.OjbAlias";
+
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerFactoryImpl.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerFactoryImpl.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerFactoryImpl.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,409 @@
+package org.apache.ojb.jdo;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Properties;
+
+import org.apache.commons.lang.BooleanUtils;
+
+/**
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ */
+
+public class PersistenceManagerFactoryImpl implements PersistenceManagerFactory
+{
+	/**
+	 * flags
+	 */
+	private boolean m_optimistic = true;
+	private boolean m_retainValues = true;
+	private boolean m_restoreValues = true;
+	private boolean m_nonTransactionalRead = true;
+	private boolean m_nonTransactionalWrite = false;
+	private boolean m_ignoreCache = true;
+	private boolean m_multiThreaded = false;
+
+	/**
+	 * pool information
+	 */
+	private int m_minPool = 1;
+	private int m_maxPool = 1;
+	private int m_msWait = 0;
+
+	/**
+	 * connection factory information
+	 */
+	private Object m_connectionFactory;
+	private String m_connectionFactoryName;
+
+	private Object m_connectionFactory2;
+	private String m_connectionFactory2Name;
+
+	private String m_connectionDriverName;
+	private String m_connectionURL;
+
+	private String m_connectionPassword;
+	private String m_connectionName;
+
+	private String m_alias;
+
+	/**
+	 * support options
+	 */
+	private final String[] m_implementedOptions = new String[]{
+		"javax.jdo.option.TransientTransactional",
+		"javax.jdo.option.NontransactionalRead",
+		"javax.jdo.option.NontransactionalWrite",
+		"javax.jdo.option.RetainValues",
+		"javax.jdo.option.RestoreValues",
+		"javax.jdo.option.Optimistic",
+		"javax.jdo.option.ApplicationIdentity",
+		"javax.jdo.option.DatastoreIdentity",
+		"javax.jdo.option.NonDatastoreIdentity",
+		"javax.jdo.option.ArrayList",
+		"javax.jdo.option.HashMap",
+		"javax.jdo.option.Hashtable",
+		"javax.jdo.option.LinkedList",
+		"javax.jdo.option.TreeMap",
+		"javax.jdo.option.TreeSet",
+		"javax.jdo.option.Vector",
+		"javax.jdo.option.Map",
+		"javax.jdo.option.List",
+		"javax.jdo.option.Array",
+		"javax.jdo.option.NullCollection",
+		"javax.jdo.query.JDOQL"
+	};
+
+	/**
+	 * properties
+	 */
+	private static Properties PROPERTIES = new Properties();
+
+	static
+	{
+		PROPERTIES.put("VendorName", "Apache ObjectRelationalBridge");
+		PROPERTIES.put("VersionNumber", "1.0");
+	}
+
+	/**
+	 * This method returns an instance of PersistenceManagerFactory based on the properties
+	 * in the parameter. It is used by JDOHelper to construct an instance of PersistenceManagerFactory
+	 * based on user-specified properties.
+	 * The following are standard key values for the Properties:
+	 * Java Data Objects1.0
+	 * javax.jdo.PersistenceManagerFactoryClass --> Ignored, we only have one and that is PersistenceManagerFactoryImpl
+	 * javax.jdo.option.Optimistic
+	 * javax.jdo.option.RetainValues
+	 * javax.jdo.option.RestoreValues
+	 * javax.jdo.option.IgnoreCache
+	 * javax.jdo.option.NontransactionalRead
+	 * javax.jdo.option.NontransactionalWrite
+	 * javax.jdo.option.Multithreaded
+	 *
+	 * javax.jdo.option.ConnectionUserName
+	 * javax.jdo.option.ConnectionPassword
+	 * javax.jdo.option.ConnectionURL
+	 * javax.jdo.option.ConnectionFactoryName
+	 * javax.jdo.option.ConnectionFactory2Name
+	 * @see JDOConstants
+	 * @param props
+	 * @return the PersistenceManagerFactory instance with the appropriate Properties.
+	 */
+	public static PersistenceManagerFactory getPersistenceManagerFactory(Properties props)
+	{
+		PersistenceManagerFactoryImpl retval = new PersistenceManagerFactoryImpl();
+		// parse and set the properties
+		// boolean props
+		retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC, BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));
+		retval.setRetainValues(Boolean.getBoolean(props.getProperty(JDOConstants.RETAIN_VALUES, BooleanUtils.toStringTrueFalse(retval.getRetainValues()))));
+		retval.setRestoreValues(Boolean.getBoolean(props.getProperty(JDOConstants.RESTORE_VALUES, BooleanUtils.toStringTrueFalse(retval.getRestoreValues()))));
+		retval.setIgnoreCache(Boolean.getBoolean(props.getProperty(JDOConstants.IGNORE_CACHE, BooleanUtils.toStringTrueFalse(retval.getIgnoreCache()))));
+		retval.setNontransactionalRead(Boolean.getBoolean(props.getProperty(JDOConstants.NON_TRANSACTIONAL_READ, BooleanUtils.toStringTrueFalse(retval.getNontransactionalRead()))));
+		retval.setMultithreaded(Boolean.getBoolean(props.getProperty(JDOConstants.MULTI_THREADED, BooleanUtils.toStringTrueFalse(retval.getMultithreaded()))));
+		retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC, BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));
+		retval.setOptimistic(Boolean.getBoolean(props.getProperty(JDOConstants.OPTIMISTIC, BooleanUtils.toStringTrueFalse(retval.getOptimistic()))));
+
+		// string props
+		retval.setConnectionUserName(props.getProperty(JDOConstants.CONNECTION_USER_NAME, retval.getConnectionUserName()));
+		retval.setConnectionPassword(props.getProperty(JDOConstants.CONNECTION_PASSWORD, null));
+		retval.setConnectionURL(props.getProperty(JDOConstants.CONNECTION_URL, retval.getConnectionURL()));
+		retval.setConnectionFactoryName(props.getProperty(JDOConstants.CONNECTION_FACTORY_NAME, retval.getConnectionFactoryName()));
+		retval.setConnectionFactory2Name(props.getProperty(JDOConstants.CONNECTION_FACTORY_2_NAME, retval.getConnectionFactory2Name()));
+		retval.setAlias(props.getProperty(JDOConstants.ALIAS, retval.getAlias()));
+		return retval;
+	}
+
+	public PersistenceManager getPersistenceManager()
+	{
+		return getPersistenceManager(null, null, null);
+	}
+
+	public PersistenceManager getPersistenceManager(String userid, String password)
+	{
+		return getPersistenceManager(null, userid, password);
+	}
+
+	public PersistenceManager getPersistenceManager(String alias, String userid, String password)
+	{
+		return new PersistenceManagerImpl(this, alias, userid, password);
+	}
+
+	public String getAlias()
+	{
+		return m_alias;
+	}
+
+	public void setAlias(String alias)
+	{
+		m_alias = alias;
+	}
+
+	public void setConnectionUserName(String s)
+	{
+		m_connectionName = s;
+	}
+
+	public String getConnectionUserName()
+	{
+		return m_connectionName;
+	}
+
+	public void setConnectionPassword(String s)
+	{
+		m_connectionPassword = s;
+	}
+
+	public void setConnectionURL(String s)
+	{
+		m_connectionURL = s;
+	}
+
+	public String getConnectionURL()
+	{
+		return m_connectionURL;
+	}
+
+	public void setConnectionDriverName(String s)
+	{
+		m_connectionDriverName = s;
+	}
+
+	public String getConnectionDriverName()
+	{
+		return m_connectionDriverName;
+	}
+
+	public void setConnectionFactoryName(String s)
+	{
+		m_connectionFactoryName = s;
+	}
+
+	public String getConnectionFactoryName()
+	{
+		return m_connectionFactoryName;
+	}
+
+	public void setConnectionFactory(Object o)
+	{
+		m_connectionFactory = o;
+	}
+
+	public Object getConnectionFactory()
+	{
+		return m_connectionFactory;
+	}
+
+	public void setConnectionFactory2Name(String s)
+	{
+		m_connectionFactory2Name = s;
+	}
+
+	public String getConnectionFactory2Name()
+	{
+		return m_connectionFactory2Name;
+	}
+
+	public void setConnectionFactory2(Object o)
+	{
+		m_connectionFactory2 = o;
+	}
+
+	public Object getConnectionFactory2()
+	{
+		return m_connectionFactory2;
+	}
+
+	public void setMultithreaded(boolean b)
+	{
+		m_multiThreaded = b;
+	}
+
+	public boolean getMultithreaded()
+	{
+		return m_multiThreaded;
+	}
+
+	public void setOptimistic(boolean b)
+	{
+		m_optimistic = b;
+	}
+
+	public boolean getOptimistic()
+	{
+		return m_optimistic;
+	}
+
+	public void setRetainValues(boolean b)
+	{
+		m_retainValues = b;
+	}
+
+	public boolean getRetainValues()
+	{
+		return m_retainValues;
+	}
+
+	public void setRestoreValues(boolean b)
+	{
+		m_restoreValues = b;
+	}
+
+	public boolean getRestoreValues()
+	{
+		return m_restoreValues;
+	}
+
+	public void setNontransactionalRead(boolean b)
+	{
+		m_nonTransactionalRead = b;
+	}
+
+	public boolean getNontransactionalRead()
+	{
+		return m_nonTransactionalRead;
+	}
+
+	public void setNontransactionalWrite(boolean b)
+	{
+		m_nonTransactionalWrite = b;
+	}
+
+	public boolean getNontransactionalWrite()
+	{
+		return m_nonTransactionalWrite;
+	}
+
+	public void setIgnoreCache(boolean b)
+	{
+		m_ignoreCache = b;
+	}
+
+	public boolean getIgnoreCache()
+	{
+		return m_ignoreCache;
+	}
+
+	public int getMaxPool()
+	{
+		return m_maxPool;
+	}
+
+	public void setMaxPool(int i)
+	{
+		m_maxPool = i;
+	}
+
+	public int getMinPool()
+	{
+		return m_minPool;
+	}
+
+	public void setMinPool(int i)
+	{
+		m_minPool = i;
+	}
+
+	public int getMsWait()
+	{
+		return m_msWait;
+	}
+
+	public void setMsWait(int i)
+	{
+		m_msWait = i;
+	}
+
+	/**
+	 * Return "static" properties of this PersistenceManagerFactory.
+	 * Properties with keys VendorName and VersionNumber are required.  Other
+	 * keys are optional.
+	 * @return the non-operational properties of this PersistenceManagerFactory.
+	 */
+	public Properties getProperties()
+	{
+		return PROPERTIES;
+	}
+
+	/** The application can determine from the results of this
+	 * method which optional features are supported by the
+	 * JDO implementation.
+	 * <P>Each supported JDO optional feature is represented by a
+	 * String with one of the following values:
+	 *
+	 * <P>javax.jdo.option.TransientTransactional
+	 * <P>javax.jdo.option.NontransactionalRead
+	 * <P>javax.jdo.option.NontransactionalWrite
+	 * <P>javax.jdo.option.RetainValues
+	 * <P>javax.jdo.option.RestoreValues
+	 * <P>javax.jdo.option.Optimistic
+	 * <P>javax.jdo.option.ApplicationIdentity
+	 * <P>javax.jdo.option.DatastoreIdentity
+	 * <P>javax.jdo.option.NonDatastoreIdentity
+	 * <P>javax.jdo.option.ArrayList
+	 * <P>javax.jdo.option.HashMap
+	 * <P>javax.jdo.option.Hashtable
+	 * <P>javax.jdo.option.LinkedList
+	 * <P>javax.jdo.option.TreeMap
+	 * <P>javax.jdo.option.TreeSet
+	 * <P>javax.jdo.option.Vector
+	 * <P>javax.jdo.option.Map
+	 * <P>javax.jdo.option.List
+	 * <P>javax.jdo.option.Array
+	 * <P>javax.jdo.option.NullCollection
+	 *
+	 *<P>The standard JDO query language is represented by a String:
+	 *<P>javax.jdo.query.JDOQL
+	 * @return the Set of String representing the supported Options
+	 */
+	public Collection supportedOptions()
+	{
+		return Collections.unmodifiableCollection(Arrays.asList(m_implementedOptions));
+	}
+	/* (non-Javadoc)
+	 * @see javax.jdo.PersistenceManagerFactory#close()
+	 */
+	public void close()
+	{
+		// TODO Auto-generated method stub
+
+	}
+
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerImpl.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerImpl.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/PersistenceManagerImpl.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,877 @@
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ojb.jdo;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.Extent;
+import javax.jdo.InstanceCallbacks;
+import javax.jdo.JDOFatalUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.ojb.broker.Identity;
+import org.apache.ojb.broker.OJB;
+import org.apache.ojb.broker.PBKey;
+import org.apache.ojb.broker.core.proxy.CollectionProxy;
+import org.apache.ojb.otm.EditingContext;
+import org.apache.ojb.otm.OTMConnection;
+import org.apache.ojb.otm.OTMKit;
+import org.apache.ojb.otm.kit.SimpleKit;
+import org.apache.ojb.otm.lock.LockType;
+import org.apache.ojb.otm.lock.LockingException;
+import org.apache.ojb.otm.states.State;
+
+/**
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
+ */
+
+public class PersistenceManagerImpl implements PersistenceManager
+{
+    private OTMConnection m_conn;
+    private OTMKit m_kit;
+    private boolean m_multiThreaded = false;
+    private boolean m_ignoreCache = false;
+    private PersistenceManagerFactory m_factory;
+    private String m_userID;
+    private String m_password;
+    private String m_alias;
+    private Object m_usersObject;
+    private TransactionImpl m_tx;
+    private OJB ojb;
+
+    public PersistenceManagerImpl(PersistenceManagerFactory factory, String alias, String userid, String password)
+    {
+        m_factory = factory;
+        m_userID = userid;
+        m_password = password;
+        m_alias = alias;
+        m_kit = SimpleKit.getInstance();
+
+        ojb = new OJB();
+        
+        /**
+         * if the alias is null, use the default.
+         */
+        if (null == m_alias)
+        {
+            m_conn = m_kit.acquireConnection(ojb.getDefaultConfiguration());
+        }
+        else
+        {
+            PBKey key = new PBKey(m_alias, m_userID, m_password);
+            m_conn = m_kit.acquireConnection(ojb.getConfiguration(key));
+        }
+        m_tx = new TransactionImpl(this, m_kit, m_conn);
+    }
+
+    OTMConnection getConnection()
+    {
+        return this.m_conn;
+    }
+
+    OTMKit getKit()
+    {
+        return this.m_kit;
+    }
+
+    public boolean isClosed()
+    {
+        return m_conn.isClosed();
+    }
+
+    /**
+     * Close database resources and
+     * Rollback transaction if there is one in progress
+     */
+    public void close()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("close()"));
+        }
+        if (m_tx.isActive()) m_tx.rollback();
+        m_conn.close();
+    }
+
+    public Transaction currentTransaction()
+    {
+        return m_tx;
+    }
+
+    /**
+     * evict all persistent-clean instances from the editing context cache
+     *
+     * @param o
+     */
+    public void evict(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("evict(Object)"));
+        }
+        if (null != o)
+        {
+            try
+            {
+                Identity oid = m_conn.getIdentity(o);
+                State state = m_conn.getEditingContext().lookupState(oid);
+                /**
+                 * if the object is PersistentClean or non transactional, evict it.
+                 */
+                if (State.PERSISTENT_CLEAN == state)
+                {
+                    /**
+                     * spec says call the jdoPreClear if it's InstanceCallbacks aware
+                     */
+                    if (o instanceof InstanceCallbacks)
+                    {
+                        ((InstanceCallbacks) o).jdoPreClear();
+                    }
+                    m_conn.invalidate(m_conn.getIdentity(o));
+                    /**
+                     * set all fields to their default values
+                     */
+
+                    /**
+                     * set state to hollow
+                     */
+                }
+                if (null == state)
+                {
+                    /**
+                     * not in the editing context, evict it from the global cache
+                     */
+                    m_conn.serviceObjectCache().remove(m_conn.getIdentity(o));
+                }
+            }
+            catch (LockingException e)
+            {
+                /**
+                 * shouldn't happen, we're only dealing with persistentClean and non transactional (aka non-locked)
+                 * objects.
+                 */
+            }
+        }
+    }
+
+    public void evictAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("evictAll(Object[]) was passed a null Array.");
+        }
+        int length = objects.length;
+        for (int i = 0; i < length; i++)
+        {
+            evict(objects[i]);
+        }
+    }
+
+    public void evictAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("evictAll(Collection) was passed a null Collection.");
+        }
+        Iterator it = collection.iterator();
+        while (it.hasNext())
+        {
+            evict(it.next());
+        }
+    }
+
+    public void evictAll()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("evictAll()"));
+        }
+        EditingContext ctx = m_conn.getEditingContext();
+        if (ctx != null)
+        {
+            for (Iterator i = ctx.getAllObjectsInContext().iterator(); i.hasNext();)
+            {
+                evict(i.next());
+            }
+        }
+        /**
+         * clear the rest of the global cache
+         */
+        m_conn.serviceObjectCache().clear();
+    }
+
+    public void refresh(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("refresh(Object)"));
+        }
+        m_conn.refresh(o);
+        if (o instanceof InstanceCallbacks)
+        {
+            ((InstanceCallbacks) o).jdoPostLoad();
+        }
+    }
+
+    public void refreshAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("refreshAll(Object[]) was passed a null Array.");
+        }
+        int length = objects.length;
+        for (int i = 0; i < length; i++)
+        {
+            refresh(objects[i]);
+        }
+    }
+
+    public void refreshAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("refreshAll(Collection) was passed a null Collection.");
+        }
+        Iterator it = collection.iterator();
+        while (it.hasNext())
+        {
+            refresh(it.next());
+        }
+    }
+
+    public void refreshAll()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("refreshAll()"));
+        }
+        if (currentTransaction().isActive())
+        {
+            Collection collection = m_conn.getEditingContext().getAllObjectsInContext();
+            Iterator it = collection.iterator();
+            while (it.hasNext())
+            {
+                refresh(it.next());
+            }
+        }
+    }
+
+    public Query newQuery()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery()"));
+        }
+
+        return new QueryImpl(this);
+    }
+
+    public Query newQuery(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Object)"));
+        }
+        try
+        {
+            return ((QueryImpl) o).ojbClone();
+        }
+        catch (ClassCastException e)
+        {
+            throw new IllegalArgumentException("newQuery(Object) must be passed a Query instance");
+        }
+    }
+
+    public Query newQuery(String s, Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(String, Object)"));
+        }
+
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    public Query newQuery(Class aClass)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class)"));
+        }
+        Query query = new QueryImpl(this);
+        query.setClass(aClass);
+        return query;
+    }
+
+    public Query newQuery(Extent extent)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent)"));
+        }
+
+        Query query = new QueryImpl(this);
+        query.setCandidates(extent);
+        return query;
+    }
+
+    public Query newQuery(Class aClass, Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection)"));
+        }
+        Query query = new QueryImpl(this);
+        query.setCandidates(collection);
+        query.setClass(aClass);
+        return query;
+    }
+
+    public Query newQuery(Class aClass, String s)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, String)"));
+        }
+        Query query = new QueryImpl(this);
+        query.setClass(aClass);
+        query.setFilter(s);
+        return query;
+    }
+
+    public Query newQuery(Class aClass, Collection collection, String s)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Class, Collection, String)"));
+        }
+        Query query = new QueryImpl(this);
+        query.setCandidates(collection);
+        query.setClass(aClass);
+        query.setFilter(s);
+        return query;
+    }
+
+    public Query newQuery(Extent extent, String s)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newQuery(Extent, String)"));
+        }
+        Query query = new QueryImpl(this);
+        query.setCandidates(extent);
+        query.setFilter(s);
+        return query;
+    }
+
+    /**
+     * @param aClass top level class
+     * @param include_extent      include subclasses, presently ignored
+     * @return
+     * @todo figure out how to implement, may have to query all and filter objects
+     */
+    public Extent getExtent(Class aClass, boolean include_extent)
+    {
+        if (!include_extent) throw new UnsupportedOperationException("Not yet implemented!");
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getExtent(Class, boolean)"));
+        }
+        return new ExtentImpl(aClass, m_conn, this, include_extent);
+    }
+
+    public Object getObjectById(Object o, boolean validate)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectById(Object, boolean)"));
+        }
+        Object retval = null;
+        try
+        {
+            retval = m_conn.getObjectByIdentity((Identity) o);
+        }
+        catch (LockingException e)
+        {
+            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
+        }
+        catch (ClassCastException e)
+        {
+            throw new IllegalArgumentException("Object passed as id is not an id: " + o);
+        }
+        return retval;
+    }
+
+    /**
+     * @todo verify that Identity meets the requirements of the JDO spec
+     */
+    public Object getObjectId(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectId(Object)"));
+        }
+        return m_conn.getIdentity(o);
+    }
+
+    public Object getTransactionalObjectId(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getTransactionalObjectId(Object)"));
+        }
+        return m_conn.getIdentity(o);
+    }
+
+    public Object newObjectIdInstance(Class aClass, String s)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("newObjectIdInstance(Class, String)"));
+        }
+        return null;
+    }
+
+    public void makePersistent(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistent(Object)"));
+        }
+        try
+        {
+            m_conn.makePersistent(o);
+        }
+        catch (LockingException e)
+        {
+            // throw runtime exception
+        }
+    }
+
+    public void makePersistentAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("makePersistentAll(Object[]) was passed a null Array.");
+        }
+        int length = objects.length;
+        for (int i = 0; i < length; i++)
+        {
+            makePersistent(objects[i]);
+        }
+    }
+
+    public void makePersistentAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makePersistentAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("makePersistentAll(Collection) was passed a null Collection.");
+        }
+        Iterator it = collection.iterator();
+        while (it.hasNext())
+        {
+            makePersistent(it.next());
+        }
+    }
+
+    public void deletePersistent(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistent(Object)"));
+        }
+        try
+        {
+            m_conn.deletePersistent(o);
+        }
+        catch (LockingException e)
+        {
+            handleLockingException(e);
+        }
+    }
+
+    public void deletePersistentAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("deletePersistentAll(Object[]) was passed a null Array.");
+        }
+        int length = objects.length;
+        for (int i = 0; i < length; i++)
+        {
+            deletePersistent(objects[i]);
+        }
+    }
+
+    public void deletePersistentAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("deletePersistentAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("deletePersistentAll(Collection) was passed a null Collection.");
+        }
+        Iterator it = collection.iterator();
+        while (it.hasNext())
+        {
+            deletePersistent(it.next());
+        }
+    }
+
+    /**
+     * Right now this makes the object non-transactional.
+     *
+     * @todo figure out what this is supposed to really do
+     */
+    public void makeTransient(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransient(Object)"));
+        }
+        m_conn.getEditingContext().remove(m_conn.getIdentity(o));
+        m_conn.serviceObjectCache().remove(m_conn.getIdentity(o));
+    }
+
+    public void makeTransientAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("makeTransientAll(Object[]) was passed a null Array.");
+        }
+        for (int i = 0; i < objects.length; i++)
+        {
+            this.makeTransient(objects[i]);
+        }
+    }
+
+    public void makeTransientAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransientAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("makeTransientAll(Collection) was passed a null Collection.");
+        }
+        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
+        {
+            this.makeTransient(iterator.next());
+        }
+    }
+
+    public void makeTransactional(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactional(Object)"));
+        }
+        try
+        {
+            m_conn.getEditingContext().insert(m_conn.getIdentity(o), o, LockType.READ_LOCK);
+        }
+        catch (LockingException e)
+        {
+            handleLockingException(e);
+        }
+    }
+
+    public void makeTransactionalAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("makeTransactionalAll(Object[]) was passed a null Array.");
+        }
+        for (int i = 0; i < objects.length; i++)
+        {
+            this.makeTransactional(objects[i]);
+        }
+    }
+
+    public void makeTransactionalAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeTransactionalAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("makeTransactionalAll(Collection) was passed a null Collection.");
+        }
+        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
+        {
+            this.makeTransactional(iterator.next());
+        }
+    }
+
+    /**
+     * @todo What is the difference between this and makeTransient?
+     */
+    public void makeNontransactional(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactional(Object)"));
+        }
+        this.makeTransient(o);
+    }
+
+    public void makeNontransactionalAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("makeNontransactionalAll(Object[]) was passed a null Array.");
+        }
+        for (int i = 0; i < objects.length; i++)
+        {
+            this.makeNontransactional(objects[i]);
+        }
+    }
+
+    public void makeNontransactionalAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("makeNontransactionalAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("makeNontransactionalAll(Collection) was passed a null Collection.");
+        }
+        for (Iterator iterator = collection.iterator(); iterator.hasNext();)
+        {
+            this.makeNontransactional(iterator.next());
+        }
+    }
+
+    /**
+     * Force materialization of real object
+     * @param o
+     */
+    public void retrieve(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieve(Object)"));
+        }
+        ojb.getProxyFactory().getRealObject(o);
+    }
+
+    /**
+     * Force materialization of all items in collection
+     * @param collection
+     */
+    public void retrieveAll(Collection collection)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Collection)"));
+        }
+        if (null == collection)
+        {
+            throw new NullPointerException("retrieveAll(Collection) was passed a null Collection.");
+        }
+
+        /* @todo I consider this a hack as CPDI is configurable now! */
+        if (ojb.getProxyFactory().isCollectionProxy(collection))
+        {
+            CollectionProxy cp = (CollectionProxy) collection;
+            cp.load();
+        }
+    }
+
+    public void retrieveAll(Object[] objects)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("retrieveAll(Object[])"));
+        }
+        if (null == objects)
+        {
+            throw new NullPointerException("retrieveAll(Object[]) was passed a null Array.");
+        }
+        // We don't proxy arrays
+    }
+
+    public void setUserObject(Object o)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("setUserObject(Object)"));
+        }
+        m_usersObject = o;
+    }
+
+    public Object getUserObject()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getUserObject()"));
+        }
+        return m_usersObject;
+    }
+
+    public PersistenceManagerFactory getPersistenceManagerFactory()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getPersistenceManagerFactory()"));
+        }
+        return this.m_factory;
+    }
+
+    /**
+     * @todo This will need to change when we have a JDO compliant Identity implementation
+     */
+    public Class getObjectIdClass(Class aClass)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getObjectIdClass(Class)"));
+        }
+        return Identity.class;
+    }
+
+    public void setMultithreaded(boolean b)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("setMultithreaded(boolean)"));
+        }
+        m_multiThreaded = b;
+    }
+
+    public boolean getMultithreaded()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getMultithreaded()"));
+        }
+        return m_multiThreaded;
+    }
+
+    public void setIgnoreCache(boolean b)
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("setIgnoreCache(boolean)"));
+        }
+        m_ignoreCache = b;
+    }
+
+    public boolean getIgnoreCache()
+    {
+        if (isClosed())
+        {
+            throw new JDOFatalUserException(generateIsClosedErrorMessage("getIgnoreCache()"));
+        }
+        return m_ignoreCache;
+    }
+
+    /**
+     * TODO i18n these messages
+     *
+     * @param methodSignature
+     * @return
+     */
+    private static final String generateIsClosedErrorMessage(String methodSignature)
+    {
+        return "PersistenceManager already closed, cannot call '" + methodSignature + "'. Obtain a new PersistenceBroker and retry.";
+    }
+
+    private void handleLockingException(LockingException e)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    /**
+     * TODO i18n these messages
+     *
+     * @param methodSignature
+     * @param type
+     * @return
+     */
+    private static final String generateNullParameterErrorMessage(String methodSignature, String type)
+    {
+        return methodSignature + " was passed a null " + type + ".";
+    }
+
+    /**
+     * @todo what does this do?
+     * @see javax.jdo.PersistenceManager#retrieveAll(java.util.Collection, boolean)
+     */
+    public void retrieveAll(Collection arg0, boolean arg1)
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @todo what does this do?
+     * @see javax.jdo.PersistenceManager#retrieveAll(java.lang.Object[], boolean)
+     */
+    public void retrieveAll(Object[] arg0, boolean arg1)
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/QueryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/QueryImpl.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/QueryImpl.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/QueryImpl.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,387 @@
+package org.apache.ojb.jdo;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.jdo.Extent;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+
+import org.apache.ojb.jdo.jdoql.Expression;
+import org.apache.ojb.jdo.jdoql.LocalVariable;
+import org.apache.ojb.jdo.jdoql.QueryParsingHelper;
+import org.apache.ojb.jdo.jdoql.QueryTreeResolver;
+
+import java.util.*;
+
+/**
+ * Not Really Functional Yet:
+ * <p>
+ * Consider making this a front end for a State system where the
+ * compiled query is a different State The big list of args should/could
+ * be collected into something that knows how to compile and and
+ * apply the arguments passed at execute time.
+ * <p>
+ * Consider also, if do above, clone returns compiled query. Compiled
+ * probably needs to be able to uncompile itself if this the case,
+ * so continuing to return uncompiled may be best
+ *
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+
+public class QueryImpl implements Query
+{
+    /** The persistence manager this query is bound to */
+    private PersistenceManagerImpl _persistenceManager;
+    /** The searched class */
+    private Class _searchedClass;
+    /** Candidate instances */
+    private Collection _candidateInstances;
+    /** The original filter string */
+    private String _filterString;
+    /** The parsed filter expression */
+    private Expression _filterExpression;
+    /** The original imports string */
+    private String _importString;
+    /** The imports */
+    private Collection _imports;
+    /** The original parameter string */
+    private String _parameterString;
+    /** The parameters */
+    private Map _parameters;
+    /** The original variables string */
+    private String _variableString;
+    /** The variables */
+    private Map _variables;
+    /** The original ordering string */
+    private String _orderingString;
+    /** The orderings */
+    private Collection _orderings;
+    /** Whether to ignore the cache while processing this query */
+    private boolean _ignoreCache;
+    /** Whether this query must be resolved and compiled first */
+    private boolean _needsCompilation = true;
+
+    /**
+     * Creates a new query that uses the given persistence manager.
+     * 
+     * @param pm The persistence manager to use
+     */
+    public QueryImpl(PersistenceManagerImpl pm)
+    {
+        _persistenceManager = pm;
+        _candidateInstances = null;
+    }
+
+    /**
+     * Returns the persistence manager that this query uses.
+     * 
+     * @return The persistence manager
+     */
+    public PersistenceManager getPersistenceManager()
+    {
+        return _persistenceManager;
+    }
+
+    /**
+     * Sets the class whose objects this query searches for.
+     * 
+     * @param searchedClass The class of the searched objects
+     */
+    public void setClass(Class searchedClass)
+    {
+        _searchedClass    = searchedClass;
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the class of the searched objects.
+     * 
+     * @return The class of the searched objects
+     */
+    public Class getSearchedClass()
+    {
+        return _searchedClass;
+    }
+    
+    /**
+     * Simply ovewrites the setClass(..) value
+     */
+    public void setCandidates(Extent extent)
+    {
+        _searchedClass    = ((ExtentImpl)extent).ojbGetClass();
+        _needsCompilation = true;
+    }
+
+    public void setCandidates(Collection candidates)
+    {
+        _candidateInstances = candidates;
+        _needsCompilation   = true;
+    }
+
+    /**
+     * Sets the filter of this query.
+     * 
+     * @param filter The filter expression
+     */
+    public void setFilter(String filter) throws JDOUserException
+    {
+        _filterString     = filter;
+        _filterExpression = new QueryParsingHelper().parseFilter(filter);
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the filter expression.
+     * 
+     * @return The filter expression
+     */
+    public Expression getFilterExpression()
+    {
+        return _filterExpression;
+    }
+
+    /**
+     * Specifies the classes/packages imported by this query for use in the filter
+     * and ordering expressions.
+     * 
+     * @param imports The import declarations
+     */
+    public void declareImports(String imports) throws JDOUserException
+    {
+        _importString     = imports;
+        _imports          = new QueryParsingHelper().parseImports(imports);
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the imports of this query.
+     * 
+     * @return The imports, a collection of {@link org.apache.ojb.jdo.jdoql.Import} objects
+     */
+    public Collection getImports()
+    {
+        return _imports;
+    }
+
+    /**
+     * Sets the parameters of this query.
+     * 
+     * @param params The parameter declarations
+     */
+    public void declareParameters(String params) throws JDOUserException
+    {
+        _parameterString  = params;
+        _parameters       = new QueryParsingHelper().parseParameters(params);
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the parameters of this query.
+     * 
+     * @return The parameters, a map of {@link org.apache.ojb.jdo.jdoql.LocalVariable} objects
+     *         indexed by their names
+     */
+    public Map getParameters()
+    {
+        return _parameters;
+    }
+
+    /**
+     * Returns the parameter of the given name if it exists.
+     * 
+     * @param name The parameter name
+     * @return The parameter
+     */
+    public LocalVariable getParameter(String name)
+    {
+        return (LocalVariable)_variables.get(name);
+    }
+
+    /**
+     * Declares the variables used in the filter expression of this query.
+     * 
+     * @param variables The variable declarations
+     */
+    public void declareVariables(String variables) throws JDOUserException
+    {
+        _variableString   = variables;
+        _variables        = new QueryParsingHelper().parseVariables(variables);
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the variables of this query.
+     * 
+     * @return The variables, a map of {@link org.apache.ojb.jdo.jdoql.LocalVariable} objects
+     *         indexed by their names
+     */
+    public Map getVariables()
+    {
+        return _variables;
+    }
+
+    /**
+     * Returns the variable of the given name if it exists.
+     * 
+     * @param name The variable name
+     * @return The variable
+     */
+    public LocalVariable getVariable(String name)
+    {
+        return (LocalVariable)_variables.get(name);
+    }
+    
+    /**
+     * Defines the ordering of this query.
+     * 
+     * @param orderings The ordering specifications
+     */
+    public void setOrdering(String orderings) throws JDOUserException
+    {
+        _orderingString   = orderings;
+        _orderings        = new QueryParsingHelper().parseOrderings(orderings);
+        _needsCompilation = true;
+    }
+
+    /**
+     * Returns the orderings of this query.
+     * 
+     * @return The orderings, a collection of {@link org.apache.ojb.jdo.jdoql.Ordering} objects
+     */
+    public Collection getOrderings()
+    {
+        return _orderings;
+    }
+
+    /**
+     * Specifies whether the query should ignore any objects in the cache.
+     * 
+     * @param shouldIgnoreCache Whether to ignore the cache
+     */
+    public void setIgnoreCache(boolean shouldIgnoreCache)
+    {
+        _ignoreCache = shouldIgnoreCache;
+    }
+
+    /**
+     * Determines whether this query ignores objects in the cache.
+     * 
+     * @return <code>true</code> if this query ignores cached objects
+     */
+    public boolean getIgnoreCache()
+    {
+        return _ignoreCache;
+    }
+
+    /**
+     * Compiles the query. In effect this resolves the various expressions and
+     * declarations against each other, checks that they are valid, and enhances
+     * the filter and ordering expressions with executable ojb queries.
+     */
+    public void compile()
+    {
+        if (_needsCompilation)
+        {
+            // first we resolve this query 
+            new QueryTreeResolver().resolveAndCheck(this);
+            // TODO: next the filter and ordering expressions are enhanced with
+            //       actual database queries, e.g. like this:
+            // new QueryCompiler().compile(this);
+            //       which adds ojb queries to the filter expressions
+            //       (including the ordering) 
+            throw new UnsupportedOperationException("Not yet implemented");
+
+            // _needsCompilation = false;
+        }
+    }
+
+    /**
+     * Performs this query.
+     * 
+     * @return The query result
+     */
+    public Object execute()
+    {
+        if (_needsCompilation)
+        {
+            compile();
+        }
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    /**
+     * @todo implement
+     */
+    public Object execute(Object o)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    public Object execute(Object o, Object o1)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    public Object execute(Object o, Object o1, Object o2)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    public Object executeWithMap(Map map)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    public Object executeWithArray(Object[] objects)
+    {
+        throw new UnsupportedOperationException("Not yet implemented!");
+    }
+
+    /**
+     * @param o is a Collection returned from execute()
+     */
+    public void close(Object o)
+    {
+    }
+
+    public void closeAll()
+    {
+    }
+
+    /**
+     * Creates an uncompiled deep clone of this query.
+     * 
+     * @return The clone
+     */
+    QueryImpl ojbClone()
+    {
+        QueryImpl query = new QueryImpl(_persistenceManager);
+
+        query.setClass(_searchedClass);
+        query.setCandidates(_candidateInstances);
+        query.declareImports(_importString);
+        query.declareParameters(_parameterString);
+        query.declareVariables(_variableString);
+        query.setFilter(_filterString);
+        query.setOrdering(_orderingString);
+
+        return query;
+    }
+
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/TransactionImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/TransactionImpl.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/TransactionImpl.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/TransactionImpl.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,163 @@
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ojb.jdo;
+
+import org.apache.ojb.otm.OTMKit;
+import org.apache.ojb.otm.OTMConnection;
+
+import javax.jdo.Transaction;
+import javax.jdo.PersistenceManager;
+import javax.jdo.JDOUserException;
+import javax.jdo.JDOUnsupportedOptionException;
+import javax.transaction.Synchronization;
+
+/**
+ * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
+ * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
+ */
+
+public class TransactionImpl implements Transaction
+{
+	private PersistenceManager m_pm;
+    private OTMKit m_kit;
+    private OTMConnection m_conn;
+
+	public TransactionImpl(PersistenceManager pm, OTMKit kit, OTMConnection conn)
+	{
+		m_pm = pm;
+        m_conn = conn;
+        m_kit = kit;
+	}
+
+	public void begin()
+	{
+        if (m_kit.getTransaction(m_conn).isInProgress())
+        {
+            throw new JDOUserException("Transaction already in progress");
+        }
+        m_kit.getTransaction(m_conn).begin();
+	}
+
+	public void commit()
+	{
+        if (!m_kit.getTransaction(m_conn).isInProgress())
+        {
+            throw new JDOUserException("Transaction not in progress");
+        }
+        m_kit.getTransaction(m_conn).commit();
+	}
+
+	public void rollback()
+	{
+		if (!m_kit.getTransaction(m_conn).isInProgress())
+        {
+            throw new JDOUserException("Transaction not in progress");
+        }
+        m_kit.getTransaction(m_conn).rollback();
+	}
+
+	public boolean isActive()
+	{
+		return m_kit.getTransaction(m_conn).isInProgress();
+	}
+
+	public void setNontransactionalRead(boolean b)
+	{
+        throw new javax.jdo.JDOUnsupportedOptionException("Unsupported");
+	}
+
+	public boolean getNontransactionalRead()
+	{
+		return false;
+	}
+
+	public void setNontransactionalWrite(boolean b)
+	{
+        throw new javax.jdo.JDOUnsupportedOptionException("Unsupported");
+	}
+
+	public boolean getNontransactionalWrite()
+	{
+		return false;
+	}
+
+    /**
+     * @todo figure out what to do if someone doesn't want this!
+     */
+	public void setRetainValues(boolean b)
+	{
+        // umh, this is always true.
+	}
+
+	public boolean getRetainValues()
+	{
+		return true;
+	}
+
+    /**
+     * @todo implement
+     */
+	public void setRestoreValues(boolean b)
+	{
+        throw new JDOUnsupportedOptionException("Not Yet Implemented");
+	}
+
+    /**
+     * @todo implement
+     */
+	public boolean getRestoreValues()
+	{
+		return false;
+	}
+
+    /**
+     * @todo implement
+     */
+	public void setOptimistic(boolean b)
+	{
+        throw new JDOUnsupportedOptionException("Not yet implemented");
+	}
+
+    /**
+     * @todo implement
+     */
+	public boolean getOptimistic()
+	{
+		return false;
+	}
+
+    /**
+     * @todo figure out how to implement
+     * @param synchronization
+     */
+	public void setSynchronization(Synchronization synchronization)
+	{
+        throw new JDOUnsupportedOptionException("Not Yet Implemented");
+	}
+
+    /**
+     * @todo figure out how to implement
+     */
+	public Synchronization getSynchronization()
+	{
+		throw new JDOUnsupportedOptionException("Not Yet Implemented");
+	}
+
+	public PersistenceManager getPersistenceManager()
+	{
+		return m_pm;
+	}
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ASTWithPositionInfo.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ASTWithPositionInfo.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ASTWithPositionInfo.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/ASTWithPositionInfo.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,119 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import antlr.CommonAST;
+import antlr.Token;
+import antlr.collections.AST;
+
+/**
+ * An AST node that also contains position info (for error handling).
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public class ASTWithPositionInfo extends CommonAST
+{
+    /** The line where the source of this node started. */
+    private int _line   = 0;
+    /** The column where the source of this node started. */
+    private int _column = 0;
+
+    /**
+     * Creates a new node.
+     */
+    public ASTWithPositionInfo()
+    {
+        super();
+    }
+
+    /**
+     * Creates a new node for the given token.
+     * 
+     * @param tok The token
+     */
+    public ASTWithPositionInfo(Token tok)
+    {
+        super(tok);
+    }
+
+    /**
+     * Returns the column where the source of this node started.
+     * 
+     * @return The column
+     * @see antlr.collections.AST#getColumn()
+     */
+    public int getColumn()
+    {
+        return _column;
+    }
+
+    /**
+     * Returns the line where the source of this node started.
+     * 
+     * @return The line
+     * @see antlr.collections.AST#getLine()
+     */
+    public int getLine()
+    {
+        return _line;
+    }
+
+    /* (non-Javadoc)
+     * @see antlr.collections.AST#initialize(antlr.collections.AST)
+     */
+    public void initialize(AST ast)
+    {
+        super.initialize(ast);
+        _line   = ast.getLine();
+        _column = ast.getColumn();
+    }
+
+    /* (non-Javadoc)
+     * @see antlr.collections.AST#initialize(antlr.Token)
+     */
+    public void initialize(Token tok)
+    {
+        super.initialize(tok);
+        _line   = tok.getLine();
+        _column = tok.getColumn();
+    }
+
+    /* (non-Javadoc)
+     * @see antlr.collections.AST#addChild(antlr.collections.AST)
+     */
+    public void addChild(AST ast)
+    {
+        if ((ast != null) && (down == null) && (_line == 0) && (_column == 0))
+        {
+            _line   = ast.getLine();
+            _column = ast.getColumn();
+        }
+        super.addChild(ast);
+    }
+
+    /* (non-Javadoc)
+     * @see antlr.collections.AST#setFirstChild(antlr.collections.AST)
+     */
+    public void setFirstChild(AST ast)
+    {
+        if ((ast != null) && (_line == 0) && (_column == 0))
+        {
+            _line   = ast.getLine();
+            _column = ast.getColumn();
+        }
+        super.setFirstChild(ast);
+    }
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Acceptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Acceptor.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Acceptor.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Acceptor.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,26 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Denotes types that accept a visitor object.
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public interface Acceptor
+{
+    void accept(Visitor visitor);
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/BinaryExpression.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/BinaryExpression.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/BinaryExpression.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/BinaryExpression.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,201 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A binary expression (arithmetic or logical).
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public class BinaryExpression extends Expression
+{
+    public static final int OPERATOR_MULTIPLY        = 0;
+    public static final int OPERATOR_DIVIDE          = 1;
+    public static final int OPERATOR_PLUS            = 2;
+    public static final int OPERATOR_MINUS           = 3;
+    public static final int OPERATOR_LOWER           = 4;
+    public static final int OPERATOR_GREATER         = 5;
+    public static final int OPERATOR_LOWER_OR_EQUAL  = 6;
+    public static final int OPERATOR_GREATER_OR_EQUAL = 7;
+    public static final int OPERATOR_EQUAL           = 8;
+    public static final int OPERATOR_NOT_EQUAL       = 9;
+    public static final int OPERATOR_BITWISE_AND     = 10;
+    public static final int OPERATOR_BITWISE_XOR     = 11;
+    public static final int OPERATOR_BITWISE_OR      = 12;
+    public static final int OPERATOR_AND             = 13;
+    public static final int OPERATOR_OR              = 14;
+
+    /** The left side expression */
+    private Expression _left;
+    /** The binary operator (one of the above constants) */
+    private int        _operator;
+    /** The right side expression */
+    private Expression _right;
+    /** The type of this expression */
+    private Class      _type;
+
+    /**
+     * Creates a new binary expression object.
+     * 
+     * @param left     The left side of the expression
+     * @param operator The binary operator
+     * @param right    The right side of the expression
+     */
+    public BinaryExpression(Expression left, int operator, Expression right)
+    {
+        _left     = left;
+        _operator = operator;
+        _right    = right;
+    }
+
+    /**
+     * Returns the left side expression.
+     * 
+     * @return The left expression 
+     */
+    public Expression getLeftSide()
+    {
+        return _left;
+    }
+
+    /**
+     * Returns the operator.
+     * 
+     * @return The operator
+     */
+    public int getOperator()
+    {
+        return _operator;
+    }
+
+    /**
+     * Returns the right side expression.
+     * 
+     * @return The right expression 
+     */
+    public Expression getRightSide()
+    {
+        return _right;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Expression#replaceChild(org.apache.ojb.jdo.jdoql.Expression, org.apache.ojb.jdo.jdoql.Expression)
+     */
+    public void replaceChild(Expression oldChild, Expression newChild)
+    {
+        if (oldChild == _left)
+        {
+            _left.setParent(null);
+            _left = newChild;
+            _left.setParent(this);
+        }
+        else if (oldChild == _right)
+        {
+            _right.setParent(null);
+            _right = newChild;
+            _right.setParent(this);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
+     */
+    public void accept(Visitor visitor)
+    {
+        visitor.visit(this);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        StringBuffer result = new StringBuffer();
+
+        result.append("(");
+        result.append(_left.toString());
+        result.append(" ");
+        switch (_operator)
+        {
+            case OPERATOR_MULTIPLY :
+                result.append("* ");
+                break;
+            case OPERATOR_DIVIDE :
+                result.append("/ ");
+                break;
+            case OPERATOR_PLUS :
+                result.append("+ ");
+                break;
+            case OPERATOR_MINUS :
+                result.append("- ");
+                break;
+            case OPERATOR_LOWER :
+                result.append("< ");
+                break;
+            case OPERATOR_GREATER :
+                result.append("> ");
+                break;
+            case OPERATOR_LOWER_OR_EQUAL :
+                result.append("<= ");
+                break;
+            case OPERATOR_GREATER_OR_EQUAL :
+                result.append(">= ");
+                break;
+            case OPERATOR_EQUAL :
+                result.append("== ");
+                break;
+            case OPERATOR_NOT_EQUAL :
+                result.append("!= ");
+                break;
+            case OPERATOR_BITWISE_AND :
+                result.append("& ");
+                break;
+            case OPERATOR_BITWISE_XOR :
+                result.append("^ ");
+                break;
+            case OPERATOR_BITWISE_OR :
+                result.append("| ");
+                break;
+            case OPERATOR_AND :
+                result.append("&& ");
+                break;
+            case OPERATOR_OR :
+                result.append("|| ");
+                break;
+        }
+        result.append(_right.toString());
+        result.append(")");
+        return result.toString();
+    }
+
+    /**
+     * Sets the type of this binary expression.
+     * 
+     * @param type The type
+     */
+    public void setType(Class type)
+    {
+        _type = type;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Expression#getType()
+     */
+    public Class getType()
+    {
+        return _type;
+    }
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Expression.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Expression.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Expression.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Expression.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,80 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Common base class for all JDOQL expressions.
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public abstract class Expression extends QueryTreeNode
+{
+    /** The parent expression if any */
+    private Expression _parent;
+
+    /**
+     * Determines whether this expression has a parent expression
+     * (i.e. an expression where this expression is an inner or base expression).
+     * 
+     * @return <code>true</code> if this expression has a parent expression
+     */
+    public boolean hasParent()
+    {
+        return _parent != null;
+    }
+
+    /**
+     * Returns the parent expression of this expression if it exists.
+     * 
+     * @return The parent expression or <code>null</code> if this expression
+     *         has no parent
+     */
+    public Expression getParent()
+    {
+        return _parent;
+    }
+
+    /**
+     * Sets the parent expression of this expression. Note that this method
+     * does not remove this expression from the parent.
+     * 
+     * @param parent The new parent expression
+     */
+    public void setParent(Expression parent)
+    {
+        _parent = parent;
+    }
+
+    /**
+     * Replaces the given old child expression with the new one. This also sets this
+     * expression as the parent of the new child and removes it from the old child.
+     * 
+     * @param oldChild The old child to be replaced
+     * @param newChild The new child
+     */
+    public void replaceChild(Expression oldChild, Expression newChild)
+    {}
+
+    /**
+     * Returns the type of this expression. Note that in the case of primitives, 
+     * the type only declares the general kind, not the actual data type. For instance,
+     * a literal of type {@link Long} can be a <code>byte</code>, <code>short</code>,
+     * <code>int</code>, <code>long</code>, or {@link java.math.BigInteger} value.
+     * 
+     * @return The type
+     */
+    public abstract Class getType();
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/FieldAccess.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/FieldAccess.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/FieldAccess.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/FieldAccess.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,86 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.ojb.broker.metadata.*;
+
+/**
+ * A field access expression. Note that this expression type can only be
+ * present in a query tree after resolving it.
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public class FieldAccess extends NameExpression
+{
+    /** The descriptor for the accessed field, either a field or a reference descriptor */
+    private AttributeDescriptorBase _descriptor;
+
+    /**
+     * Creates a new field access object.
+     * 
+     * @param base The base expression (can be <code>null</code>)
+     * @param name The field's name
+     */
+    public FieldAccess(Expression base, String name)
+    {
+        super(base, name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
+     */
+    public void accept(Visitor visitor)
+    {
+        visitor.visit(this);
+    }
+
+    /**
+     * Sets the descriptor of the field accessed by this field access expression.
+     * Must be either a reference or a field descriptor.
+     *  
+     * @param descriptor The descriptor of the field
+     */
+    public void setFieldDescriptor(AttributeDescriptorBase descriptor)
+    {
+        _descriptor = descriptor;
+    }
+
+    /**
+     * Returns the descriptor of the field accessed by this field access expression.
+     * 
+     * @return The descriptor which is either a reference or field descriptor
+     */
+    public AttributeDescriptorBase getFieldDescriptor()
+    {
+        return _descriptor;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Expression#getType()
+     */
+    public Class getType()
+    {
+        if (_descriptor instanceof FieldDescriptor)
+        {
+            return ((FieldDescriptor)_descriptor).getPersistentField().getType();
+        }
+        else
+        {
+            // this also covers collections
+            return ((ObjectReferenceDescriptor)_descriptor).getItemClass();
+        }
+    }
+}

Added: db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Import.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Import.java?rev=430936&view=auto
==============================================================================
--- db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Import.java (added)
+++ db/ojb/trunk/proposals/jdo/java/org/apache/ojb/jdo/jdoql/Import.java Fri Aug 11 18:17:46 2006
@@ -0,0 +1,80 @@
+package org.apache.ojb.jdo.jdoql;
+
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a direct or on-demand import within a JDOQL query.
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ */
+public class Import extends QueryTreeNode
+{
+    /** The import spec, either a fully qualified class name or a qualified package name */
+    private String _spec;
+    /** Whether this import is direct (class) or on-demand (package) */
+    private boolean _isOnDemand;
+    /** If an direct import, this is the resolved class */
+    private Class   _importedClass;
+
+    /**
+     * Creates a new import object.
+     * 
+     * @param spec       The import spec
+     * @param isOnDemand Whether the import is on-demand or direct
+     */
+    public Import(String spec, boolean isOnDemand)
+    {
+        _spec       = spec;
+        _isOnDemand = isOnDemand;
+    }
+
+    /**
+     * Returns whether this import is direct (class) or on-demand (package).
+     * 
+     * @return <code>true</code> if this import is on-demand
+     */
+    public boolean isOnDemand()
+    {
+        return _isOnDemand;
+    }
+
+    /**
+     * Returns the import spec which is either a fully qualified class name or
+     * a package.
+     * 
+     * @return The spec
+     */
+    public String getSpec()
+    {
+        return _spec;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
+     */
+    public void accept(Visitor visitor)
+    {
+        visitor.visit(this);
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return _isOnDemand ? _spec + ".*" : _spec;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message