Author: scamp
Date: Mon Jan 24 07:12:19 2005
New Revision: 126289

URL: http://svn.apache.org/viewcvs?view=rev&rev=126289
Log:
added
Added:
   
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansQueryExpression.java
   
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/topicexpression/

Added: 
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansQueryExpression.java
Url: 
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansQueryExpression.java?view=auto&rev=126289
==============================================================================
--- (empty file)
+++ 
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansQueryExpression.java
   Mon Jan 24 07:12:19 2005
@@ -0,0 +1,90 @@
+package org.apache.ws.notification.base.impl;

+

+import org.apache.ws.resource.properties.query.QueryExpression;

+import org.apache.ws.resource.i18n.MessagesImpl;

+import org.apache.ws.resource.i18n.Keys;

+import org.apache.ws.XmlObjectFacade;

+import org.apache.ws.util.i18n.Messages;

+import org.apache.ws.util.XmlBeanUtils;

+import org.apache.xmlbeans.XmlObject;

+import org.apache.xmlbeans.XmlOptions;

+import org.apache.commons.logging.Log;

+import org.apache.commons.logging.LogFactory;

+import org.w3c.dom.Node;

+import org.w3c.dom.DocumentFragment;

+import org.w3c.dom.Text;

+import 
org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionType;

+

+import javax.xml.rpc.JAXRPCException;

+import javax.naming.directory.SchemaViolationException;

+import java.net.URI;

+

+

+/**

+ * This is primarily the same as XmlBeansTopicExpression and this type should 
probably live in Apollo since

+ * it is defined in the WS-RP spec.

+ *

+ *

+ * @author Sal Campana

+ */

+public class XmlBeansQueryExpression implements QueryExpression, 
XmlObjectFacade

+{

+    private static final Log LOG = LogFactory.getLog( 
XmlBeansQueryExpression.class );

+    public static final Messages MSG = MessagesImpl.getInstance();

+    private URI m_dialect;

+    private Node m_content;

+    private QueryExpressionType m_queryExprXBean;

+

+    public XmlBeansQueryExpression(QueryExpressionType queryExprXBean) throws 
SchemaViolationException

+    {

+        m_queryExprXBean = queryExprXBean;

+        try

+        {

+            m_dialect = new URI( queryExprXBean.getDialect() );

+        }

+        catch ( Exception e )

+        {

+            throw new JAXRPCException( MSG.getMessage( 
Keys.FAILED_INIT_DIALECT, e ) );

+        }

+

+         XmlObject[] childElems = XmlBeanUtils.getChildElements( 
queryExprXBean );

+        if ( childElems.length > 1 )

+        {

+            throw new SchemaViolationException( MSG.getMessage( 
Keys.QUERY_ONLY_ONE_NODE ) );

+        }

+

+        if ( childElems.length == 1 )

+        {

+            m_content = ( (DocumentFragment) childElems[0].newDomNode() 
).getFirstChild();

+        }

+        else

+        {

+            Node queryExprNode = ( (DocumentFragment) 
queryExprXBean.newDomNode( new XmlOptions().setSaveOuter() ) ).getFirstChild();

+            m_content = queryExprNode.getFirstChild();

+            if ( ( m_content == null ) || !( m_content instanceof Text ) )

+            {

+                throw new SchemaViolationException( MSG.getMessage( 
Keys.QUERY_MUST_HAVE_ELEM_OR_TXT ) );

+            }

+        }

+        if ( LOG.isDebugEnabled() )

+        {

+            LOG.debug( MSG.getMessage( Keys.QUERY_EXPR, toString() ) );

+        }

+

+    }

+

+    public Node getContent()

+    {

+        return m_content;

+    }

+

+    public URI getDialect()

+    {

+        return m_dialect;

+    }

+

+    public XmlObject getXmlObject()

+    {

+        return m_queryExprXBean;

+    }

+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to