You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by df...@apache.org on 2021/04/09 20:12:20 UTC
[activemq-nms-msmq] 04/05: Apply patch for AMQNET-556 from Stephane
Ramet. Thanks Stephane!
This is an automated email from the ASF dual-hosted git repository.
dfoulks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-nms-msmq.git
commit 7274a80a76cb827785d576f57f413b02f60ae83c
Author: Jim Gomes <jg...@apache.org>
AuthorDate: Sat Sep 10 23:09:20 2016 +0000
Apply patch for AMQNET-556 from Stephane Ramet. Thanks Stephane!
---
Apache.NMS.MSMQ.Test.nunit | 12 +-
msmqprovider-test.config | 35 +
nant.build | 7 +-
src/main/csharp/Connection.cs | 257 ++-
src/main/csharp/ConnectionMetaData.cs | 214 +-
src/main/csharp/DefaultMessageConverter.cs | 31 +-
src/main/csharp/IMessageConverterEx.cs | 88 +-
src/main/csharp/MessageConsumer.cs | 191 +-
src/main/csharp/MessageProducer.cs | 73 +-
src/main/csharp/Queue.cs | 73 +-
src/main/csharp/QueueBrowser.cs | 336 +--
src/main/csharp/Readers/AbstractMessageReader.cs | 252 +--
.../csharp/Readers/ByCorrelationIdMessageReader.cs | 278 +--
src/main/csharp/Readers/ByIdMessageReader.cs | 272 +--
src/main/csharp/Readers/ByLookupIdMessageReader.cs | 360 +--
src/main/csharp/Readers/BySelectorMessageReader.cs | 576 +++--
src/main/csharp/Readers/IMessageReader.cs | 186 +-
src/main/csharp/Readers/MessageReaderUtil.cs | 182 +-
.../csharp/Readers/NonFilteringMessageReader.cs | 256 +--
src/main/csharp/Selector/ANDExpression.cs | 93 +-
src/main/csharp/Selector/AlignedNumericValues.cs | 349 ++-
src/main/csharp/Selector/ArithmeticExpression.cs | 113 +-
src/main/csharp/Selector/BinaryExpression.cs | 117 +-
src/main/csharp/Selector/BooleanCastExpression.cs | 89 +-
.../csharp/Selector/BooleanConstantExpression.cs | 73 +-
src/main/csharp/Selector/BooleanUnaryExpression.cs | 77 +-
src/main/csharp/Selector/ComparisonExpression.cs | 323 ++-
src/main/csharp/Selector/ConstantExpression.cs | 311 ++-
src/main/csharp/Selector/DivideExpression.cs | 133 +-
src/main/csharp/Selector/EqualExpression.cs | 93 +-
src/main/csharp/Selector/GreaterExpression.cs | 83 +-
.../csharp/Selector/GreaterOrEqualExpression.cs | 85 +-
src/main/csharp/Selector/IBooleanExpression.cs | 69 +-
src/main/csharp/Selector/IExpression.cs | 67 +-
src/main/csharp/Selector/InExpression.cs | 195 +-
src/main/csharp/Selector/IsNullExpression.cs | 117 +-
src/main/csharp/Selector/LesserExpression.cs | 83 +-
.../csharp/Selector/LesserOrEqualExpression.cs | 85 +-
src/main/csharp/Selector/LikeExpression.cs | 247 +--
src/main/csharp/Selector/LogicExpression.cs | 95 +-
.../csharp/Selector/MessageEvaluationContext.cs | 153 +-
src/main/csharp/Selector/MinusExpression.cs | 133 +-
src/main/csharp/Selector/ModExpression.cs | 133 +-
src/main/csharp/Selector/MultiplyExpression.cs | 133 +-
src/main/csharp/Selector/NOTExpression.cs | 89 +-
src/main/csharp/Selector/NegateExpression.cs | 101 +-
src/main/csharp/Selector/ORExpression.cs | 91 +-
src/main/csharp/Selector/ParseException.cs | 394 ++--
src/main/csharp/Selector/PlusExpression.cs | 135 +-
src/main/csharp/Selector/PropertyExpression.cs | 105 +-
src/main/csharp/Selector/SelectorParser.cs | 2341 ++++++++++----------
src/main/csharp/Selector/SelectorParser.csc | 23 +-
.../csharp/Selector/SelectorParserConstants.cs | 150 +-
.../csharp/Selector/SelectorParserTokenManager.cs | 2053 +++++++++--------
src/main/csharp/Selector/SimpleCharStream.cs | 732 +++---
src/main/csharp/Selector/Token.cs | 156 +-
src/main/csharp/Selector/TokenMgrError.cs | 260 +--
src/main/csharp/Selector/UnaryExpression.cs | 131 +-
src/main/csharp/Session.cs | 20 +-
src/test/csharp/AsyncConsumeTest.cs | 228 ++
src/test/csharp/BadConsumeTest.cs | 69 +
src/test/csharp/BytesMessageTest.cs | 138 ++
src/test/csharp/Commands/BytesMessage.cs | 511 +++++
src/test/csharp/Commands/Destination.cs | 380 ++++
src/test/csharp/Commands/MapMessage.cs | 90 +
src/test/csharp/Commands/Message.cs | 329 +++
src/test/csharp/Commands/ObjectMessage.cs | 44 +
src/test/csharp/Commands/Queue.cs | 75 +
src/test/csharp/Commands/StreamMessage.cs | 901 ++++++++
src/test/csharp/Commands/TempDestination.cs | 70 +
src/test/csharp/Commands/TempQueue.cs | 81 +
src/test/csharp/Commands/TempTopic.cs | 77 +
src/test/csharp/Commands/TextMessage.cs | 70 +
src/test/csharp/Commands/Topic.cs | 74 +
src/test/csharp/ConnectionTest.cs | 194 ++
src/test/csharp/ConsumerTest.cs | 596 +++++
src/test/csharp/DurableTest.cs | 267 +++
src/test/csharp/EndianBinaryReaderTest.cs | 162 ++
src/test/csharp/EndianBinaryWriterTest.cs | 202 ++
src/test/csharp/EndianTest.cs | 131 ++
.../csharp/ForeignMessageTransformationTest.cs | 315 +++
src/test/csharp/MSMQAsyncConsumeTest.cs | 107 +
.../Queue.cs => test/csharp/MSMQBadConsumeTest.cs} | 44 +-
.../csharp/MSMQBytesMessageTest.cs} | 53 +-
src/test/csharp/MSMQConnectionTest.cs | 107 +
src/test/csharp/MSMQConsumerTest.cs | 154 ++
src/test/csharp/MSMQDurableTest.cs | 72 +
.../csharp/MSMQForeignMessageTransformationTest.cs | 86 +
src/test/csharp/MSMQMapMessageTest.cs | 49 +
src/test/csharp/MSMQMessageSelectorTest.cs | 169 ++
.../Queue.cs => test/csharp/MSMQMessageTest.cs} | 44 +-
.../csharp/MSMQMessageTransformerTest.cs} | 50 +-
.../csharp/MSMQNMSPropertyTest.cs} | 45 +-
src/test/csharp/MSMQProducerTest.cs | 65 +
.../csharp/MSMQRequestResponseTest.cs} | 44 +-
.../csharp/MSMQStreamMessageTest.cs} | 45 +-
src/test/csharp/MSMQTempDestinationDeletionTest.cs | 48 +
src/test/csharp/MSMQTempDestinationTest.cs | 68 +
.../Queue.cs => test/csharp/MSMQTestSupport.cs} | 52 +-
.../csharp/MSMQTextMessageTest.cs} | 45 +-
src/test/csharp/MSMQTransactionTest.cs | 115 +
.../Queue.cs => test/csharp/MSMQXmlMessageTest.cs} | 44 +-
src/test/csharp/MapMessageTest.cs | 208 ++
src/test/csharp/MessageSelectorTest.cs | 221 ++
src/test/csharp/MessageTest.cs | 147 ++
src/test/csharp/MessageTransformerTest.cs | 124 ++
src/test/csharp/NMSPropertyTest.cs | 82 +
src/test/csharp/NMSTest.cs | 505 +++++
src/test/csharp/NMSTestSupport.cs | 637 ++++++
src/test/csharp/NMSTracer.cs | 87 +
src/test/csharp/PrimitiveMapTest.cs | 170 ++
src/test/csharp/ProducerTest.cs | 113 +
src/test/csharp/RedeliveryPolicyTest.cs | 135 ++
src/test/csharp/RequestResponseTest.cs | 74 +
src/test/csharp/StreamMessageTest.cs | 111 +
src/test/csharp/TempDestinationDeletionTest.cs | 80 +
src/test/csharp/TempDestinationTest.cs | 175 ++
src/test/csharp/TextMessageTest.cs | 71 +
src/test/csharp/TransactionTest.cs | 439 ++++
src/test/csharp/XmlMessageTest.cs | 186 ++
vs2008-msmq-test.csproj | 65 +-
vs2008-msmq.csproj | 3 +-
vs2008-msmq.sln | 60 +-
123 files changed, 17001 insertions(+), 7111 deletions(-)
diff --git a/Apache.NMS.MSMQ.Test.nunit b/Apache.NMS.MSMQ.Test.nunit
index b321b9d..4dc9dc2 100644
--- a/Apache.NMS.MSMQ.Test.nunit
+++ b/Apache.NMS.MSMQ.Test.nunit
@@ -1,7 +1,7 @@
-<NUnitProject>
- <Settings activeconfig="Default" />
- <Config name="Default" binpathtype="Auto">
- <assembly path="Apache.NMS.Test.dll" />
- <assembly path="Apache.NMS.MSMQ.Test.dll" />
- </Config>
+<NUnitProject>
+ <Settings activeconfig="Default" />
+ <Config name="Default" binpathtype="Auto">
+ <!--<assembly path="Apache.NMS.Test.dll" />-->
+ <assembly path="Apache.NMS.MSMQ.Test.dll" />
+ </Config>
</NUnitProject>
\ No newline at end of file
diff --git a/msmqprovider-test.config b/msmqprovider-test.config
new file mode 100644
index 0000000..65e5dff
--- /dev/null
+++ b/msmqprovider-test.config
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+-->
+<configuration>
+ <testURI value="msmq://localhost">
+ <userName value="guest"/>
+ <passWord value="guest"/>
+ <defaultTestQueue value="queue://.\Private$\TestQ"/>
+ <defaultTestTopic value=""/>
+ <defaultTestQueue2 value="queue://.\Private$\TestQ2"/>
+ <defaultTestTopic2 value=""/>
+ <durableConsumerTestTopic value=""/>
+ <messageSelectorTestQueue value="queue://.\Private$\TestQ"/>
+ <messageSelectorTestTopic value=""/>
+ <deletionTestQueue value="queue://.\Private$\TestQ"/>
+ <deletionTestTopic value=""/>
+ <deletionTestTempQueue value=""/>
+ <deletionTestTempTopic value=""/>
+ <transactionTestQueue value="queue://.\Private$\TestQT"/>
+ </testURI>
+</configuration>
diff --git a/nant.build b/nant.build
index 0df9a29..67d0fa0 100644
--- a/nant.build
+++ b/nant.build
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -31,8 +31,6 @@
<property name="nunit.dll" value="${basedir}/lib/NUnit/${current.build.framework}/nunit.framework.dll" dynamic="true" />
<property name="Apache.NMS.dll" value="${basedir}/lib/Apache.NMS/${current.build.framework}/Apache.NMS.dll" dynamic="true" />
<property name="Apache.NMS.pdb" value="${basedir}/lib/Apache.NMS/${current.build.framework}/Apache.NMS.pdb" dynamic="true" />
- <property name="Apache.NMS.Test.dll" value="${basedir}/lib/Apache.NMS/${current.build.framework}//Apache.NMS.Test.dll" dynamic="true" />
- <property name="Apache.NMS.Test.pdb" value="${basedir}/lib/Apache.NMS/${current.build.framework}/Apache.NMS.Test.pdb" dynamic="true" />
<property name="NUnit.Projectfile" value="Apache.NMS.MSMQ.Test.nunit" />
<!-- Skip certain frameworks, since MSMQ is not supported on those platforms. -->
@@ -77,7 +75,6 @@
<include name="${current.build.framework.assembly.dir}/System.Xml.dll" />
<include name="${current.build.framework.assembly.dir}/System.Messaging.dll" />
<include name="${Apache.NMS.dll}" />
- <include name="${Apache.NMS.Test.dll}" />
<include name="${build.bin.dir}/${project.name}.dll" />
<include name="${nunit.dll}" />
</assemblyfileset>
@@ -88,8 +85,6 @@
<include name="nmsprovider-*.config" />
<include name="${Apache.NMS.dll}" />
<include name="${Apache.NMS.pdb}" />
- <include name="${Apache.NMS.Test.dll}" />
- <include name="${Apache.NMS.Test.pdb}" />
<include name="${nunit.dll}" />
<include name="${NUnit.Projectfile}" />
</fileset>
diff --git a/src/main/csharp/Connection.cs b/src/main/csharp/Connection.cs
index 9207708..5df73f4 100644
--- a/src/main/csharp/Connection.cs
+++ b/src/main/csharp/Connection.cs
@@ -16,6 +16,7 @@
*/
using System;
+using System.Threading;
namespace Apache.NMS.MSMQ
{
@@ -26,21 +27,101 @@ namespace Apache.NMS.MSMQ
///
public class Connection : IConnection
{
- private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
- private IMessageConverter messageConverter = new DefaultMessageConverter();
+ #region Constructors
- private IRedeliveryPolicy redeliveryPolicy;
- private ConnectionMetaData metaData = null;
- private bool connected;
- private bool closed;
- private string clientId;
+ public Connection()
+ {
+ // now lets send the connection and see if we get an ack/nak
+ // TODO: establish a connection
+ }
+
+ #endregion
+
+ #region Connection state
+
+ public enum ConnectionState
+ {
+ Created,
+ Connected,
+ Starting,
+ Started,
+ Stopping,
+ Stopped,
+ Closed
+ }
+
+ private ConnectionState state = ConnectionState.Created;
+
+ public class StateChangeEventArgs : EventArgs
+ {
+ public StateChangeEventArgs(ConnectionState originalState,
+ ConnectionState currentState)
+ {
+ this.originalState = originalState;
+ this.currentState = currentState;
+ }
+
+ private ConnectionState originalState;
+ public ConnectionState OriginalState
+ {
+ get { return originalState; }
+ }
+
+ private ConnectionState currentState;
+ public ConnectionState CurrentState
+ {
+ get { return currentState; }
+ }
+ }
+
+ public delegate void StateChangeEventHandler(object sender, StateChangeEventArgs e);
+
+ public event StateChangeEventHandler ConnectionStateChange;
+
+ private void ChangeState(ConnectionState newState)
+ {
+ if(ConnectionStateChange != null)
+ {
+ ConnectionStateChange(this,
+ new StateChangeEventArgs(this.state, newState));
+ }
+
+ this.state = newState;
+ }
+
+ private object stateLock = new object();
+
+ #endregion
+
+ #region Start & stop
/// <summary>
/// Starts message delivery for this connection.
/// </summary>
public void Start()
{
- CheckConnected();
+ lock(stateLock)
+ {
+ switch(state)
+ {
+ case ConnectionState.Created:
+ case ConnectionState.Connected:
+ case ConnectionState.Stopped:
+ ChangeState(ConnectionState.Starting);
+ ChangeState(ConnectionState.Started);
+ break;
+
+ case ConnectionState.Stopping:
+ throw new NMSException("Connection stopping");
+
+ case ConnectionState.Closed:
+ throw new NMSException("Connection closed");
+
+ case ConnectionState.Starting:
+ case ConnectionState.Started:
+ break;
+ }
+ }
}
/// <summary>
@@ -49,7 +130,7 @@ namespace Apache.NMS.MSMQ
/// </summary>
public bool IsStarted
{
- get { return true; }
+ get { return state == ConnectionState.Started; }
}
/// <summary>
@@ -57,9 +138,65 @@ namespace Apache.NMS.MSMQ
/// </summary>
public void Stop()
{
- CheckConnected();
+ lock(stateLock)
+ {
+ switch(state)
+ {
+ case ConnectionState.Started:
+ ChangeState(ConnectionState.Stopping);
+ ChangeState(ConnectionState.Stopped);
+ break;
+
+ case ConnectionState.Starting:
+ throw new NMSException("Connection starting");
+
+ case ConnectionState.Closed:
+ throw new NMSException("Connection closed");
+
+ case ConnectionState.Created:
+ case ConnectionState.Connected:
+ case ConnectionState.Stopping:
+ case ConnectionState.Stopped:
+ break;
+ }
+ }
+ }
+
+ #endregion
+
+ #region Close & dispose
+
+ public void Close()
+ {
+ if(!IsClosed)
+ {
+ Stop();
+
+ state = ConnectionState.Closed;
+ }
+ }
+
+ public bool IsClosed
+ {
+ get { return state == ConnectionState.Closed; }
+ }
+
+ public void Dispose()
+ {
+ try
+ {
+ Close();
+ }
+ catch
+ {
+ state = ConnectionState.Closed;
+ }
}
+ #endregion
+
+ #region Create session
+
/// <summary>
/// Creates a new session to work on this connection
/// </summary>
@@ -73,14 +210,16 @@ namespace Apache.NMS.MSMQ
/// </summary>
public ISession CreateSession(AcknowledgementMode mode)
{
- CheckConnected();
+ if(IsClosed)
+ {
+ throw new NMSException("Connection closed");
+ }
return new Session(this, mode);
}
- public void Dispose()
- {
- closed = true;
- }
+ #endregion
+
+ #region Connection properties
/// <summary>
/// The default timeout for network requests.
@@ -91,24 +230,27 @@ namespace Apache.NMS.MSMQ
set { }
}
+ private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
public AcknowledgementMode AcknowledgementMode
{
get { return acknowledgementMode; }
set { acknowledgementMode = value; }
}
+ private IMessageConverter messageConverter = new DefaultMessageConverter();
public IMessageConverter MessageConverter
{
get { return messageConverter; }
set { messageConverter = value; }
}
+ private string clientId;
public string ClientId
{
get { return clientId; }
set
{
- if(connected)
+ if(state != ConnectionState.Created)
{
throw new NMSException("You cannot change the ClientId once the Connection is connected");
}
@@ -116,6 +258,7 @@ namespace Apache.NMS.MSMQ
}
}
+ private IRedeliveryPolicy redeliveryPolicy;
/// <summary>
/// Get/or set the redelivery policy for this connection.
/// </summary>
@@ -125,6 +268,19 @@ namespace Apache.NMS.MSMQ
set { this.redeliveryPolicy = value; }
}
+ private ConnectionMetaData metaData = null;
+ /// <summary>
+ /// Gets the Meta Data for the NMS Connection instance.
+ /// </summary>
+ public IConnectionMetaData MetaData
+ {
+ get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
+ }
+
+ #endregion
+
+ #region Transformer delegates
+
private ConsumerTransformerDelegate consumerTransformer;
public ConsumerTransformerDelegate ConsumerTransformer
{
@@ -139,57 +295,18 @@ namespace Apache.NMS.MSMQ
set { this.producerTransformer = value; }
}
- /// <summary>
- /// Gets the Meta Data for the NMS Connection instance.
- /// </summary>
- public IConnectionMetaData MetaData
- {
- get { return this.metaData ?? (this.metaData = new ConnectionMetaData()); }
- }
+ #endregion
+
+ #region Exception & transport listeners
/// <summary>
/// A delegate that can receive transport level exceptions.
/// </summary>
public event ExceptionListener ExceptionListener;
- /// <summary>
- /// An asynchronous listener that is notified when a Fault tolerant connection
- /// has been interrupted.
- /// </summary>
- public event ConnectionInterruptedListener ConnectionInterruptedListener;
-
- /// <summary>
- /// An asynchronous listener that is notified when a Fault tolerant connection
- /// has been resumed.
- /// </summary>
- public event ConnectionResumedListener ConnectionResumedListener;
-
- protected void CheckConnected()
- {
- if(closed)
- {
- throw new NMSException("Connection Closed");
- }
- if(!connected)
- {
- connected = true;
- // now lets send the connection and see if we get an ack/nak
- // TODO: establish a connection
- }
- }
-
- public void Close()
- {
- Dispose();
- }
-
- public void PurgeTempDestinations()
- {
- }
-
public void HandleException(Exception e)
{
- if(ExceptionListener != null && !this.closed)
+ if(ExceptionListener != null && !this.IsClosed)
{
ExceptionListener(e);
}
@@ -199,11 +316,17 @@ namespace Apache.NMS.MSMQ
}
}
+ /// <summary>
+ /// An asynchronous listener that is notified when a Fault tolerant connection
+ /// has been interrupted.
+ /// </summary>
+ public event ConnectionInterruptedListener ConnectionInterruptedListener;
+
public void HandleTransportInterrupted()
{
Tracer.Debug("Transport has been Interrupted.");
- if(this.ConnectionInterruptedListener != null && !this.closed)
+ if(this.ConnectionInterruptedListener != null && !this.IsClosed)
{
try
{
@@ -215,11 +338,17 @@ namespace Apache.NMS.MSMQ
}
}
+ /// <summary>
+ /// An asynchronous listener that is notified when a Fault tolerant connection
+ /// has been resumed.
+ /// </summary>
+ public event ConnectionResumedListener ConnectionResumedListener;
+
public void HandleTransportResumed()
{
Tracer.Debug("Transport has resumed normal operation.");
- if(this.ConnectionResumedListener != null && !this.closed)
+ if(this.ConnectionResumedListener != null && !this.IsClosed)
{
try
{
@@ -230,5 +359,11 @@ namespace Apache.NMS.MSMQ
}
}
}
+
+ #endregion
+
+ public void PurgeTempDestinations()
+ {
+ }
}
}
diff --git a/src/main/csharp/ConnectionMetaData.cs b/src/main/csharp/ConnectionMetaData.cs
index 5a305c0..9bba3b6 100644
--- a/src/main/csharp/ConnectionMetaData.cs
+++ b/src/main/csharp/ConnectionMetaData.cs
@@ -1,107 +1,107 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-using System;
-using System.Reflection;
-
-namespace Apache.NMS.MSMQ
-{
- /// <summary>
- /// Implements the Connection Meta-Data feature for Apache.NMS.MSMQ
- /// </summary>
- public class ConnectionMetaData : IConnectionMetaData
- {
- private int nmsMajorVersion;
- private int nmsMinorVersion;
-
- private string nmsProviderName;
- private string nmsVersion;
-
- private int providerMajorVersion;
- private int providerMinorVersion;
- private string providerVersion;
-
- private string[] nmsxProperties;
-
- public ConnectionMetaData()
- {
- Assembly self = Assembly.GetExecutingAssembly();
- AssemblyName asmName = self.GetName();
-
- this.nmsProviderName = asmName.Name;
- this.providerMajorVersion = asmName.Version.Major;
- this.providerMinorVersion = asmName.Version.Minor;
- this.providerVersion = asmName.Version.ToString();
-
- this.nmsxProperties = new String[] { };
-
- foreach(AssemblyName name in self.GetReferencedAssemblies())
- {
- if(0 == string.Compare(name.Name, "Apache.NMS", true))
- {
- this.nmsMajorVersion = name.Version.Major;
- this.nmsMinorVersion = name.Version.Minor;
- this.nmsVersion = name.Version.ToString();
-
- return;
- }
- }
-
- throw new NMSException("Could not find a reference to the Apache.NMS Assembly.");
- }
-
- public int NMSMajorVersion
- {
- get { return this.nmsMajorVersion; }
- }
-
- public int NMSMinorVersion
- {
- get { return this.nmsMinorVersion; }
- }
-
- public string NMSProviderName
- {
- get { return this.nmsProviderName; }
- }
-
- public string NMSVersion
- {
- get { return this.nmsVersion; }
- }
-
- public string[] NMSXPropertyNames
- {
- get { return this.nmsxProperties; }
- }
-
- public int ProviderMajorVersion
- {
- get { return this.providerMajorVersion; }
- }
-
- public int ProviderMinorVersion
- {
- get { return this.providerMinorVersion; }
- }
-
- public string ProviderVersion
- {
- get { return this.providerVersion; }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+using System;
+using System.Reflection;
+
+namespace Apache.NMS.MSMQ
+{
+ /// <summary>
+ /// Implements the Connection Meta-Data feature for Apache.NMS.MSMQ
+ /// </summary>
+ public class ConnectionMetaData : IConnectionMetaData
+ {
+ private int nmsMajorVersion;
+ private int nmsMinorVersion;
+
+ private string nmsProviderName;
+ private string nmsVersion;
+
+ private int providerMajorVersion;
+ private int providerMinorVersion;
+ private string providerVersion;
+
+ private string[] nmsxProperties;
+
+ public ConnectionMetaData()
+ {
+ Assembly self = Assembly.GetExecutingAssembly();
+ AssemblyName asmName = self.GetName();
+
+ this.nmsProviderName = asmName.Name;
+ this.providerMajorVersion = asmName.Version.Major;
+ this.providerMinorVersion = asmName.Version.Minor;
+ this.providerVersion = asmName.Version.ToString();
+
+ this.nmsxProperties = new String[] { };
+
+ foreach(AssemblyName name in self.GetReferencedAssemblies())
+ {
+ if(0 == string.Compare(name.Name, "Apache.NMS", true))
+ {
+ this.nmsMajorVersion = name.Version.Major;
+ this.nmsMinorVersion = name.Version.Minor;
+ this.nmsVersion = name.Version.ToString();
+
+ return;
+ }
+ }
+
+ throw new NMSException("Could not find a reference to the Apache.NMS Assembly.");
+ }
+
+ public int NMSMajorVersion
+ {
+ get { return this.nmsMajorVersion; }
+ }
+
+ public int NMSMinorVersion
+ {
+ get { return this.nmsMinorVersion; }
+ }
+
+ public string NMSProviderName
+ {
+ get { return this.nmsProviderName; }
+ }
+
+ public string NMSVersion
+ {
+ get { return this.nmsVersion; }
+ }
+
+ public string[] NMSXPropertyNames
+ {
+ get { return this.nmsxProperties; }
+ }
+
+ public int ProviderMajorVersion
+ {
+ get { return this.providerMajorVersion; }
+ }
+
+ public int ProviderMinorVersion
+ {
+ get { return this.providerMinorVersion; }
+ }
+
+ public string ProviderVersion
+ {
+ get { return this.providerVersion; }
+ }
+ }
+}
diff --git a/src/main/csharp/DefaultMessageConverter.cs b/src/main/csharp/DefaultMessageConverter.cs
index 83097fc..b726474 100644
--- a/src/main/csharp/DefaultMessageConverter.cs
+++ b/src/main/csharp/DefaultMessageConverter.cs
@@ -118,16 +118,16 @@ namespace Apache.NMS.MSMQ
// Populate property data
foreach(object keyObject in message.Properties.Keys)
{
- string key = (keyObject as string);
- object val = message.Properties.GetString(key);
- if(!SetLabelAsNMSType && string.Compare(key, "Label", true) == 0 && val != null)
- {
- msmqMessage.Label = val.ToString();
- }
- else
- {
- propertyData[key] = val;
- }
+ string key = (keyObject as string);
+ object val = message.Properties[key];
+ if(!SetLabelAsNMSType && string.Compare(key, "Label", true) == 0 && val != null)
+ {
+ msmqMessage.Label = val.ToString();
+ }
+ else
+ {
+ propertyData[key] = val;
+ }
}
// Store the NMS property data in the extension area
@@ -418,6 +418,8 @@ namespace Apache.NMS.MSMQ
result = baseMessage;
}
+ result.ReadOnlyBody = true;
+
return result;
}
@@ -442,6 +444,7 @@ namespace Apache.NMS.MSMQ
else if(message is BytesMessage)
{
BytesMessage bytesMessage = message as BytesMessage;
+ bytesMessage.Reset();
answer.BodyStream.Write(bytesMessage.Content, 0, bytesMessage.Content.Length);
answer.AppSpecific = (int) NMSMessageType.BytesMessage;
}
@@ -604,12 +607,14 @@ namespace Apache.NMS.MSMQ
/// <result>MSMQ queue.</result>
public MessageQueue ToMsmqDestination(IDestination destination)
{
- if(null == destination)
+ Queue queue = destination as Queue;
+
+ if(destination == null)
{
return null;
}
- return new MessageQueue((destination as Destination).Path);
+ return queue.MSMQMessageQueue;
}
/// <summary>
@@ -625,7 +630,7 @@ namespace Apache.NMS.MSMQ
return null;
}
- return new Queue(destinationQueue.Path);
+ return new Queue(destinationQueue);
}
#endregion
diff --git a/src/main/csharp/IMessageConverterEx.cs b/src/main/csharp/IMessageConverterEx.cs
index 92be928..fcd1354 100644
--- a/src/main/csharp/IMessageConverterEx.cs
+++ b/src/main/csharp/IMessageConverterEx.cs
@@ -1,44 +1,44 @@
-using System.Messaging;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ
-{
- /// <summary>
- /// Extended IMessageConverter interface supporting new methods for
- /// optimizing message selection through "selectors".
- /// The original IMessageConverter is maintained for compatibility
- /// reasons with existing clients implementing it.
- /// </summary>
- public interface IMessageConverterEx : IMessageConverter
- {
- /// <summary>
- /// Converts the specified MSMQ message to an equivalent NMS message.
- /// </summary>
- /// <param name="message">MSMQ message to be converted.</param>
- /// <param name="convertBody">true if message body should be converted.</param>
- /// <result>Converted NMS message.</result>
- IMessage ToNmsMessage(Message message, bool convertBody);
-
- /// <summary>
- /// Converts an MSMQ message body to the equivalent NMS message body.
- /// </summary>
- /// <param name="message">Source MSMQ message.</param>
- /// <param name="answer">Target NMS message.</param>
- void ConvertMessageBodyToNMS(Message message, IMessage answer);
- }
-}
+using System.Messaging;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ
+{
+ /// <summary>
+ /// Extended IMessageConverter interface supporting new methods for
+ /// optimizing message selection through "selectors".
+ /// The original IMessageConverter is maintained for compatibility
+ /// reasons with existing clients implementing it.
+ /// </summary>
+ public interface IMessageConverterEx : IMessageConverter
+ {
+ /// <summary>
+ /// Converts the specified MSMQ message to an equivalent NMS message.
+ /// </summary>
+ /// <param name="message">MSMQ message to be converted.</param>
+ /// <param name="convertBody">true if message body should be converted.</param>
+ /// <result>Converted NMS message.</result>
+ IMessage ToNmsMessage(Message message, bool convertBody);
+
+ /// <summary>
+ /// Converts an MSMQ message body to the equivalent NMS message body.
+ /// </summary>
+ /// <param name="message">Source MSMQ message.</param>
+ /// <param name="answer">Target NMS message.</param>
+ void ConvertMessageBodyToNMS(Message message, IMessage answer);
+ }
+}
diff --git a/src/main/csharp/MessageConsumer.cs b/src/main/csharp/MessageConsumer.cs
index eaaed5c..c69c6f5 100644
--- a/src/main/csharp/MessageConsumer.cs
+++ b/src/main/csharp/MessageConsumer.cs
@@ -32,9 +32,6 @@ namespace Apache.NMS.MSMQ
private readonly Session session;
private readonly AcknowledgementMode acknowledgementMode;
private MessageQueue messageQueue;
- private Thread asyncDeliveryThread = null;
- private AutoResetEvent pause = new AutoResetEvent(false);
- private Atomic<bool> asyncDelivery = new Atomic<bool>(false);
private ConsumerTransformerDelegate consumerTransformer;
public ConsumerTransformerDelegate ConsumerTransformer
@@ -81,6 +78,8 @@ namespace Apache.NMS.MSMQ
messageQueue, session.MessageConverter, selector);
}
+ #region Asynchronous delivery
+
private int listenerCount = 0;
private event MessageListener listener;
public event MessageListener Listener
@@ -89,7 +88,13 @@ namespace Apache.NMS.MSMQ
{
listener += value;
listenerCount++;
- StartAsyncDelivery();
+
+ session.Connection.ConnectionStateChange += OnConnectionStateChange;
+
+ if(session.Connection.IsStarted)
+ {
+ StartAsyncDelivery();
+ }
}
remove
@@ -100,87 +105,37 @@ namespace Apache.NMS.MSMQ
listenerCount--;
}
- if(0 == listenerCount)
+ if(listenerCount == 0)
{
+ session.Connection.ConnectionStateChange -= OnConnectionStateChange;
+
StopAsyncDelivery();
}
}
}
- public IMessage Receive()
- {
- IMessage nmsMessage = null;
-
- if(messageQueue != null)
- {
- nmsMessage = reader.Receive();
- nmsMessage = TransformMessage(nmsMessage);
- }
-
- return nmsMessage;
- }
-
- public IMessage Receive(TimeSpan timeout)
- {
- IMessage nmsMessage = null;
-
- if(messageQueue != null)
- {
- nmsMessage = reader.Receive(timeout);
- nmsMessage = TransformMessage(nmsMessage);
- }
-
- return nmsMessage;
- }
-
- public IMessage ReceiveNoWait()
- {
- IMessage nmsMessage = null;
-
- if(messageQueue != null)
- {
- nmsMessage = reader.Receive(zeroTimeout);
- nmsMessage = TransformMessage(nmsMessage);
- }
-
- return nmsMessage;
- }
-
- public void Dispose()
+ private void OnConnectionStateChange(object sender, Connection.StateChangeEventArgs e)
{
- Close();
- }
-
- public void Close()
- {
- StopAsyncDelivery();
- if(messageQueue != null)
+ if(e.CurrentState == Connection.ConnectionState.Starting)
{
- messageQueue.Dispose();
- messageQueue = null;
+ if(listenerCount > 0)
+ {
+ StartAsyncDelivery();
+ }
}
- }
-
- protected virtual void StopAsyncDelivery()
- {
- if(asyncDelivery.CompareAndSet(true, false))
+ else if(e.CurrentState == Connection.ConnectionState.Stopping)
{
- if(null != asyncDeliveryThread)
+ if(listenerCount > 0)
{
- Tracer.Info("Stopping async delivery thread.");
- pause.Set();
- if(!asyncDeliveryThread.Join(10000))
- {
- Tracer.Info("Aborting async delivery thread.");
- asyncDeliveryThread.Abort();
- }
-
- asyncDeliveryThread = null;
- Tracer.Info("Async delivery thread stopped.");
+ StopAsyncDelivery();
}
}
}
+ private Thread asyncDeliveryThread = null;
+ private Atomic<bool> asyncDelivery = new Atomic<bool>(false);
+ TimeSpan dispatchingTimeout = new TimeSpan(5000);
+
protected virtual void StartAsyncDelivery()
{
if(asyncDelivery.CompareAndSet(false, true))
@@ -199,7 +154,7 @@ namespace Apache.NMS.MSMQ
{
try
{
- IMessage message = Receive();
+ IMessage message = Receive(dispatchingTimeout);
if(asyncDelivery.Value && message != null)
{
try
@@ -215,6 +170,7 @@ namespace Apache.NMS.MSMQ
catch(ThreadAbortException ex)
{
Tracer.InfoFormat("Thread abort received in thread: {0} : {1}", this, ex.Message);
+
break;
}
catch(Exception ex)
@@ -225,11 +181,104 @@ namespace Apache.NMS.MSMQ
Tracer.Info("Stopping dispatcher thread consumer: " + this);
}
+ protected virtual void StopAsyncDelivery()
+ {
+ if(asyncDelivery.CompareAndSet(true, false))
+ {
+ if(null != asyncDeliveryThread)
+ {
+ // Thread.Interrupt and Thread.Abort do not interrupt Receive
+ // instructions. Attempting to abort the thread and joining
+ // will result in a phantom backgroud thread, which may
+ // ultimately consume a message before actually stopping.
+
+ Tracer.Info("Waiting for thread to complete aborting.");
+ asyncDeliveryThread.Join(dispatchingTimeout);
+
+ asyncDeliveryThread = null;
+ Tracer.Info("Async delivery thread stopped.");
+ }
+ }
+ }
+
+
protected virtual void HandleAsyncException(Exception e)
{
session.Connection.HandleException(e);
}
+ #endregion
+
+ #region Receive (synchronous)
+
+ public IMessage Receive()
+ {
+ IMessage nmsMessage = null;
+
+ if(messageQueue != null)
+ {
+ nmsMessage = reader.Receive();
+ nmsMessage = TransformMessage(nmsMessage);
+ }
+
+ return nmsMessage;
+ }
+
+ public IMessage Receive(TimeSpan timeout)
+ {
+ IMessage nmsMessage = null;
+
+ if(messageQueue != null)
+ {
+ try
+ {
+ nmsMessage = reader.Receive(timeout);
+ }
+ catch(MessageQueueException ex)
+ {
+ if(ex.MessageQueueErrorCode != MessageQueueErrorCode.IOTimeout)
+ {
+ throw ex;
+ }
+ }
+ nmsMessage = TransformMessage(nmsMessage);
+ }
+
+ return nmsMessage;
+ }
+
+ public IMessage ReceiveNoWait()
+ {
+ return Receive(zeroTimeout);
+ }
+
+ #endregion
+
+ #region Close & dispose
+
+ public void Dispose()
+ {
+ Close();
+ }
+
+ public void Close()
+ {
+ if(listenerCount > 0)
+ {
+ session.Connection.ConnectionStateChange -= OnConnectionStateChange;
+
+ StopAsyncDelivery();
+ }
+
+ if(messageQueue != null)
+ {
+ messageQueue.Dispose();
+ messageQueue = null;
+ }
+ }
+
+ #endregion
+
protected virtual IMessage TransformMessage(IMessage message)
{
IMessage transformed = message;
diff --git a/src/main/csharp/MessageProducer.cs b/src/main/csharp/MessageProducer.cs
index 8690fc4..4a0bed4 100644
--- a/src/main/csharp/MessageProducer.cs
+++ b/src/main/csharp/MessageProducer.cs
@@ -50,41 +50,47 @@ namespace Apache.NMS.MSMQ
this.destination = destination;
if(destination != null)
{
- messageQueue = openMessageQueue(destination);
+ messageQueue = OpenMessageQueue(destination);
}
}
- private MessageQueue openMessageQueue(Destination dest)
+ private MessageQueue OpenMessageQueue(Destination dest)
{
- MessageQueue rc = null;
- try
+ Queue queue = dest as Queue;
+
+ MessageQueue mq = queue.MSMQMessageQueue;
+
+ if(mq == null)
{
- if(!MessageQueue.Exists(dest.Path))
- {
- // create the new message queue and make it transactional
- rc = MessageQueue.Create(dest.Path, session.Transacted);
- this.destination.Path = rc.Path;
- }
- else
+ try
{
- rc = new MessageQueue(dest.Path);
- this.destination.Path = rc.Path;
- if(!rc.CanWrite)
+ if(!Queue.Exists(dest.Path))
{
- throw new NMSSecurityException("Do not have write access to: " + dest);
+ // create the new message queue and make it transactional
+ mq = MessageQueue.Create(dest.Path, session.Transacted);
+ this.destination = new Queue(mq);
+ }
+ else
+ {
+ mq = new MessageQueue(dest.Path);
+ this.destination = new Queue(mq);
+ if(!mq.CanWrite)
+ {
+ throw new NMSSecurityException("Do not have write access to: " + dest);
+ }
}
}
- }
- catch(Exception e)
- {
- if(rc != null)
+ catch(Exception e)
{
- rc.Dispose();
+ if(mq != null)
+ {
+ mq.Dispose();
+ }
+
+ throw new NMSException(e.Message + ": " + dest, e);
}
-
- throw new NMSException(e.Message + ": " + dest, e);
}
- return rc;
+ return mq;
}
public void Send(IMessage message)
@@ -111,18 +117,28 @@ namespace Apache.NMS.MSMQ
// Locate the MSMQ Queue we will be sending to
if(messageQueue != null)
{
+ if(destination == null)
+ {
+ throw new InvalidDestinationException("This producer can only be used to send to: " + destination);
+ }
+
if(destination.Equals(this.destination))
{
mq = messageQueue;
}
else
{
- throw new NMSException("This producer can only be used to send to: " + destination);
+ throw new NotSupportedException("This producer can only be used to send to: " + destination);
}
}
else
{
- mq = openMessageQueue((Destination) destination);
+ if(destination == null)
+ {
+ throw new NotSupportedException();
+ }
+
+ mq = OpenMessageQueue((Destination) destination);
}
if(this.ProducerTransformer != null)
@@ -147,7 +163,7 @@ namespace Apache.NMS.MSMQ
// TODO: message.NMSMessageId =
}
- // Convert the Mesasge into a MSMQ message
+ // Convert the Message into a MSMQ message
Message msg = session.MessageConverter.ToMsmqMessage(message);
if(mq.Transactional)
@@ -179,6 +195,11 @@ namespace Apache.NMS.MSMQ
mq.Send(msg);
}
+ message.NMSMessageId = msg.Id;
+ if(message.NMSCorrelationID == null)
+ {
+ message.NMSCorrelationID = msg.CorrelationId;
+ }
}
finally
{
diff --git a/src/main/csharp/Queue.cs b/src/main/csharp/Queue.cs
index 30efcd9..4444a1b 100644
--- a/src/main/csharp/Queue.cs
+++ b/src/main/csharp/Queue.cs
@@ -15,6 +15,7 @@
* limitations under the License.
*/
using System;
+using System.Messaging;
namespace Apache.NMS.MSMQ
{
@@ -24,17 +25,69 @@ namespace Apache.NMS.MSMQ
/// </summary>
public class Queue : Destination, IQueue
{
-
public Queue()
: base()
{
}
+ public Queue(MessageQueue messageQueue)
+ : base()
+ {
+ this.messageQueue = messageQueue;
+ Path = messageQueue.Path;
+ }
+
public Queue(String name)
: base(name)
{
+ if(string.IsNullOrEmpty(name))
+ {
+ messageQueue = null;
+ }
+ else
+ {
+ try
+ {
+ messageQueue = new MessageQueue(name);
+ }
+ catch(Exception /*ex*/)
+ {
+ // Excerpt from Microsoft documentation for MessageQueue.Exists :
+ // (@https://msdn.microsoft.com/fr-fr/library/system.messaging.messagequeue.exists(v=vs.110).aspx)
+ // Exists(String) is an expensive operation. Use it only when it is necessary within the application.
+ // ---
+ // Therefore, we won't check for existence of the queue before attempting to access it.
+
+ //if(!Exists(name))
+ //{
+ // Excerpt from the Oracle JMS JavaDoc for Session.createQueue :
+ // (@https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#createQueue-java.lang.String-)
+ // Note that this method simply creates an object that encapsulates the name of a queue. It does
+ // not create the physical queue in the JMS provider. JMS does not provide a method to create the
+ // physical queue, since this would be specific to a given JMS provider. Creating a physical queue
+ // is provider-specific and is typically an administrative task performed by an administrator,
+ // though some providers may create them automatically when needed. The one exception to this is
+ // the creation of a temporary queue, which is done using the createTemporaryQueue method.
+ // ---
+ // Therefore, we should throw an NMSException if the queue does not exist.
+ // ---
+ // BUT, to keep it compatible with the initial implementation of MessageProducer, which attempts
+ // to create non pre-existing queues, we keep it silent..
+
+ // throw new NMSException("Message queue \"" + name + "\" does not exist", ex);
+ //}
+
+ // throw new NMSException("Cannot access message queue \"" + name + "\"", ex);
+ }
+ }
}
+ private MessageQueue messageQueue;
+ public MessageQueue MSMQMessageQueue
+ {
+ get { return messageQueue; }
+ }
+
override public DestinationType DestinationType
{
get
@@ -54,7 +107,25 @@ namespace Apache.NMS.MSMQ
return new Queue(name);
}
+ public static bool Exists(string name)
+ {
+ try
+ {
+ return MessageQueue.Exists(name);
+ }
+ catch(InvalidOperationException)
+ {
+ // Excerpt from Microsoft documentation for MessageQueue.Exists :
+ // (@https://msdn.microsoft.com/fr-fr/library/system.messaging.messagequeue.exists(v=vs.110).aspx)
+ // InvalidOperationException: The application used format name syntax when verifying queue existence.
+ // ---
+ // The Exists(String) method does not support the FormatName prefix.
+ // No method exists to determine whether a queue with a specified format name exists.
+ // We'll assume the queue exists at this point
+ return true;
+ }
+ }
}
}
diff --git a/src/main/csharp/QueueBrowser.cs b/src/main/csharp/QueueBrowser.cs
index 3ff795d..9ccc2f9 100644
--- a/src/main/csharp/QueueBrowser.cs
+++ b/src/main/csharp/QueueBrowser.cs
@@ -1,164 +1,172 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-using System;
-using System.Collections;
-using System.Messaging;
-using Apache.NMS;
-using Apache.NMS.Util;
-using Apache.NMS.MSMQ.Readers;
-
-namespace Apache.NMS.MSMQ
-{
- public class QueueBrowser : Apache.NMS.IQueueBrowser
- {
- private bool closed = false;
- private bool disposed = false;
-
- private readonly Session session;
- private MessageQueue messageQueue;
-
- private string selector;
-
- private IMessageReader reader;
-
- public QueueBrowser(Session session, MessageQueue messageQueue)
- : this(session, messageQueue, null)
- {
- }
-
- public QueueBrowser(Session session, MessageQueue messageQueue,
- string selector)
- {
- this.session = session;
- this.messageQueue = messageQueue;
- if(null != this.messageQueue)
- {
- this.messageQueue.MessageReadPropertyFilter.SetAll();
- }
-
- reader = MessageReaderUtil.CreateMessageReader(
- messageQueue, session.MessageConverter, selector);
- }
-
- ~QueueBrowser()
- {
- Dispose(false);
- }
-
- #region IDisposable Members
-
- ///<summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///</summary>
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void Dispose(bool disposing)
- {
- if(disposed)
- {
- return;
- }
-
- if(disposing)
- {
- // Dispose managed code here.
- }
-
- try
- {
- Close();
- }
- catch
- {
- // Ignore errors.
- }
-
- disposed = true;
- }
-
- #endregion
-
- public void Close()
- {
- if(messageQueue != null)
- {
- messageQueue.Dispose();
- messageQueue = null;
- }
- closed = true;
- }
-
- public string MessageSelector
- {
- get { return selector; }
- }
-
- public IQueue Queue
- {
- get { return new Queue(this.messageQueue.Path); }
- }
-
- internal class Enumerator : IEnumerator
- {
- private readonly Session session;
- private readonly MessageEnumerator innerEnumerator;
- private readonly IMessageReader reader;
-
- public Enumerator(Session session, MessageQueue messageQueue,
- IMessageReader reader)
- {
- this.session = session;
- this.innerEnumerator = messageQueue.GetMessageEnumerator2();
- this.reader = reader;
- }
-
- public object Current
- {
- get
- {
- return this.session.MessageConverter.ToNmsMessage(this.innerEnumerator.Current);
- }
- }
-
- public bool MoveNext()
- {
- while(this.innerEnumerator.MoveNext())
- {
- if(reader.Matches(this.innerEnumerator.Current))
- {
- return true;
- }
- }
- return false;
- }
-
- public void Reset()
- {
- this.innerEnumerator.Reset();
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new Enumerator(this.session, this.messageQueue, this.reader);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Collections;
+using System.Messaging;
+using Apache.NMS;
+using Apache.NMS.Util;
+using Apache.NMS.MSMQ.Readers;
+
+namespace Apache.NMS.MSMQ
+{
+ public class QueueBrowser : Apache.NMS.IQueueBrowser
+ {
+ private bool disposed = false;
+
+ private readonly Session session;
+ private MessageQueue messageQueue;
+
+ private string selector;
+
+ private IMessageReader reader;
+
+ public QueueBrowser(Session session, MessageQueue messageQueue)
+ : this(session, messageQueue, null)
+ {
+ }
+
+ public QueueBrowser(Session session, MessageQueue messageQueue,
+ string selector)
+ {
+ this.session = session;
+ this.messageQueue = messageQueue;
+ if(null != this.messageQueue)
+ {
+ this.messageQueue.MessageReadPropertyFilter.SetAll();
+ }
+ this.selector = selector;
+
+ reader = MessageReaderUtil.CreateMessageReader(
+ messageQueue, session.MessageConverter, selector);
+ }
+
+ ~QueueBrowser()
+ {
+ Dispose(false);
+ }
+
+ #region IDisposable Members
+
+ ///<summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///</summary>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected void Dispose(bool disposing)
+ {
+ if(disposed)
+ {
+ return;
+ }
+
+ if(disposing)
+ {
+ // Dispose managed code here.
+ }
+
+ try
+ {
+ Close();
+ }
+ catch
+ {
+ // Ignore errors.
+ }
+
+ disposed = true;
+ }
+
+ #endregion
+
+ public void Close()
+ {
+ if(messageQueue != null)
+ {
+ messageQueue.Dispose();
+ messageQueue = null;
+ }
+ }
+
+ public string MessageSelector
+ {
+ get { return selector; }
+ }
+
+ public IQueue Queue
+ {
+ get { return new Queue(this.messageQueue.Path); }
+ }
+
+ internal class Enumerator : IEnumerator, IDisposable
+ {
+ private Session session;
+ private MessageEnumerator innerEnumerator;
+ private IMessageReader reader;
+
+ public Enumerator(Session session, MessageQueue messageQueue,
+ IMessageReader reader)
+ {
+ this.session = session;
+ this.innerEnumerator = messageQueue.GetMessageEnumerator2();
+ this.reader = reader;
+ }
+
+ public object Current
+ {
+ get
+ {
+ return this.session.MessageConverter.ToNmsMessage(this.innerEnumerator.Current);
+ }
+ }
+
+ public bool MoveNext()
+ {
+ while(this.innerEnumerator.MoveNext())
+ {
+ if(reader.Matches(this.innerEnumerator.Current))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void Reset()
+ {
+ this.innerEnumerator.Reset();
+ }
+
+ public void Dispose()
+ {
+ if(innerEnumerator != null)
+ {
+ innerEnumerator.Close();
+ innerEnumerator = null;
+ }
+ }
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return new Enumerator(this.session, this.messageQueue, this.reader);
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/AbstractMessageReader.cs b/src/main/csharp/Readers/AbstractMessageReader.cs
index 7874696..dcb217d 100644
--- a/src/main/csharp/Readers/AbstractMessageReader.cs
+++ b/src/main/csharp/Readers/AbstractMessageReader.cs
@@ -1,126 +1,126 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// Abstract MSMQ message reader. Derived classes support various
- /// message filtering methods.
- /// </summary>
- public abstract class AbstractMessageReader : IMessageReader
- {
- protected MessageQueue messageQueue;
- protected IMessageConverter messageConverter;
- protected IMessageConverterEx messageConverterEx;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- public AbstractMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter)
- {
- this.messageQueue = messageQueue;
-
- this.messageConverter = messageConverter;
- this.messageConverterEx = (messageConverter as IMessageConverterEx);
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public abstract IMessage Peek();
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public abstract IMessage Peek(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public abstract IMessage Receive();
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public abstract IMessage Receive(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public abstract IMessage Receive(MessageQueueTransaction transaction);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public abstract IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction);
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public abstract bool Matches(Message message);
-
- /// <summary>
- /// Converts an MSMQ message to an NMS message, using the converter
- /// specified at construction time.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>NMS message.</return>
- protected IMessage Convert(Message message)
- {
- return message == null ? null : messageConverter.ToNmsMessage(message);
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// Abstract MSMQ message reader. Derived classes support various
+ /// message filtering methods.
+ /// </summary>
+ public abstract class AbstractMessageReader : IMessageReader
+ {
+ protected MessageQueue messageQueue;
+ protected IMessageConverter messageConverter;
+ protected IMessageConverterEx messageConverterEx;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ public AbstractMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter)
+ {
+ this.messageQueue = messageQueue;
+
+ this.messageConverter = messageConverter;
+ this.messageConverterEx = (messageConverter as IMessageConverterEx);
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public abstract IMessage Peek();
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public abstract IMessage Peek(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public abstract IMessage Receive();
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public abstract IMessage Receive(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public abstract IMessage Receive(MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public abstract IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public abstract bool Matches(Message message);
+
+ /// <summary>
+ /// Converts an MSMQ message to an NMS message, using the converter
+ /// specified at construction time.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>NMS message.</return>
+ protected IMessage Convert(Message message)
+ {
+ return message == null ? null : messageConverter.ToNmsMessage(message);
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/ByCorrelationIdMessageReader.cs b/src/main/csharp/Readers/ByCorrelationIdMessageReader.cs
index fad3d1a..bc8d832 100644
--- a/src/main/csharp/Readers/ByCorrelationIdMessageReader.cs
+++ b/src/main/csharp/Readers/ByCorrelationIdMessageReader.cs
@@ -1,139 +1,139 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// message identifier.
- /// </summary>
- public class ByCorrelationIdMessageReader : AbstractMessageReader
- {
- private string correlationId;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="correlationId">The correlation identifier of messages
- /// to be read.</param>
- public ByCorrelationIdMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, string correlationId)
- : base(messageQueue, messageConverter)
- {
- this.correlationId = correlationId;
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.PeekByCorrelationId(correlationId));
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- return Convert(messageQueue.PeekByCorrelationId(correlationId,
- timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.ReceiveByCorrelationId(correlationId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
- timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
- transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
- timeSpan, transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- // NB: case-sensitive match
- return message.CorrelationId == correlationId;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// message identifier.
+ /// </summary>
+ public class ByCorrelationIdMessageReader : AbstractMessageReader
+ {
+ private string correlationId;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="correlationId">The correlation identifier of messages
+ /// to be read.</param>
+ public ByCorrelationIdMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, string correlationId)
+ : base(messageQueue, messageConverter)
+ {
+ this.correlationId = correlationId;
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return Convert(messageQueue.PeekByCorrelationId(correlationId));
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.PeekByCorrelationId(correlationId,
+ timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return Convert(messageQueue.ReceiveByCorrelationId(correlationId));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
+ timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
+ transaction));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveByCorrelationId(correlationId,
+ timeSpan, transaction));
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ // NB: case-sensitive match
+ return message.CorrelationId == correlationId;
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/ByIdMessageReader.cs b/src/main/csharp/Readers/ByIdMessageReader.cs
index f981ca8..6a544f4 100644
--- a/src/main/csharp/Readers/ByIdMessageReader.cs
+++ b/src/main/csharp/Readers/ByIdMessageReader.cs
@@ -1,136 +1,136 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// message identifier.
- /// </summary>
- public class ByIdMessageReader : AbstractMessageReader
- {
- private string messageId;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="messageId">The message identifier of messages to
- /// be read.</param>
- public ByIdMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, string messageId)
- : base(messageQueue, messageConverter)
- {
- this.messageId = messageId;
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.PeekById(messageId));
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- return Convert(messageQueue.PeekById(messageId, timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.ReceiveById(messageId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return Convert(messageQueue.ReceiveById(messageId, timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveById(messageId, transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveById(messageId, timeSpan,
- transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- // NB: case-sensitive match
- return message.Id == messageId;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// message identifier.
+ /// </summary>
+ public class ByIdMessageReader : AbstractMessageReader
+ {
+ private string messageId;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="messageId">The message identifier of messages to
+ /// be read.</param>
+ public ByIdMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, string messageId)
+ : base(messageQueue, messageConverter)
+ {
+ this.messageId = messageId;
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return Convert(messageQueue.PeekById(messageId));
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.PeekById(messageId, timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return Convert(messageQueue.ReceiveById(messageId));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, transaction));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.ReceiveById(messageId, timeSpan,
+ transaction));
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ // NB: case-sensitive match
+ return message.Id == messageId;
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/ByLookupIdMessageReader.cs b/src/main/csharp/Readers/ByLookupIdMessageReader.cs
index 421c52b..423c3a7 100644
--- a/src/main/csharp/Readers/ByLookupIdMessageReader.cs
+++ b/src/main/csharp/Readers/ByLookupIdMessageReader.cs
@@ -1,145 +1,215 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// lookup identifier.
- /// </summary>
- public class ByLookupIdMessageReader : AbstractMessageReader
- {
- private Int64 lookupId;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="lookupId">The lookup identifier of the message
- /// to be read.</param>
- public ByLookupIdMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, Int64 lookupId)
- : base(messageQueue, messageConverter)
- {
- this.lookupId = lookupId;
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.PeekByLookupId(lookupId));
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.PeekByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.ReceiveByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.ReceiveByLookupId(lookupId));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- // No time-out option for receiving messages by lookup identifiers:
- // either the message is present in the queue, or the method throws
- // an exception immediately if the message is not in the queue.
- return Convert(messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- return message.LookupId == lookupId;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// lookup identifier.
+ /// </summary>
+ public class ByLookupIdMessageReader : AbstractMessageReader
+ {
+ private Int64 lookupId;
+
+ // The MSMQ documentation for MessageQueue.PeekByLookupId(*) and
+ // MessageQueue.ReceiveByLookupId(*) specifies:
+ // InvalidOperationException: The message with the specified lookupId could not be found.
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="lookupId">The lookup identifier of the message
+ /// to be read.</param>
+ public ByLookupIdMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, Int64 lookupId)
+ : base(messageQueue, messageConverter)
+ {
+ this.lookupId = lookupId;
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ try
+ {
+ return Convert(messageQueue.PeekByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.PeekByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ try
+ {
+ return Convert(messageQueue.ReceiveByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.ReceiveByLookupId(lookupId));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ try
+ {
+ return Convert(messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ try
+ {
+ // No time-out option for receiving messages by lookup identifiers:
+ // either the message is present in the queue, or the method throws
+ // an exception immediately if the message is not in the queue.
+ return Convert(messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+ }
+ catch(InvalidOperationException)
+ {
+ return null;
+ }
+ catch(Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ return message.LookupId == lookupId;
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/BySelectorMessageReader.cs b/src/main/csharp/Readers/BySelectorMessageReader.cs
index e7cd5c3..5617784 100644
--- a/src/main/csharp/Readers/BySelectorMessageReader.cs
+++ b/src/main/csharp/Readers/BySelectorMessageReader.cs
@@ -1,290 +1,286 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-using Apache.NMS;
-using Apache.NMS.Selector;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning messages matching the specified
- /// selector.
- /// </summary>
- public class BySelectorMessageReader : AbstractMessageReader
- {
- private string selector;
- private MessageEvaluationContext evaluationContext;
- private IBooleanExpression selectionExpression;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="selector">The selector string.</param>
- public BySelectorMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter, string selector)
- : base(messageQueue, messageConverter)
- {
- this.selector = selector;
-
- SelectorParser selectorParser = new SelectorParser();
- selectionExpression = selectorParser.Parse(selector);
-
- evaluationContext = new MessageEvaluationContext(null);
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return InternalPeek(DateTime.MaxValue, true);
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- DateTime maxTime = DateTime.Now + timeSpan;
- return InternalPeek(maxTime, true);
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return InternalReceive(DateTime.MaxValue, null);
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return InternalReceive(DateTime.Now + timeSpan, null);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return InternalReceive(DateTime.MaxValue, transaction);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return InternalReceive(DateTime.Now + timeSpan, transaction);
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="maxTime">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public IMessage InternalReceive(DateTime maxTime,
- MessageQueueTransaction transaction)
- {
- // In a shared connection / multi-consumer context, the message may
- // have been consumed by another client, after it was peeked but
- // before it was peeked by this client. Hence the loop.
- // (not sure it can be shared AND transactional, though).
- while(true)
- {
- IMessage peekedMessage = InternalPeek(maxTime, false);
-
- if(peekedMessage == null)
- {
- return null;
- }
-
- try
- {
- long lookupId = peekedMessage.Properties.GetLong("LookupId");
-
- Message message = (transaction == null ?
- messageQueue.ReceiveByLookupId(lookupId) :
- messageQueue.ReceiveByLookupId(
- MessageLookupAction.Current, lookupId, transaction));
-
- return Convert(message);
- }
- catch(InvalidOperationException exc)
- {
- // TODO: filter exceptions, catch only exceptions due to
- // unknown lookup id.
- }
- }
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue, matching the selection criteria.
- /// </summary>
- /// <param name="maxTime">Reception time-out.</param>
- /// <param name="convertBody">true if message body should be converted.</param>
- /// <returns>Peeked message.</returns>
- private IMessage InternalPeek(DateTime maxTime, bool convertBody)
- {
- TimeSpan timeSpan = maxTime - DateTime.Now;
- if(timeSpan <= TimeSpan.Zero)
- {
- timeSpan = TimeSpan.Zero;
- }
-
- Cursor cursor = messageQueue.CreateCursor();
-
- PeekAction action = PeekAction.Current;
-
- while(true)
- {
- Message msmqMessage = null;
-
- try
- {
- msmqMessage = messageQueue.Peek(timeSpan, cursor, action);
- }
- catch(MessageQueueException exc)
- {
- if(exc.MessageQueueErrorCode != MessageQueueErrorCode.IOTimeout)
- {
- throw exc;
- }
- }
-
- if(msmqMessage == null)
- {
- return null;
- }
-
- IMessage nmsMessage = InternalMatch(msmqMessage, convertBody);
-
- if(nmsMessage != null)
- {
- return nmsMessage;
- }
-
- action = PeekAction.Next;
- }
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria. If matched
- /// the method returns the converted NMS message. Else it returns null.
- /// </summary>
- /// <param name="message">The MSMQ message to check.</param>
- /// <param name="convertBody">true if the message body should be
- /// converted.</param>
- /// <returns>The matching message converted to NMS, or null.</returns>
- private IMessage InternalMatch(Message message, bool convertBody)
- {
- if(messageConverterEx == null)
- {
- IMessage nmsMessage = messageConverter.ToNmsMessage(message);
-
- evaluationContext.Message = nmsMessage;
-
- if(selectionExpression.Matches(evaluationContext))
- {
- return nmsMessage;
- }
- }
- else
- {
- // This version converts the message body only for those
- // messages matching the selection criteria.
- // Relies on MessageConverterEx for partial conversions.
- IMessage nmsMessage = messageConverterEx.ToNmsMessage(
- message, false);
-
- evaluationContext.Message = nmsMessage;
-
- if(selectionExpression.Matches(evaluationContext))
- {
- if(convertBody)
- {
- messageConverterEx.ConvertMessageBodyToNMS(
- message, nmsMessage);
- }
-
- return nmsMessage;
- }
- }
-
- return null;
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- IMessage nmsMessage = messageConverterEx == null ?
- messageConverter.ToNmsMessage(message) :
- messageConverterEx.ToNmsMessage(message, false);
-
- evaluationContext.Message = nmsMessage;
-
- return selectionExpression.Matches(evaluationContext);
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+using Apache.NMS;
+using Apache.NMS.Selector;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning messages matching the specified
+ /// selector.
+ /// </summary>
+ public class BySelectorMessageReader : AbstractMessageReader
+ {
+ private string selector;
+ private MessageEvaluationContext evaluationContext;
+ private IBooleanExpression selectionExpression;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="selector">The selector string.</param>
+ public BySelectorMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter, string selector)
+ : base(messageQueue, messageConverter)
+ {
+ this.selector = selector;
+
+ SelectorParser selectorParser = new SelectorParser();
+ selectionExpression = selectorParser.Parse(selector);
+
+ evaluationContext = new MessageEvaluationContext(null);
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return InternalPeek(DateTime.MaxValue, true);
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ DateTime maxTime = DateTime.Now + timeSpan;
+ return InternalPeek(maxTime, true);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return InternalReceive(DateTime.MaxValue, null);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return InternalReceive(DateTime.Now + timeSpan, null);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return InternalReceive(DateTime.MaxValue, transaction);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return InternalReceive(DateTime.Now + timeSpan, transaction);
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="maxTime">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public IMessage InternalReceive(DateTime maxTime,
+ MessageQueueTransaction transaction)
+ {
+ // In a shared connection / multi-consumer context, the message may
+ // have been consumed by another client, after it was peeked but
+ // before it was peeked by this client. Hence the loop.
+ // (not sure it can be shared AND transactional, though).
+ while(true)
+ {
+ IMessage peekedMessage = InternalPeek(maxTime, false);
+
+ if(peekedMessage == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ long lookupId = peekedMessage.Properties.GetLong("LookupId");
+
+ Message message = (transaction == null ?
+ messageQueue.ReceiveByLookupId(lookupId) :
+ messageQueue.ReceiveByLookupId(
+ MessageLookupAction.Current, lookupId, transaction));
+
+ return Convert(message);
+ }
+ catch(InvalidOperationException)
+ {
+ // TODO: filter exceptions, catch only exceptions due to
+ // unknown lookup id.
+ }
+ }
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue, matching the selection criteria.
+ /// </summary>
+ /// <param name="maxTime">Reception time-out.</param>
+ /// <param name="convertBody">true if message body should be converted.</param>
+ /// <returns>Peeked message.</returns>
+ private IMessage InternalPeek(DateTime maxTime, bool convertBody)
+ {
+ TimeSpan timeSpan = maxTime - DateTime.Now;
+ if(timeSpan <= TimeSpan.Zero)
+ {
+ timeSpan = TimeSpan.Zero;
+ }
+
+ using(Cursor cursor = messageQueue.CreateCursor())
+ {
+ PeekAction action = PeekAction.Current;
+ while(true)
+ {
+ Message msmqMessage = null;
+
+ try
+ {
+ msmqMessage = messageQueue.Peek(timeSpan, cursor, action);
+ }
+ catch(MessageQueueException exc)
+ {
+ if(exc.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
+ {
+ return null;
+ }
+ throw exc;
+ }
+
+ IMessage nmsMessage = InternalMatch(msmqMessage, convertBody);
+
+ if(nmsMessage != null)
+ {
+ return nmsMessage;
+ }
+
+ action = PeekAction.Next;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria. If matched
+ /// the method returns the converted NMS message. Else it returns null.
+ /// </summary>
+ /// <param name="message">The MSMQ message to check.</param>
+ /// <param name="convertBody">true if the message body should be
+ /// converted.</param>
+ /// <returns>The matching message converted to NMS, or null.</returns>
+ private IMessage InternalMatch(Message message, bool convertBody)
+ {
+ if(messageConverterEx == null)
+ {
+ IMessage nmsMessage = messageConverter.ToNmsMessage(message);
+
+ evaluationContext.Message = nmsMessage;
+
+ if(selectionExpression.Matches(evaluationContext))
+ {
+ return nmsMessage;
+ }
+ }
+ else
+ {
+ // This version converts the message body only for those
+ // messages matching the selection criteria.
+ // Relies on MessageConverterEx for partial conversions.
+ IMessage nmsMessage = messageConverterEx.ToNmsMessage(
+ message, false);
+
+ evaluationContext.Message = nmsMessage;
+
+ if(selectionExpression.Matches(evaluationContext))
+ {
+ if(convertBody)
+ {
+ messageConverterEx.ConvertMessageBodyToNMS(
+ message, nmsMessage);
+ }
+
+ return nmsMessage;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ IMessage nmsMessage = messageConverterEx == null ?
+ messageConverter.ToNmsMessage(message) :
+ messageConverterEx.ToNmsMessage(message, false);
+
+ evaluationContext.Message = nmsMessage;
+
+ return selectionExpression.Matches(evaluationContext);
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/IMessageReader.cs b/src/main/csharp/Readers/IMessageReader.cs
index 8168664..c36323f 100644
--- a/src/main/csharp/Readers/IMessageReader.cs
+++ b/src/main/csharp/Readers/IMessageReader.cs
@@ -1,93 +1,93 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader.
- /// </summary>
- public interface IMessageReader
- {
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- IMessage Peek();
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- IMessage Peek(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- IMessage Receive();
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(TimeSpan timeSpan);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(MessageQueueTransaction transaction);
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- IMessage Receive(TimeSpan timeSpan, MessageQueueTransaction transaction);
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- bool Matches(Message message);
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader.
+ /// </summary>
+ public interface IMessageReader
+ {
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ IMessage Peek();
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ IMessage Peek(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ IMessage Receive();
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(TimeSpan timeSpan);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ IMessage Receive(TimeSpan timeSpan, MessageQueueTransaction transaction);
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ bool Matches(Message message);
+ }
+}
diff --git a/src/main/csharp/Readers/MessageReaderUtil.cs b/src/main/csharp/Readers/MessageReaderUtil.cs
index c303965..97d62c3 100644
--- a/src/main/csharp/Readers/MessageReaderUtil.cs
+++ b/src/main/csharp/Readers/MessageReaderUtil.cs
@@ -1,91 +1,91 @@
-using System;
-using System.Messaging;
-using System.Globalization;
-using System.Text.RegularExpressions;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// Utility routines for creating MSMQ message readers.
- /// </summary>
- public static class MessageReaderUtil
- {
- private static Regex basicSelectorRegex =
- new Regex(@"^\s*" +
- @"(NMSMessageId)\s*=\s*'([^']*)'|" +
- @"(NMSCorrelationId)\s*=\s*'([^']*)'|" +
- @"(LookupId)\s*=\s*([-+]{0,1}\d+)" +
- @"\s*$",
- RegexOptions.IgnoreCase | RegexOptions.Compiled);
-
- /// <summary>
- /// Creates a message reader for the specified message selector.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- /// <param name="selector">The message selector.</param>
- /// <return>A reader for the specified selector.</return>
- public static IMessageReader CreateMessageReader(
- MessageQueue messageQueue, IMessageConverter messageConverter,
- string selector)
- {
- IMessageReader reader;
-
- if(string.IsNullOrEmpty(selector))
- {
- reader = new NonFilteringMessageReader(messageQueue,
- messageConverter);
- }
- else
- {
- Match match = basicSelectorRegex.Match(selector);
- if(match.Success)
- {
- if(!string.IsNullOrEmpty(match.Groups[1].Value))
- {
- reader = new ByIdMessageReader(messageQueue,
- messageConverter, match.Groups[2].Value);
- }
- else if(!string.IsNullOrEmpty(match.Groups[3].Value))
- {
- reader = new ByCorrelationIdMessageReader(messageQueue,
- messageConverter, match.Groups[4].Value);
- }
- else
- {
- Int64 lookupId = Int64.Parse(match.Groups[6].Value,
- CultureInfo.InvariantCulture);
-
- reader = new ByLookupIdMessageReader(messageQueue,
- messageConverter, lookupId);
- }
- }
- else
- {
- reader = new BySelectorMessageReader(messageQueue,
- messageConverter, selector);
- }
- }
-
- return reader;
- }
- }
-}
+using System;
+using System.Messaging;
+using System.Globalization;
+using System.Text.RegularExpressions;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// Utility routines for creating MSMQ message readers.
+ /// </summary>
+ public static class MessageReaderUtil
+ {
+ private static Regex basicSelectorRegex =
+ new Regex(@"^\s*" +
+ @"(NMSMessageId)\s*=\s*'([^']*)'|" +
+ @"(NMSCorrelationId)\s*=\s*'([^']*)'|" +
+ @"(LookupId)\s*=\s*([-+]{0,1}\d+)" +
+ @"\s*$",
+ RegexOptions.IgnoreCase | RegexOptions.Compiled);
+
+ /// <summary>
+ /// Creates a message reader for the specified message selector.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ /// <param name="selector">The message selector.</param>
+ /// <return>A reader for the specified selector.</return>
+ public static IMessageReader CreateMessageReader(
+ MessageQueue messageQueue, IMessageConverter messageConverter,
+ string selector)
+ {
+ IMessageReader reader;
+
+ if(string.IsNullOrEmpty(selector))
+ {
+ reader = new NonFilteringMessageReader(messageQueue,
+ messageConverter);
+ }
+ else
+ {
+ Match match = basicSelectorRegex.Match(selector);
+ if(match.Success)
+ {
+ if(!string.IsNullOrEmpty(match.Groups[1].Value))
+ {
+ reader = new ByIdMessageReader(messageQueue,
+ messageConverter, match.Groups[2].Value);
+ }
+ else if(!string.IsNullOrEmpty(match.Groups[3].Value))
+ {
+ reader = new ByCorrelationIdMessageReader(messageQueue,
+ messageConverter, match.Groups[4].Value);
+ }
+ else
+ {
+ Int64 lookupId = Int64.Parse(match.Groups[6].Value,
+ CultureInfo.InvariantCulture);
+
+ reader = new ByLookupIdMessageReader(messageQueue,
+ messageConverter, lookupId);
+ }
+ }
+ else
+ {
+ reader = new BySelectorMessageReader(messageQueue,
+ messageConverter, selector);
+ }
+ }
+
+ return reader;
+ }
+ }
+}
diff --git a/src/main/csharp/Readers/NonFilteringMessageReader.cs b/src/main/csharp/Readers/NonFilteringMessageReader.cs
index ea98baf..0b9ff7b 100644
--- a/src/main/csharp/Readers/NonFilteringMessageReader.cs
+++ b/src/main/csharp/Readers/NonFilteringMessageReader.cs
@@ -1,128 +1,128 @@
-using System;
-using System.Messaging;
-using Apache.NMS.MSMQ;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.MSMQ.Readers
-{
- /// <summary>
- /// MSMQ message reader, returning all messages, without filtering.
- /// </summary>
- public class NonFilteringMessageReader : AbstractMessageReader
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="messageQueue">The MSMQ message queue from which
- /// messages will be read.</param>
- /// <param name="messageConverter">A message converter for mapping
- /// MSMQ messages to NMS messages.</param>
- public NonFilteringMessageReader(MessageQueue messageQueue,
- IMessageConverter messageConverter)
- : base(messageQueue, messageConverter)
- {
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available.
- /// </summary>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek()
- {
- return Convert(messageQueue.Peek());
- }
-
- /// <summary>
- /// Returns without removing (peeks) the first message in the queue
- /// referenced by this MessageQueue matching the selection criteria.
- /// The Peek method is synchronous, so it blocks the current thread
- /// until a message becomes available or the specified time-out occurs.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Peeked message.</returns>
- public override IMessage Peek(TimeSpan timeSpan)
- {
- return Convert(messageQueue.Peek(timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by
- /// the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <returns>Received message.</returns>
- public override IMessage Receive()
- {
- return Convert(messageQueue.Receive());
- }
-
- /// <summary>
- /// Receives the first message available in the queue referenced by the
- /// MessageQueue matching the selection criteria, and waits until either
- /// a message is available in the queue, or the time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan)
- {
- return Convert(messageQueue.Receive(timeSpan));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria.
- /// This call is synchronous, and blocks the current thread of execution
- /// until a message is available.
- /// </summary>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.Receive(transaction));
- }
-
- /// <summary>
- /// Receives the first message available in the transactional queue
- /// referenced by the MessageQueue matching the selection criteria,
- /// and waits until either a message is available in the queue, or the
- /// time-out expires.
- /// </summary>
- /// <param name="timeSpan">Reception time-out.</param>
- /// <param name="transaction">Transaction.</param>
- /// <returns>Received message.</returns>
- public override IMessage Receive(TimeSpan timeSpan,
- MessageQueueTransaction transaction)
- {
- return Convert(messageQueue.Receive(timeSpan, transaction));
- }
-
- /// <summary>
- /// Checks if an MSMQ message matches the selection criteria.
- /// </summary>
- /// <param name="message">MSMQ message.</param>
- /// <return>true if the message matches the selection criteria.</return>
- public override bool Matches(Message message)
- {
- return true;
- }
- }
-}
+using System;
+using System.Messaging;
+using Apache.NMS.MSMQ;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+namespace Apache.NMS.MSMQ.Readers
+{
+ /// <summary>
+ /// MSMQ message reader, returning all messages, without filtering.
+ /// </summary>
+ public class NonFilteringMessageReader : AbstractMessageReader
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="messageQueue">The MSMQ message queue from which
+ /// messages will be read.</param>
+ /// <param name="messageConverter">A message converter for mapping
+ /// MSMQ messages to NMS messages.</param>
+ public NonFilteringMessageReader(MessageQueue messageQueue,
+ IMessageConverter messageConverter)
+ : base(messageQueue, messageConverter)
+ {
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available.
+ /// </summary>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek()
+ {
+ return Convert(messageQueue.Peek());
+ }
+
+ /// <summary>
+ /// Returns without removing (peeks) the first message in the queue
+ /// referenced by this MessageQueue matching the selection criteria.
+ /// The Peek method is synchronous, so it blocks the current thread
+ /// until a message becomes available or the specified time-out occurs.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Peeked message.</returns>
+ public override IMessage Peek(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.Peek(timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by
+ /// the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive()
+ {
+ return Convert(messageQueue.Receive());
+ }
+
+ /// <summary>
+ /// Receives the first message available in the queue referenced by the
+ /// MessageQueue matching the selection criteria, and waits until either
+ /// a message is available in the queue, or the time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan)
+ {
+ return Convert(messageQueue.Receive(timeSpan));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria.
+ /// This call is synchronous, and blocks the current thread of execution
+ /// until a message is available.
+ /// </summary>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.Receive(transaction));
+ }
+
+ /// <summary>
+ /// Receives the first message available in the transactional queue
+ /// referenced by the MessageQueue matching the selection criteria,
+ /// and waits until either a message is available in the queue, or the
+ /// time-out expires.
+ /// </summary>
+ /// <param name="timeSpan">Reception time-out.</param>
+ /// <param name="transaction">Transaction.</param>
+ /// <returns>Received message.</returns>
+ public override IMessage Receive(TimeSpan timeSpan,
+ MessageQueueTransaction transaction)
+ {
+ return Convert(messageQueue.Receive(timeSpan, transaction));
+ }
+
+ /// <summary>
+ /// Checks if an MSMQ message matches the selection criteria.
+ /// </summary>
+ /// <param name="message">MSMQ message.</param>
+ /// <return>true if the message matches the selection criteria.</return>
+ public override bool Matches(Message message)
+ {
+ return true;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ANDExpression.cs b/src/main/csharp/Selector/ANDExpression.cs
index 285efe3..976eacc 100644
--- a/src/main/csharp/Selector/ANDExpression.cs
+++ b/src/main/csharp/Selector/ANDExpression.cs
@@ -1,47 +1,46 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a logical AND combination of two expressions.
- /// </summary>
- public class ANDExpression : LogicExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "AND"; }
- }
-
- public ANDExpression(IBooleanExpression left, IBooleanExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
- if(!(bool)lvalue) return false;
-
- object rvalue = Right.Evaluate(message);
- return rvalue == null ? null : rvalue;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a logical AND combination of two expressions.
+ /// </summary>
+ public class ANDExpression : LogicExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "AND"; }
+ }
+
+ public ANDExpression(IBooleanExpression left, IBooleanExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+ if(!(bool)lvalue) return false;
+
+ object rvalue = Right.Evaluate(message);
+ return rvalue == null ? null : rvalue;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/AlignedNumericValues.cs b/src/main/csharp/Selector/AlignedNumericValues.cs
index 96e2eeb..b8bfa50 100644
--- a/src/main/csharp/Selector/AlignedNumericValues.cs
+++ b/src/main/csharp/Selector/AlignedNumericValues.cs
@@ -1,175 +1,174 @@
-using System;
-using System.Globalization;
-using System.Collections.Generic;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A couple of numeric values converted to the type of the largest type.
- /// </summary>
- public class AlignedNumericValues
- {
- private object left;
- public object Left
- {
- get { return left; }
- }
-
- private object right;
- public object Right
- {
- get { return right; }
- }
-
- private T type;
- public T TypeEnum
- {
- get { return type; }
- }
-
- public Type Type
- {
- get { return GetType(type); }
- }
-
- public AlignedNumericValues(object lvalue, object rvalue)
- {
- if(lvalue == null || rvalue == null)
- {
- return;
- }
-
- T ltypeEnum = GetTypeEnum(lvalue);
- T rtypeEnum = GetTypeEnum(rvalue);
-
- type = targetType[(int)ltypeEnum][(int)rtypeEnum];
-
- left = (ltypeEnum == type ? lvalue : ConvertValue(lvalue, type));
- right = (rtypeEnum == type ? rvalue : ConvertValue(rvalue, type));
- }
-
- public enum T
- {
- SByteType = 0, // Signed 8-bit integer (-128 to 127)
- ByteType = 1, // Unsigned 8-bit integer (0 to 255)
- CharType = 2, // Unicode 16-bit character (U+0000 to U+ffff)
- ShortType = 3, // Signed 16-bit integer (-32 768 to 32 767)
- UShortType = 4, // Unsigned 16-bit integer (0 to 65 535)
- IntType = 5, // Signed 32-bit integer (-2 147 483 648 to 2 147 483 647)
- UIntType = 6, // Unsigned 32-bit integer (0 to 4 294 967 295)
- LongType = 7, // Signed 64-bit integer (-9 223 372 036 854 775 808 to 9 223 372 036 854 775 807)
- ULongType = 8, // Unsigned 64-bit integer (0 to 18 446 744 073 709 551 615)
- FloatType = 9, // 7 digits (±1.5e−45 to ±3.4e38)
- DoubleType = 10 // 15-16 digits (±5.0e−324 to ±1.7e308)
- }
-
- private static Dictionary<Type, T> typeEnums
- = new Dictionary<Type, T>
- {
- { typeof(sbyte ), T.SByteType },
- { typeof(byte ), T.ByteType },
- { typeof(char ), T.CharType },
- { typeof(short ), T.ShortType },
- { typeof(ushort), T.UShortType },
- { typeof(int ), T.IntType },
- { typeof(uint ), T.UIntType },
- { typeof(long ), T.LongType },
- { typeof(ulong ), T.ULongType },
- { typeof(float ), T.FloatType },
- { typeof(double), T.DoubleType }
- };
-
- private static T[][] targetType = new T[][]
- {
- // SByteType , ByteType , CharType , ShortType , UShortType, IntType , UIntType , LongType , ULongType , FloatType , DoubleType
- /*SByteType */new T[] { T.SByteType , T.ShortType , T.IntType , T.ShortType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
- /*ByteType */new T[] { T.ShortType , T.ByteType , T.UShortType, T.ShortType , T.UShortType, T.IntType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
- /*CharType */new T[] { T.IntType , T.UShortType, T.CharType , T.IntType , T.UShortType, T.IntType , T.LongType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
- /*ShortType */new T[] { T.ShortType , T.ShortType , T.IntType , T.ShortType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
- /*UShortType*/new T[] { T.IntType , T.UShortType, T.UShortType, T.IntType , T.UShortType, T.IntType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
- /*IntType */new T[] { T.IntType , T.IntType , T.IntType , T.IntType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
- /*UIntType */new T[] { T.LongType , T.UIntType , T.LongType , T.LongType , T.UIntType , T.LongType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
- /*LongType */new T[] { T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
- /*ULongType */new T[] { T.LongType , T.ULongType , T.ULongType , T.LongType , T.ULongType , T.LongType , T.ULongType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
- /*FloatType */new T[] { T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.DoubleType },
- /*DoubleType*/new T[] { T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType }
- };
-
- private T GetTypeEnum(object value)
- {
- return GetTypeEnum(value.GetType());
- }
-
- private T GetTypeEnum(Type type)
- {
- try
- {
- return typeEnums[type];
- }
- catch
- {
- throw new NotSupportedException(
- string.Format("Unsupported data type {0}.", type));
- }
- }
-
- private Type GetType(T typeEnum)
- {
- switch(typeEnum)
- {
- case T.SByteType : return typeof(sbyte );
- case T.ByteType : return typeof(byte );
- case T.CharType : return typeof(char );
- case T.ShortType : return typeof(short );
- case T.UShortType: return typeof(ushort);
- case T.IntType : return typeof(int );
- case T.UIntType : return typeof(uint );
- case T.LongType : return typeof(long );
- case T.ULongType : return typeof(ulong );
- case T.FloatType : return typeof(float );
- case T.DoubleType: return typeof(double);
- default:
- throw new NotSupportedException(
- string.Format("Unsupported data type {0}.", typeEnum));
- }
- }
-
- private object ConvertValue(object value, T targetTypeEnum)
- {
- switch(targetTypeEnum)
- {
- case T.SByteType : return Convert.ToSByte (value);
- case T.ByteType : return Convert.ToByte (value);
- case T.CharType : return Convert.ToChar (value);
- case T.ShortType : return Convert.ToInt16 (value);
- case T.UShortType: return Convert.ToUInt16(value);
- case T.IntType : return Convert.ToInt32 (value);
- case T.UIntType : return Convert.ToUInt32(value);
- case T.LongType : return Convert.ToInt64 (value);
- case T.ULongType : return Convert.ToUInt64(value);
- case T.FloatType : return Convert.ToSingle(value);
- case T.DoubleType: return Convert.ToDouble(value);
- default:
- throw new NotSupportedException(
- string.Format("Unsupported data type {0}.", targetTypeEnum));
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Globalization;
+using System.Collections.Generic;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A couple of numeric values converted to the type of the largest type.
+ /// </summary>
+ public class AlignedNumericValues
+ {
+ private object left;
+ public object Left
+ {
+ get { return left; }
+ }
+
+ private object right;
+ public object Right
+ {
+ get { return right; }
+ }
+
+ private T type;
+ public T TypeEnum
+ {
+ get { return type; }
+ }
+
+ public Type Type
+ {
+ get { return GetType(type); }
+ }
+
+ public AlignedNumericValues(object lvalue, object rvalue)
+ {
+ if(lvalue == null || rvalue == null)
+ {
+ return;
+ }
+
+ T ltypeEnum = GetTypeEnum(lvalue);
+ T rtypeEnum = GetTypeEnum(rvalue);
+
+ type = targetType[(int)ltypeEnum][(int)rtypeEnum];
+
+ left = (ltypeEnum == type ? lvalue : ConvertValue(lvalue, type));
+ right = (rtypeEnum == type ? rvalue : ConvertValue(rvalue, type));
+ }
+
+ public enum T
+ {
+ SByteType = 0, // Signed 8-bit integer (-128 to 127)
+ ByteType = 1, // Unsigned 8-bit integer (0 to 255)
+ CharType = 2, // Unicode 16-bit character (U+0000 to U+ffff)
+ ShortType = 3, // Signed 16-bit integer (-32 768 to 32 767)
+ UShortType = 4, // Unsigned 16-bit integer (0 to 65 535)
+ IntType = 5, // Signed 32-bit integer (-2 147 483 648 to 2 147 483 647)
+ UIntType = 6, // Unsigned 32-bit integer (0 to 4 294 967 295)
+ LongType = 7, // Signed 64-bit integer (-9 223 372 036 854 775 808 to 9 223 372 036 854 775 807)
+ ULongType = 8, // Unsigned 64-bit integer (0 to 18 446 744 073 709 551 615)
+ FloatType = 9, // 7 digits (±1.5e−45 to ±3.4e38)
+ DoubleType = 10 // 15-16 digits (±5.0e−324 to ±1.7e308)
+ }
+
+ private static Dictionary<Type, T> typeEnums
+ = new Dictionary<Type, T>
+ {
+ { typeof(sbyte ), T.SByteType },
+ { typeof(byte ), T.ByteType },
+ { typeof(char ), T.CharType },
+ { typeof(short ), T.ShortType },
+ { typeof(ushort), T.UShortType },
+ { typeof(int ), T.IntType },
+ { typeof(uint ), T.UIntType },
+ { typeof(long ), T.LongType },
+ { typeof(ulong ), T.ULongType },
+ { typeof(float ), T.FloatType },
+ { typeof(double), T.DoubleType }
+ };
+
+ private static T[][] targetType = new T[][]
+ {
+ // SByteType , ByteType , CharType , ShortType , UShortType, IntType , UIntType , LongType , ULongType , FloatType , DoubleType
+ /*SByteType */new T[] { T.SByteType , T.ShortType , T.IntType , T.ShortType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
+ /*ByteType */new T[] { T.ShortType , T.ByteType , T.UShortType, T.ShortType , T.UShortType, T.IntType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
+ /*CharType */new T[] { T.IntType , T.UShortType, T.CharType , T.IntType , T.UShortType, T.IntType , T.LongType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
+ /*ShortType */new T[] { T.ShortType , T.ShortType , T.IntType , T.ShortType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
+ /*UShortType*/new T[] { T.IntType , T.UShortType, T.UShortType, T.IntType , T.UShortType, T.IntType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
+ /*IntType */new T[] { T.IntType , T.IntType , T.IntType , T.IntType , T.IntType , T.IntType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
+ /*UIntType */new T[] { T.LongType , T.UIntType , T.LongType , T.LongType , T.UIntType , T.LongType , T.UIntType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
+ /*LongType */new T[] { T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.LongType , T.FloatType , T.DoubleType },
+ /*ULongType */new T[] { T.LongType , T.ULongType , T.ULongType , T.LongType , T.ULongType , T.LongType , T.ULongType , T.LongType , T.ULongType , T.FloatType , T.DoubleType },
+ /*FloatType */new T[] { T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.FloatType , T.DoubleType },
+ /*DoubleType*/new T[] { T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType, T.DoubleType }
+ };
+
+ private T GetTypeEnum(object value)
+ {
+ return GetTypeEnum(value.GetType());
+ }
+
+ private T GetTypeEnum(Type type)
+ {
+ try
+ {
+ return typeEnums[type];
+ }
+ catch
+ {
+ throw new NotSupportedException(
+ string.Format("Unsupported data type {0}.", type));
+ }
+ }
+
+ private Type GetType(T typeEnum)
+ {
+ switch(typeEnum)
+ {
+ case T.SByteType : return typeof(sbyte );
+ case T.ByteType : return typeof(byte );
+ case T.CharType : return typeof(char );
+ case T.ShortType : return typeof(short );
+ case T.UShortType: return typeof(ushort);
+ case T.IntType : return typeof(int );
+ case T.UIntType : return typeof(uint );
+ case T.LongType : return typeof(long );
+ case T.ULongType : return typeof(ulong );
+ case T.FloatType : return typeof(float );
+ case T.DoubleType: return typeof(double);
+ default:
+ throw new NotSupportedException(
+ string.Format("Unsupported data type {0}.", typeEnum));
+ }
+ }
+
+ private object ConvertValue(object value, T targetTypeEnum)
+ {
+ switch(targetTypeEnum)
+ {
+ case T.SByteType : return Convert.ToSByte (value);
+ case T.ByteType : return Convert.ToByte (value);
+ case T.CharType : return Convert.ToChar (value);
+ case T.ShortType : return Convert.ToInt16 (value);
+ case T.UShortType: return Convert.ToUInt16(value);
+ case T.IntType : return Convert.ToInt32 (value);
+ case T.UIntType : return Convert.ToUInt32(value);
+ case T.LongType : return Convert.ToInt64 (value);
+ case T.ULongType : return Convert.ToUInt64(value);
+ case T.FloatType : return Convert.ToSingle(value);
+ case T.DoubleType: return Convert.ToDouble(value);
+ default:
+ throw new NotSupportedException(
+ string.Format("Unsupported data type {0}.", targetTypeEnum));
+ }
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ArithmeticExpression.cs b/src/main/csharp/Selector/ArithmeticExpression.cs
index a0524ee..0da9129 100644
--- a/src/main/csharp/Selector/ArithmeticExpression.cs
+++ b/src/main/csharp/Selector/ArithmeticExpression.cs
@@ -1,57 +1,56 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which performs an operation on two expression values.
- /// </summary>
- public abstract class ArithmeticExpression : BinaryExpression
- {
- public ArithmeticExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public static IExpression CreatePlus(IExpression left, IExpression right)
- {
- return new PlusExpression(left, right);
- }
-
- public static IExpression CreateMinus(IExpression left, IExpression right)
- {
- return new MinusExpression(left, right);
- }
-
- public static IExpression CreateMultiply(IExpression left, IExpression right)
- {
- return new MultiplyExpression(left, right);
- }
-
- public static IExpression CreateDivide(IExpression left, IExpression right)
- {
- return new DivideExpression(left, right);
- }
-
- public static IExpression CreateMod(IExpression left, IExpression right)
- {
- return new ModExpression(left, right);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which performs an operation on two expression values.
+ /// </summary>
+ public abstract class ArithmeticExpression : BinaryExpression
+ {
+ public ArithmeticExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public static IExpression CreatePlus(IExpression left, IExpression right)
+ {
+ return new PlusExpression(left, right);
+ }
+
+ public static IExpression CreateMinus(IExpression left, IExpression right)
+ {
+ return new MinusExpression(left, right);
+ }
+
+ public static IExpression CreateMultiply(IExpression left, IExpression right)
+ {
+ return new MultiplyExpression(left, right);
+ }
+
+ public static IExpression CreateDivide(IExpression left, IExpression right)
+ {
+ return new DivideExpression(left, right);
+ }
+
+ public static IExpression CreateMod(IExpression left, IExpression right)
+ {
+ return new ModExpression(left, right);
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/BinaryExpression.cs b/src/main/csharp/Selector/BinaryExpression.cs
index 9206f8c..0cb506d 100644
--- a/src/main/csharp/Selector/BinaryExpression.cs
+++ b/src/main/csharp/Selector/BinaryExpression.cs
@@ -1,59 +1,58 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which performs an operation on two expression values.
- /// </summary>
- public abstract class BinaryExpression : IExpression
- {
- protected IExpression leftExpression;
- public IExpression Left
- {
- get { return leftExpression; }
- set { leftExpression = value; }
- }
-
- protected IExpression rightExpression;
- public IExpression Right
- {
- get { return rightExpression; }
- set { rightExpression = value; }
- }
-
- protected abstract string ExpressionSymbol
- {
- get;
- }
-
- public BinaryExpression(IExpression left, IExpression right)
- {
- leftExpression = left;
- rightExpression = right;
- }
-
- public abstract object Evaluate(MessageEvaluationContext message);
-
- public override string ToString()
- {
- return "(" + leftExpression.ToString() + " " + ExpressionSymbol + " " + rightExpression.ToString() + ")";
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which performs an operation on two expression values.
+ /// </summary>
+ public abstract class BinaryExpression : IExpression
+ {
+ protected IExpression leftExpression;
+ public IExpression Left
+ {
+ get { return leftExpression; }
+ set { leftExpression = value; }
+ }
+
+ protected IExpression rightExpression;
+ public IExpression Right
+ {
+ get { return rightExpression; }
+ set { rightExpression = value; }
+ }
+
+ protected abstract string ExpressionSymbol
+ {
+ get;
+ }
+
+ public BinaryExpression(IExpression left, IExpression right)
+ {
+ leftExpression = left;
+ rightExpression = right;
+ }
+
+ public abstract object Evaluate(MessageEvaluationContext message);
+
+ public override string ToString()
+ {
+ return "(" + leftExpression.ToString() + " " + ExpressionSymbol + " " + rightExpression.ToString() + ")";
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/BooleanCastExpression.cs b/src/main/csharp/Selector/BooleanCastExpression.cs
index 26a6e9e..ea5bf05 100644
--- a/src/main/csharp/Selector/BooleanCastExpression.cs
+++ b/src/main/csharp/Selector/BooleanCastExpression.cs
@@ -1,45 +1,44 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which casts an expression value to a boolean.
- /// </summary>
- public class BooleanCastExpression : BooleanUnaryExpression
- {
- protected override string ExpressionSymbol
- {
- get { return ""; }
- }
-
- public BooleanCastExpression(IExpression left)
- : base(left)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = Right.Evaluate(message);
- if(rvalue == null ) return null;
- if(rvalue is bool ) return (bool)rvalue;
- return false;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which casts an expression value to a boolean.
+ /// </summary>
+ public class BooleanCastExpression : BooleanUnaryExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return ""; }
+ }
+
+ public BooleanCastExpression(IExpression left)
+ : base(left)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null ) return null;
+ if(rvalue is bool ) return (bool)rvalue;
+ return false;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/BooleanConstantExpression.cs b/src/main/csharp/Selector/BooleanConstantExpression.cs
index eb6447a..1859436 100644
--- a/src/main/csharp/Selector/BooleanConstantExpression.cs
+++ b/src/main/csharp/Selector/BooleanConstantExpression.cs
@@ -1,38 +1,37 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// Represents a boolean constant expression.
- /// </summary>
- public class BooleanConstantExpression : ConstantExpression, IBooleanExpression
- {
- public BooleanConstantExpression(object value)
- : base(value)
- {
- }
-
- public bool Matches(MessageEvaluationContext message)
- {
- object value = Evaluate(message);
- return value != null && (bool)value;
- }
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// Represents a boolean constant expression.
+ /// </summary>
+ public class BooleanConstantExpression : ConstantExpression, IBooleanExpression
+ {
+ public BooleanConstantExpression(object value)
+ : base(value)
+ {
+ }
+
+ public bool Matches(MessageEvaluationContext message)
+ {
+ object value = Evaluate(message);
+ return value != null && (bool)value;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/csharp/Selector/BooleanUnaryExpression.cs b/src/main/csharp/Selector/BooleanUnaryExpression.cs
index 3873050..00489d5 100644
--- a/src/main/csharp/Selector/BooleanUnaryExpression.cs
+++ b/src/main/csharp/Selector/BooleanUnaryExpression.cs
@@ -1,39 +1,38 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which performs an operation on one expression value
- /// and returns a boolean value.
- /// </summary>
- public abstract class BooleanUnaryExpression : UnaryExpression, IBooleanExpression
- {
- public BooleanUnaryExpression(IExpression left)
- : base(left)
- {
- }
-
- public bool Matches(MessageEvaluationContext message)
- {
- object value = Evaluate(message);
- return value != null && (bool)value;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which performs an operation on one expression value
+ /// and returns a boolean value.
+ /// </summary>
+ public abstract class BooleanUnaryExpression : UnaryExpression, IBooleanExpression
+ {
+ public BooleanUnaryExpression(IExpression left)
+ : base(left)
+ {
+ }
+
+ public bool Matches(MessageEvaluationContext message)
+ {
+ object value = Evaluate(message);
+ return value != null && (bool)value;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ComparisonExpression.cs b/src/main/csharp/Selector/ComparisonExpression.cs
index 4024271..ca9a9fe 100644
--- a/src/main/csharp/Selector/ComparisonExpression.cs
+++ b/src/main/csharp/Selector/ComparisonExpression.cs
@@ -1,162 +1,161 @@
-using System;
-using System.Collections;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a comparison of two or more expressions or objects.
- /// </summary>
- public abstract class ComparisonExpression : BinaryExpression, IBooleanExpression
- {
- public ComparisonExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- object rvalue = Right.Evaluate(message);
-
- int? compared = null;
-
- if(lvalue == null || rvalue == null)
- {
- if(lvalue == null && rvalue == null)
- {
- compared = 0;
- }
- }
- else
- {
- if(lvalue == rvalue)
- {
- compared = 0;
- }
- else if(lvalue is string && rvalue is string)
- {
- compared = ((string)lvalue).CompareTo(rvalue);
- }
- else
- {
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : compared = ((sbyte )values.Left).CompareTo((sbyte )values.Right); break;
- case AlignedNumericValues.T.ByteType : compared = ((byte )values.Left).CompareTo((byte )values.Right); break;
- case AlignedNumericValues.T.CharType : compared = ((char )values.Left).CompareTo((char )values.Right); break;
- case AlignedNumericValues.T.ShortType : compared = ((short )values.Left).CompareTo((short )values.Right); break;
- case AlignedNumericValues.T.UShortType: compared = ((ushort)values.Left).CompareTo((ushort)values.Right); break;
- case AlignedNumericValues.T.IntType : compared = ((int )values.Left).CompareTo((int )values.Right); break;
- case AlignedNumericValues.T.UIntType : compared = ((uint )values.Left).CompareTo((uint )values.Right); break;
- case AlignedNumericValues.T.LongType : compared = ((long )values.Left).CompareTo((long )values.Right); break;
- case AlignedNumericValues.T.ULongType : compared = ((ulong )values.Left).CompareTo((ulong )values.Right); break;
- case AlignedNumericValues.T.FloatType : compared = ((float )values.Left).CompareTo((float )values.Right); break;
- case AlignedNumericValues.T.DoubleType: compared = ((double)values.Left).CompareTo((double)values.Right); break;
- }
- }
- }
-
- return AsBoolean(compared);
- }
-
- public abstract bool AsBoolean(int? compared);
-
- public bool Matches(MessageEvaluationContext message)
- {
- object value = Evaluate(message);
- return value != null && (bool)value;
- }
-
- // Equality expressions
- public static IBooleanExpression CreateEqual(IExpression left, IExpression right)
- {
- return new EqualExpression(left, right, true);
- }
-
- public static IBooleanExpression CreateNotEqual(IExpression left, IExpression right)
- {
- return new EqualExpression(left, right, false);
- }
-
- public static IBooleanExpression CreateIsNull(IExpression left)
- {
- return new IsNullExpression(left, true);
- }
-
- public static IBooleanExpression CreateIsNotNull(IExpression left)
- {
- return new IsNullExpression(left, false);
- }
-
- // Binary comparison expressions
- public static IBooleanExpression CreateGreaterThan(IExpression left, IExpression right)
- {
- return new GreaterExpression(left, right);
- }
-
- public static IBooleanExpression CreateGreaterThanOrEqual(IExpression left, IExpression right)
- {
- return new GreaterOrEqualExpression(left, right);
- }
-
- public static IBooleanExpression CreateLesserThan(IExpression left, IExpression right)
- {
- return new LesserExpression(left, right);
- }
-
- public static IBooleanExpression CreateLesserThanOrEqual(IExpression left, IExpression right)
- {
- return new LesserOrEqualExpression(left, right);
- }
-
- // Other comparison expressions
- public static IBooleanExpression CreateLike(IExpression left, string right, string escape)
- {
- return new LikeExpression(left, right, escape, true);
- }
-
- public static IBooleanExpression CreateNotLike(IExpression left, string right, string escape)
- {
- return new LikeExpression(left, right, escape, false);
- }
-
- public static IBooleanExpression CreateBetween(IExpression value, IExpression left, IExpression right)
- {
- return LogicExpression.CreateAND(CreateGreaterThanOrEqual(value, left), CreateLesserThanOrEqual(value, right));
- }
-
- public static IBooleanExpression CreateNotBetween(IExpression value, IExpression left, IExpression right)
- {
- return LogicExpression.CreateOR(CreateLesserThan(value, left), CreateGreaterThan(value, right));
- }
-
- public static IBooleanExpression CreateIn(IExpression left, ArrayList elements)
- {
- return new InExpression(left, elements, true);
- }
-
- public static IBooleanExpression CreateNotIn(IExpression left, ArrayList elements)
- {
- return new InExpression(left, elements, false);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Collections;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a comparison of two or more expressions or objects.
+ /// </summary>
+ public abstract class ComparisonExpression : BinaryExpression, IBooleanExpression
+ {
+ public ComparisonExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ object rvalue = Right.Evaluate(message);
+
+ int? compared = null;
+
+ if(lvalue == null || rvalue == null)
+ {
+ if(lvalue == null && rvalue == null)
+ {
+ compared = 0;
+ }
+ }
+ else
+ {
+ if(lvalue == rvalue)
+ {
+ compared = 0;
+ }
+ else if(lvalue is string && rvalue is string)
+ {
+ compared = ((string)lvalue).CompareTo(rvalue);
+ }
+ else
+ {
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : compared = ((sbyte )values.Left).CompareTo((sbyte )values.Right); break;
+ case AlignedNumericValues.T.ByteType : compared = ((byte )values.Left).CompareTo((byte )values.Right); break;
+ case AlignedNumericValues.T.CharType : compared = ((char )values.Left).CompareTo((char )values.Right); break;
+ case AlignedNumericValues.T.ShortType : compared = ((short )values.Left).CompareTo((short )values.Right); break;
+ case AlignedNumericValues.T.UShortType: compared = ((ushort)values.Left).CompareTo((ushort)values.Right); break;
+ case AlignedNumericValues.T.IntType : compared = ((int )values.Left).CompareTo((int )values.Right); break;
+ case AlignedNumericValues.T.UIntType : compared = ((uint )values.Left).CompareTo((uint )values.Right); break;
+ case AlignedNumericValues.T.LongType : compared = ((long )values.Left).CompareTo((long )values.Right); break;
+ case AlignedNumericValues.T.ULongType : compared = ((ulong )values.Left).CompareTo((ulong )values.Right); break;
+ case AlignedNumericValues.T.FloatType : compared = ((float )values.Left).CompareTo((float )values.Right); break;
+ case AlignedNumericValues.T.DoubleType: compared = ((double)values.Left).CompareTo((double)values.Right); break;
+ }
+ }
+ }
+
+ return AsBoolean(compared);
+ }
+
+ public abstract bool AsBoolean(int? compared);
+
+ public bool Matches(MessageEvaluationContext message)
+ {
+ object value = Evaluate(message);
+ return value != null && (bool)value;
+ }
+
+ // Equality expressions
+ public static IBooleanExpression CreateEqual(IExpression left, IExpression right)
+ {
+ return new EqualExpression(left, right, true);
+ }
+
+ public static IBooleanExpression CreateNotEqual(IExpression left, IExpression right)
+ {
+ return new EqualExpression(left, right, false);
+ }
+
+ public static IBooleanExpression CreateIsNull(IExpression left)
+ {
+ return new IsNullExpression(left, true);
+ }
+
+ public static IBooleanExpression CreateIsNotNull(IExpression left)
+ {
+ return new IsNullExpression(left, false);
+ }
+
+ // Binary comparison expressions
+ public static IBooleanExpression CreateGreaterThan(IExpression left, IExpression right)
+ {
+ return new GreaterExpression(left, right);
+ }
+
+ public static IBooleanExpression CreateGreaterThanOrEqual(IExpression left, IExpression right)
+ {
+ return new GreaterOrEqualExpression(left, right);
+ }
+
+ public static IBooleanExpression CreateLesserThan(IExpression left, IExpression right)
+ {
+ return new LesserExpression(left, right);
+ }
+
+ public static IBooleanExpression CreateLesserThanOrEqual(IExpression left, IExpression right)
+ {
+ return new LesserOrEqualExpression(left, right);
+ }
+
+ // Other comparison expressions
+ public static IBooleanExpression CreateLike(IExpression left, string right, string escape)
+ {
+ return new LikeExpression(left, right, escape, true);
+ }
+
+ public static IBooleanExpression CreateNotLike(IExpression left, string right, string escape)
+ {
+ return new LikeExpression(left, right, escape, false);
+ }
+
+ public static IBooleanExpression CreateBetween(IExpression value, IExpression left, IExpression right)
+ {
+ return LogicExpression.CreateAND(CreateGreaterThanOrEqual(value, left), CreateLesserThanOrEqual(value, right));
+ }
+
+ public static IBooleanExpression CreateNotBetween(IExpression value, IExpression left, IExpression right)
+ {
+ return LogicExpression.CreateOR(CreateLesserThan(value, left), CreateGreaterThan(value, right));
+ }
+
+ public static IBooleanExpression CreateIn(IExpression left, ArrayList elements)
+ {
+ return new InExpression(left, elements, true);
+ }
+
+ public static IBooleanExpression CreateNotIn(IExpression left, ArrayList elements)
+ {
+ return new InExpression(left, elements, false);
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ConstantExpression.cs b/src/main/csharp/Selector/ConstantExpression.cs
index 90dfd69..b71683d 100644
--- a/src/main/csharp/Selector/ConstantExpression.cs
+++ b/src/main/csharp/Selector/ConstantExpression.cs
@@ -1,157 +1,156 @@
-using System;
-using System.Text;
-using System.Globalization;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// Represents a constant expression.
- /// </summary>
- public class ConstantExpression : IExpression
- {
- private object value;
- public object Value
- {
- get { return value; }
- }
-
- public ConstantExpression(object value)
- {
- this.value = value;
- }
-
- public static ConstantExpression CreateFromDecimal(string text)
- {
- // Long integer specified ?
- object value;
- if(text.EndsWith("l") || text.EndsWith("L"))
- {
- text = text.Substring(0, text.Length - 1);
- value = Int64.Parse(text, CultureInfo.InvariantCulture);
- }
- else
- {
- long lvalue = Int64.Parse(text, CultureInfo.InvariantCulture);
- if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
- {
- value = (int)lvalue;
- }
- else
- {
- value = lvalue;
- }
- }
- return new ConstantExpression(value);
- }
-
- public static ConstantExpression CreateFromHex(string text)
- {
- long lvalue = Convert.ToInt64(text.Substring(2), 16);
-
- object value;
- if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
- {
- value = (int)lvalue;
- }
- else
- {
- value = lvalue;
- }
- return new ConstantExpression(value);
- }
-
-
- public static ConstantExpression CreateFromOctal(string text)
- {
- long lvalue = Convert.ToInt64(text, 8);
-
- object value;
- if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
- {
- value = (int)lvalue;
- }
- else
- {
- value = lvalue;
- }
- return new ConstantExpression(value);
- }
-
- public static ConstantExpression CreateFloat(string text)
- {
- double value = Double.Parse(text, CultureInfo.InvariantCulture);
- return new ConstantExpression(value);
- }
-
- public object Evaluate(MessageEvaluationContext message)
- {
- return value;
- }
-
- public override string ToString()
- {
- if(value == null)
- {
- return "NULL";
- }
- if(value is bool)
- {
- return (bool)value ? "TRUE" : "FALSE";
- }
- if(value is string)
- {
- return EncodeString((string)value);
- }
- return value.ToString();
- }
-
- public override int GetHashCode()
- {
- return (value == null ? 0 : value.GetHashCode());
- }
-
- /// <summary>
- /// Encodes the value of string so that it looks like it would look like
- /// when it was provided in a selector.
- /// </summary>
- /// <param name="s">String to be encoded.</param>
- /// <return>Encoded string.</return>
- public static string EncodeString(string s)
- {
- StringBuilder b = new StringBuilder();
- b.Append('\'');
- for(int c = 0; c < s.Length; c++)
- {
- char ch = s[c];
- if(ch == '\'')
- {
- b.Append(ch);
- }
- b.Append(ch);
- }
- b.Append('\'');
- return b.ToString();
- }
-
- public static readonly BooleanConstantExpression NULL = new BooleanConstantExpression(null);
- public static readonly BooleanConstantExpression TRUE = new BooleanConstantExpression(true);
- public static readonly BooleanConstantExpression FALSE = new BooleanConstantExpression(false);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Text;
+using System.Globalization;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// Represents a constant expression.
+ /// </summary>
+ public class ConstantExpression : IExpression
+ {
+ private object value;
+ public object Value
+ {
+ get { return value; }
+ }
+
+ public ConstantExpression(object value)
+ {
+ this.value = value;
+ }
+
+ public static ConstantExpression CreateFromDecimal(string text)
+ {
+ // Long integer specified ?
+ object value;
+ if(text.EndsWith("l") || text.EndsWith("L"))
+ {
+ text = text.Substring(0, text.Length - 1);
+ value = Int64.Parse(text, CultureInfo.InvariantCulture);
+ }
+ else
+ {
+ long lvalue = Int64.Parse(text, CultureInfo.InvariantCulture);
+ if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
+ {
+ value = (int)lvalue;
+ }
+ else
+ {
+ value = lvalue;
+ }
+ }
+ return new ConstantExpression(value);
+ }
+
+ public static ConstantExpression CreateFromHex(string text)
+ {
+ long lvalue = Convert.ToInt64(text.Substring(2), 16);
+
+ object value;
+ if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
+ {
+ value = (int)lvalue;
+ }
+ else
+ {
+ value = lvalue;
+ }
+ return new ConstantExpression(value);
+ }
+
+
+ public static ConstantExpression CreateFromOctal(string text)
+ {
+ long lvalue = Convert.ToInt64(text, 8);
+
+ object value;
+ if(lvalue >= Int32.MinValue && lvalue <= Int32.MaxValue)
+ {
+ value = (int)lvalue;
+ }
+ else
+ {
+ value = lvalue;
+ }
+ return new ConstantExpression(value);
+ }
+
+ public static ConstantExpression CreateFloat(string text)
+ {
+ double value = Double.Parse(text, CultureInfo.InvariantCulture);
+ return new ConstantExpression(value);
+ }
+
+ public object Evaluate(MessageEvaluationContext message)
+ {
+ return value;
+ }
+
+ public override string ToString()
+ {
+ if(value == null)
+ {
+ return "NULL";
+ }
+ if(value is bool)
+ {
+ return (bool)value ? "TRUE" : "FALSE";
+ }
+ if(value is string)
+ {
+ return EncodeString((string)value);
+ }
+ return value.ToString();
+ }
+
+ public override int GetHashCode()
+ {
+ return (value == null ? 0 : value.GetHashCode());
+ }
+
+ /// <summary>
+ /// Encodes the value of string so that it looks like it would look like
+ /// when it was provided in a selector.
+ /// </summary>
+ /// <param name="s">String to be encoded.</param>
+ /// <return>Encoded string.</return>
+ public static string EncodeString(string s)
+ {
+ StringBuilder b = new StringBuilder();
+ b.Append('\'');
+ for(int c = 0; c < s.Length; c++)
+ {
+ char ch = s[c];
+ if(ch == '\'')
+ {
+ b.Append(ch);
+ }
+ b.Append(ch);
+ }
+ b.Append('\'');
+ return b.ToString();
+ }
+
+ public static readonly BooleanConstantExpression NULL = new BooleanConstantExpression(null);
+ public static readonly BooleanConstantExpression TRUE = new BooleanConstantExpression(true);
+ public static readonly BooleanConstantExpression FALSE = new BooleanConstantExpression(false);
+ }
}
\ No newline at end of file
diff --git a/src/main/csharp/Selector/DivideExpression.cs b/src/main/csharp/Selector/DivideExpression.cs
index e280ec8..63f13aa 100644
--- a/src/main/csharp/Selector/DivideExpression.cs
+++ b/src/main/csharp/Selector/DivideExpression.cs
@@ -1,67 +1,66 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a division of two expressions.
- /// </summary>
- public class DivideExpression : ArithmeticExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "/"; }
- }
-
- public DivideExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
-
- object rvalue = Right.Evaluate(message);
- if(rvalue == null) return null;
-
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- object result = null;
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left / (sbyte )values.Right; break;
- case AlignedNumericValues.T.ByteType : result = (byte )values.Left / (byte )values.Right; break;
- case AlignedNumericValues.T.CharType : result = (char )values.Left / (char )values.Right; break;
- case AlignedNumericValues.T.ShortType : result = (short )values.Left / (short )values.Right; break;
- case AlignedNumericValues.T.UShortType: result = (ushort)values.Left / (ushort)values.Right; break;
- case AlignedNumericValues.T.IntType : result = (int )values.Left / (int )values.Right; break;
- case AlignedNumericValues.T.UIntType : result = (uint )values.Left / (uint )values.Right; break;
- case AlignedNumericValues.T.LongType : result = (long )values.Left / (long )values.Right; break;
- case AlignedNumericValues.T.ULongType : result = (ulong )values.Left / (ulong )values.Right; break;
- case AlignedNumericValues.T.FloatType : result = (float )values.Left / (float )values.Right; break;
- case AlignedNumericValues.T.DoubleType: result = (double)values.Left / (double)values.Right; break;
- }
-
- return result;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a division of two expressions.
+ /// </summary>
+ public class DivideExpression : ArithmeticExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "/"; }
+ }
+
+ public DivideExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null) return null;
+
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ object result = null;
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left / (sbyte )values.Right; break;
+ case AlignedNumericValues.T.ByteType : result = (byte )values.Left / (byte )values.Right; break;
+ case AlignedNumericValues.T.CharType : result = (char )values.Left / (char )values.Right; break;
+ case AlignedNumericValues.T.ShortType : result = (short )values.Left / (short )values.Right; break;
+ case AlignedNumericValues.T.UShortType: result = (ushort)values.Left / (ushort)values.Right; break;
+ case AlignedNumericValues.T.IntType : result = (int )values.Left / (int )values.Right; break;
+ case AlignedNumericValues.T.UIntType : result = (uint )values.Left / (uint )values.Right; break;
+ case AlignedNumericValues.T.LongType : result = (long )values.Left / (long )values.Right; break;
+ case AlignedNumericValues.T.ULongType : result = (ulong )values.Left / (ulong )values.Right; break;
+ case AlignedNumericValues.T.FloatType : result = (float )values.Left / (float )values.Right; break;
+ case AlignedNumericValues.T.DoubleType: result = (double)values.Left / (double)values.Right; break;
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/EqualExpression.cs b/src/main/csharp/Selector/EqualExpression.cs
index 0e9a792..af48080 100644
--- a/src/main/csharp/Selector/EqualExpression.cs
+++ b/src/main/csharp/Selector/EqualExpression.cs
@@ -1,47 +1,46 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing an equality or inequality comparison
- /// of two expressions.
- /// </summary>
- public class EqualExpression : ComparisonExpression
- {
- private bool notNot;
-
- protected override string ExpressionSymbol
- {
- get { return notNot ? "=" : "<>"; }
- }
-
- public EqualExpression(IExpression left, IExpression right, bool notNot)
- : base(left, right)
- {
- this.notNot = notNot;
- }
-
- public override bool AsBoolean(int? compared)
- {
- bool answer = (compared.HasValue ? compared.Value == 0 : false);
- return notNot ? answer : !answer;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing an equality or inequality comparison
+ /// of two expressions.
+ /// </summary>
+ public class EqualExpression : ComparisonExpression
+ {
+ private bool notNot;
+
+ protected override string ExpressionSymbol
+ {
+ get { return notNot ? "=" : "<>"; }
+ }
+
+ public EqualExpression(IExpression left, IExpression right, bool notNot)
+ : base(left, right)
+ {
+ this.notNot = notNot;
+ }
+
+ public override bool AsBoolean(int? compared)
+ {
+ bool answer = (compared.HasValue ? compared.Value == 0 : false);
+ return notNot ? answer : !answer;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/GreaterExpression.cs b/src/main/csharp/Selector/GreaterExpression.cs
index eb264e5..012f3fb 100644
--- a/src/main/csharp/Selector/GreaterExpression.cs
+++ b/src/main/csharp/Selector/GreaterExpression.cs
@@ -1,42 +1,41 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a greater than comparison of two expressions.
- /// </summary>
- public class GreaterExpression : ComparisonExpression
- {
- protected override string ExpressionSymbol
- {
- get { return ">"; }
- }
-
- public GreaterExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override bool AsBoolean(int? compared)
- {
- return compared.HasValue ? compared.Value > 0 : false;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a greater than comparison of two expressions.
+ /// </summary>
+ public class GreaterExpression : ComparisonExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return ">"; }
+ }
+
+ public GreaterExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override bool AsBoolean(int? compared)
+ {
+ return compared.HasValue ? compared.Value > 0 : false;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/GreaterOrEqualExpression.cs b/src/main/csharp/Selector/GreaterOrEqualExpression.cs
index 7a456f8..df8cc6f 100644
--- a/src/main/csharp/Selector/GreaterOrEqualExpression.cs
+++ b/src/main/csharp/Selector/GreaterOrEqualExpression.cs
@@ -1,43 +1,42 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a greater than or equal comparison
- /// of two expressions.
- /// </summary>
- public class GreaterOrEqualExpression : ComparisonExpression
- {
- protected override string ExpressionSymbol
- {
- get { return ">="; }
- }
-
- public GreaterOrEqualExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override bool AsBoolean(int? compared)
- {
- return compared.HasValue ? compared.Value >= 0 : false;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a greater than or equal comparison
+ /// of two expressions.
+ /// </summary>
+ public class GreaterOrEqualExpression : ComparisonExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return ">="; }
+ }
+
+ public GreaterOrEqualExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override bool AsBoolean(int? compared)
+ {
+ return compared.HasValue ? compared.Value >= 0 : false;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/IBooleanExpression.cs b/src/main/csharp/Selector/IBooleanExpression.cs
index af6c0f5..bf5a833 100644
--- a/src/main/csharp/Selector/IBooleanExpression.cs
+++ b/src/main/csharp/Selector/IBooleanExpression.cs
@@ -1,35 +1,34 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An IBooleanExpression is an expression that always
- /// produces a boolean result.
- /// </summary>
- public interface IBooleanExpression : IExpression
- {
- /// <summary>
- /// Checks if expression evaluates to <c>true</c>.
- /// </summary>
- /// <param name="message">Evaluation context.</param>
- /// <return><c>true</c> if the expression evaluates to <c>true</c>.</return>
- bool Matches(MessageEvaluationContext message);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An IBooleanExpression is an expression that always
+ /// produces a boolean result.
+ /// </summary>
+ public interface IBooleanExpression : IExpression
+ {
+ /// <summary>
+ /// Checks if expression evaluates to <c>true</c>.
+ /// </summary>
+ /// <param name="message">Evaluation context.</param>
+ /// <return><c>true</c> if the expression evaluates to <c>true</c>.</return>
+ bool Matches(MessageEvaluationContext message);
+ }
+}
diff --git a/src/main/csharp/Selector/IExpression.cs b/src/main/csharp/Selector/IExpression.cs
index 30fb893..833c6b5 100644
--- a/src/main/csharp/Selector/IExpression.cs
+++ b/src/main/csharp/Selector/IExpression.cs
@@ -1,35 +1,34 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// Represents an expression
- /// </summary>
- public interface IExpression
- {
- /// <summary>
- /// Evaluates the expression.
- /// </summary>
- /// <param name="message">Evaluation context.</param>
- /// <return>The result of the evaluation.</return>
- object Evaluate(MessageEvaluationContext message);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// Represents an expression
+ /// </summary>
+ public interface IExpression
+ {
+ /// <summary>
+ /// Evaluates the expression.
+ /// </summary>
+ /// <param name="message">Evaluation context.</param>
+ /// <return>The result of the evaluation.</return>
+ object Evaluate(MessageEvaluationContext message);
+ }
+}
\ No newline at end of file
diff --git a/src/main/csharp/Selector/InExpression.cs b/src/main/csharp/Selector/InExpression.cs
index cd2d7ea..cbf3e60 100644
--- a/src/main/csharp/Selector/InExpression.cs
+++ b/src/main/csharp/Selector/InExpression.cs
@@ -1,98 +1,97 @@
-using System;
-using System.Text;
-using System.Collections;
-using System.Collections.Generic;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A boolean expression which checks if an expression value is
- /// contained in a list of defined values.
- /// </summary>
- public class InExpression : BooleanUnaryExpression
- {
- private bool notNot;
- private ArrayList elements;
- private HashSet<string> hashset;
-
- protected override string ExpressionSymbol
- {
- get { return notNot ? "IN" : "NOT IN"; }
- }
-
- public InExpression(IExpression right, ArrayList elements, bool notNot)
- : base(right)
- {
- this.notNot = notNot;
-
- this.elements = elements;
- this.hashset = new HashSet<string>();
-
- foreach(object element in elements)
- {
- hashset.Add((string)element);
- }
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = Right.Evaluate(message);
-
- bool answer = false;
- if(rvalue != null && (rvalue is string))
- {
- answer = hashset.Contains((string)rvalue);
- }
-
- return notNot ? answer : !answer;
- }
-
- public override string ToString()
- {
- StringBuilder answer = new StringBuilder();
- answer.Append(Right);
- answer.Append(" ");
- answer.Append(ExpressionSymbol);
- answer.Append(" (");
-
- for(int i = 0; i < elements.Count; i++)
- {
- if(i > 0) answer.Append(", ");
-
- string s = (string)elements[i];
-
- answer.Append('\'');
- for(int c = 0; c < s.Length; c++)
- {
- char ch = s[c];
- if(ch == '\'')
- {
- answer.Append(ch);
- }
- answer.Append(ch);
- }
- answer.Append('\'');
- }
-
- answer.Append(")");
- return answer.ToString();
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Text;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A boolean expression which checks if an expression value is
+ /// contained in a list of defined values.
+ /// </summary>
+ public class InExpression : BooleanUnaryExpression
+ {
+ private bool notNot;
+ private ArrayList elements;
+ private HashSet<string> hashset;
+
+ protected override string ExpressionSymbol
+ {
+ get { return notNot ? "IN" : "NOT IN"; }
+ }
+
+ public InExpression(IExpression right, ArrayList elements, bool notNot)
+ : base(right)
+ {
+ this.notNot = notNot;
+
+ this.elements = elements;
+ this.hashset = new HashSet<string>();
+
+ foreach(object element in elements)
+ {
+ hashset.Add((string)element);
+ }
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = Right.Evaluate(message);
+
+ bool answer = false;
+ if(rvalue != null && (rvalue is string))
+ {
+ answer = hashset.Contains((string)rvalue);
+ }
+
+ return notNot ? answer : !answer;
+ }
+
+ public override string ToString()
+ {
+ StringBuilder answer = new StringBuilder();
+ answer.Append(Right);
+ answer.Append(" ");
+ answer.Append(ExpressionSymbol);
+ answer.Append(" (");
+
+ for(int i = 0; i < elements.Count; i++)
+ {
+ if(i > 0) answer.Append(", ");
+
+ string s = (string)elements[i];
+
+ answer.Append('\'');
+ for(int c = 0; c < s.Length; c++)
+ {
+ char ch = s[c];
+ if(ch == '\'')
+ {
+ answer.Append(ch);
+ }
+ answer.Append(ch);
+ }
+ answer.Append('\'');
+ }
+
+ answer.Append(")");
+ return answer.ToString();
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/IsNullExpression.cs b/src/main/csharp/Selector/IsNullExpression.cs
index 28d89a2..6ad0436 100644
--- a/src/main/csharp/Selector/IsNullExpression.cs
+++ b/src/main/csharp/Selector/IsNullExpression.cs
@@ -1,59 +1,58 @@
-using System;
-using System.Text;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A boolean expression which checks if an expression value is null.
- /// </summary>
- public class IsNullExpression : BooleanUnaryExpression
- {
- private bool notNot;
-
- protected override string ExpressionSymbol
- {
- get { return notNot ? "IS NULL" : "IS NOT NULL"; }
- }
-
- public IsNullExpression(IExpression right, bool notNot)
- : base(right)
- {
- this.notNot = notNot;
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = Right.Evaluate(message);
-
- bool answer = (rvalue == null || rvalue == ConstantExpression.NULL);
-
- return notNot ? answer : !answer;
- }
-
- public override string ToString()
- {
- StringBuilder answer = new StringBuilder();
- answer.Append(Right);
- answer.Append(" ");
- answer.Append(ExpressionSymbol);
- return answer.ToString();
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Text;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A boolean expression which checks if an expression value is null.
+ /// </summary>
+ public class IsNullExpression : BooleanUnaryExpression
+ {
+ private bool notNot;
+
+ protected override string ExpressionSymbol
+ {
+ get { return notNot ? "IS NULL" : "IS NOT NULL"; }
+ }
+
+ public IsNullExpression(IExpression right, bool notNot)
+ : base(right)
+ {
+ this.notNot = notNot;
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = Right.Evaluate(message);
+
+ bool answer = (rvalue == null || rvalue == ConstantExpression.NULL);
+
+ return notNot ? answer : !answer;
+ }
+
+ public override string ToString()
+ {
+ StringBuilder answer = new StringBuilder();
+ answer.Append(Right);
+ answer.Append(" ");
+ answer.Append(ExpressionSymbol);
+ return answer.ToString();
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/LesserExpression.cs b/src/main/csharp/Selector/LesserExpression.cs
index 4be2c9d..24b707b 100644
--- a/src/main/csharp/Selector/LesserExpression.cs
+++ b/src/main/csharp/Selector/LesserExpression.cs
@@ -1,42 +1,41 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a lesser than comparison of two expressions.
- /// </summary>
- public class LesserExpression : ComparisonExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "<"; }
- }
-
- public LesserExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override bool AsBoolean(int? compared)
- {
- return compared.HasValue ? compared.Value < 0 : false;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a lesser than comparison of two expressions.
+ /// </summary>
+ public class LesserExpression : ComparisonExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "<"; }
+ }
+
+ public LesserExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override bool AsBoolean(int? compared)
+ {
+ return compared.HasValue ? compared.Value < 0 : false;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/LesserOrEqualExpression.cs b/src/main/csharp/Selector/LesserOrEqualExpression.cs
index abdc7e5..f4a99db 100644
--- a/src/main/csharp/Selector/LesserOrEqualExpression.cs
+++ b/src/main/csharp/Selector/LesserOrEqualExpression.cs
@@ -1,43 +1,42 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a lesser than or equal comparison
- /// of two expressions.
- /// </summary>
- public class LesserOrEqualExpression : ComparisonExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "<="; }
- }
-
- public LesserOrEqualExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override bool AsBoolean(int? compared)
- {
- return compared.HasValue ? compared.Value <= 0 : false;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a lesser than or equal comparison
+ /// of two expressions.
+ /// </summary>
+ public class LesserOrEqualExpression : ComparisonExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "<="; }
+ }
+
+ public LesserOrEqualExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override bool AsBoolean(int? compared)
+ {
+ return compared.HasValue ? compared.Value <= 0 : false;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/LikeExpression.cs b/src/main/csharp/Selector/LikeExpression.cs
index 8317bd6..41be1bd 100644
--- a/src/main/csharp/Selector/LikeExpression.cs
+++ b/src/main/csharp/Selector/LikeExpression.cs
@@ -1,124 +1,123 @@
-using System;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Globalization;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a string matching comparison.
- /// </summary>
- public class LikeExpression : BooleanUnaryExpression
- {
- private bool notNot;
- private Regex pattern;
-
- protected override string ExpressionSymbol
- {
- get { return notNot ? "LIKE" : "NOT LIKE"; }
- }
-
- public LikeExpression(IExpression left, string like, string escape, bool notNot)
- : base(left)
- {
- this.notNot = notNot;
-
- bool doEscape = false;
- char escapeChar = '%';
-
- if(escape != null)
- {
- if(escape.Length != 1)
- {
- throw new ApplicationException("The ESCAPE string litteral is invalid. It can only be one character. Litteral used: " + escape);
- }
- doEscape = true;
- escapeChar = escape[0];
- }
-
- StringBuilder temp = new StringBuilder();
- StringBuilder regexp = new StringBuilder(like.Length * 2);
- regexp.Append("^"); // The beginning of the input
- for(int c = 0; c < like.Length; c++)
- {
- char ch = like[c];
- if(doEscape && (ch == escapeChar))
- {
- c++;
- if(c >= like.Length)
- {
- // nothing left to escape...
- break;
- }
- temp.Append(like[c]);
- }
- else if(ch == '%')
- {
- if(temp.Length > 0)
- {
- regexp.Append(Regex.Escape(temp.ToString()));
- temp.Length = 0;
- }
- regexp.Append(".*?"); // Do a non-greedy match
- }
- else if(c == '_')
- {
- if(temp.Length > 0)
- {
- regexp.Append(Regex.Escape(temp.ToString()));
- temp.Length = 0;
- }
- regexp.Append("."); // match one
- }
- else
- {
- temp.Append(ch);
- }
- }
- if(temp.Length > 0)
- {
- regexp.Append(Regex.Escape(temp.ToString()));
- }
- regexp.Append("$"); // The end of the input
-
- pattern = new Regex(regexp.ToString(), RegexOptions.Singleline | RegexOptions.Compiled);
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = this.Right.Evaluate(message);
-
- bool answer = false;
- if(rvalue != null)
- {
- if(rvalue is string)
- {
- answer = pattern.IsMatch((string)rvalue);
- }
- else
- {
- //throw new ApplicationException("LIKE can only operate on string identifiers. LIKE attemped on " + rvalue.GetType().ToString());
- }
- }
-
- return notNot ? answer : !answer;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Globalization;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a string matching comparison.
+ /// </summary>
+ public class LikeExpression : BooleanUnaryExpression
+ {
+ private bool notNot;
+ private Regex pattern;
+
+ protected override string ExpressionSymbol
+ {
+ get { return notNot ? "LIKE" : "NOT LIKE"; }
+ }
+
+ public LikeExpression(IExpression left, string like, string escape, bool notNot)
+ : base(left)
+ {
+ this.notNot = notNot;
+
+ bool doEscape = false;
+ char escapeChar = '%';
+
+ if(escape != null)
+ {
+ if(escape.Length != 1)
+ {
+ throw new ApplicationException("The ESCAPE string litteral is invalid. It can only be one character. Litteral used: " + escape);
+ }
+ doEscape = true;
+ escapeChar = escape[0];
+ }
+
+ StringBuilder temp = new StringBuilder();
+ StringBuilder regexp = new StringBuilder(like.Length * 2);
+ regexp.Append("^"); // The beginning of the input
+ for(int c = 0; c < like.Length; c++)
+ {
+ char ch = like[c];
+ if(doEscape && (ch == escapeChar))
+ {
+ c++;
+ if(c >= like.Length)
+ {
+ // nothing left to escape...
+ break;
+ }
+ temp.Append(like[c]);
+ }
+ else if(ch == '%')
+ {
+ if(temp.Length > 0)
+ {
+ regexp.Append(Regex.Escape(temp.ToString()));
+ temp.Length = 0;
+ }
+ regexp.Append(".*?"); // Do a non-greedy match
+ }
+ else if(c == '_')
+ {
+ if(temp.Length > 0)
+ {
+ regexp.Append(Regex.Escape(temp.ToString()));
+ temp.Length = 0;
+ }
+ regexp.Append("."); // match one
+ }
+ else
+ {
+ temp.Append(ch);
+ }
+ }
+ if(temp.Length > 0)
+ {
+ regexp.Append(Regex.Escape(temp.ToString()));
+ }
+ regexp.Append("$"); // The end of the input
+
+ pattern = new Regex(regexp.ToString(), RegexOptions.Singleline | RegexOptions.Compiled);
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = this.Right.Evaluate(message);
+
+ bool answer = false;
+ if(rvalue != null)
+ {
+ if(rvalue is string)
+ {
+ answer = pattern.IsMatch((string)rvalue);
+ }
+ else
+ {
+ //throw new ApplicationException("LIKE can only operate on string identifiers. LIKE attemped on " + rvalue.GetType().ToString());
+ }
+ }
+
+ return notNot ? answer : !answer;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/LogicExpression.cs b/src/main/csharp/Selector/LogicExpression.cs
index 61617a4..8e60fb0 100644
--- a/src/main/csharp/Selector/LogicExpression.cs
+++ b/src/main/csharp/Selector/LogicExpression.cs
@@ -1,48 +1,47 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a logical combination of two objects.
- /// </summary>
- public abstract class LogicExpression : BinaryExpression, IBooleanExpression
- {
- public LogicExpression(IBooleanExpression left, IBooleanExpression right)
- : base(left, right)
- {
- }
-
- public bool Matches(MessageEvaluationContext message)
- {
- object value = Evaluate(message);
- return value != null && (bool)value;
- }
-
- public static IBooleanExpression CreateOR(IBooleanExpression left, IBooleanExpression right)
- {
- return new ORExpression(left, right);
- }
-
- public static IBooleanExpression CreateAND(IBooleanExpression left, IBooleanExpression right)
- {
- return new ANDExpression(left, right);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a logical combination of two objects.
+ /// </summary>
+ public abstract class LogicExpression : BinaryExpression, IBooleanExpression
+ {
+ public LogicExpression(IBooleanExpression left, IBooleanExpression right)
+ : base(left, right)
+ {
+ }
+
+ public bool Matches(MessageEvaluationContext message)
+ {
+ object value = Evaluate(message);
+ return value != null && (bool)value;
+ }
+
+ public static IBooleanExpression CreateOR(IBooleanExpression left, IBooleanExpression right)
+ {
+ return new ORExpression(left, right);
+ }
+
+ public static IBooleanExpression CreateAND(IBooleanExpression left, IBooleanExpression right)
+ {
+ return new ANDExpression(left, right);
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/MessageEvaluationContext.cs b/src/main/csharp/Selector/MessageEvaluationContext.cs
index 054d911..6f26d0f 100644
--- a/src/main/csharp/Selector/MessageEvaluationContext.cs
+++ b/src/main/csharp/Selector/MessageEvaluationContext.cs
@@ -1,78 +1,77 @@
-using System;
-using Apache.NMS;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// MessageEvaluationContext is used to cache selection results.
- ///
- /// A message usually has multiple selectors applied against it. Some selector
- /// have a high cost of evaluating against the message. Those selectors may whish
- /// to cache evaluation results associated with the message in the
- /// MessageEvaluationContext.
- /// </summary>
- public class MessageEvaluationContext
- {
- private IMessage nmsMessage;
- public IMessage Message
- {
- get { return nmsMessage; }
- set { nmsMessage = value; }
- }
-
- public MessageEvaluationContext(IMessage message)
- {
- nmsMessage = message;
- }
-
- public object GetProperty(string name)
- {
- if(name.Length > 3 &&
- string.Compare(name.Substring(0, 3), "JMS", true) == 0)
- {
- if(string.Compare(name, "JMSCorrelationID", true) == 0)
- {
- return nmsMessage.NMSCorrelationID;
- }
- if(string.Compare(name, "JMSMessageID", true) == 0)
- {
- return nmsMessage.NMSMessageId;
- }
- if(string.Compare(name, "JMSPriority", true) == 0)
- {
- return nmsMessage.NMSPriority;
- }
- if(string.Compare(name, "JMSTimestamp", true) == 0)
- {
- return nmsMessage.NMSTimestamp;
- }
- if(string.Compare(name, "JMSType", true) == 0)
- {
- return nmsMessage.NMSType;
- }
- if(string.Compare(name, "JMSDeliveryMode", true) == 0)
- {
- return nmsMessage.NMSDeliveryMode;
- }
- }
- return nmsMessage.Properties[name];
- }
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using Apache.NMS;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// MessageEvaluationContext is used to cache selection results.
+ ///
+ /// A message usually has multiple selectors applied against it. Some selector
+ /// have a high cost of evaluating against the message. Those selectors may whish
+ /// to cache evaluation results associated with the message in the
+ /// MessageEvaluationContext.
+ /// </summary>
+ public class MessageEvaluationContext
+ {
+ private IMessage nmsMessage;
+ public IMessage Message
+ {
+ get { return nmsMessage; }
+ set { nmsMessage = value; }
+ }
+
+ public MessageEvaluationContext(IMessage message)
+ {
+ nmsMessage = message;
+ }
+
+ public object GetProperty(string name)
+ {
+ if(name.Length > 3 &&
+ string.Compare(name.Substring(0, 3), "JMS", true) == 0)
+ {
+ if(string.Compare(name, "JMSCorrelationID", true) == 0)
+ {
+ return nmsMessage.NMSCorrelationID;
+ }
+ if(string.Compare(name, "JMSMessageID", true) == 0)
+ {
+ return nmsMessage.NMSMessageId;
+ }
+ if(string.Compare(name, "JMSPriority", true) == 0)
+ {
+ return nmsMessage.NMSPriority;
+ }
+ if(string.Compare(name, "JMSTimestamp", true) == 0)
+ {
+ return nmsMessage.NMSTimestamp;
+ }
+ if(string.Compare(name, "JMSType", true) == 0)
+ {
+ return nmsMessage.NMSType;
+ }
+ if(string.Compare(name, "JMSDeliveryMode", true) == 0)
+ {
+ return nmsMessage.NMSDeliveryMode;
+ }
+ }
+ return nmsMessage.Properties[name];
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/csharp/Selector/MinusExpression.cs b/src/main/csharp/Selector/MinusExpression.cs
index 260e5e8..b2bc845 100644
--- a/src/main/csharp/Selector/MinusExpression.cs
+++ b/src/main/csharp/Selector/MinusExpression.cs
@@ -1,67 +1,66 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a substraction of two expressions.
- /// </summary>
- public class MinusExpression : ArithmeticExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "-"; }
- }
-
- public MinusExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
-
- object rvalue = Right.Evaluate(message);
- if(rvalue == null) return null;
-
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- object result = null;
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left - (sbyte )values.Right; break;
- case AlignedNumericValues.T.ByteType : result = (byte )values.Left - (byte )values.Right; break;
- case AlignedNumericValues.T.CharType : result = (char )values.Left - (char )values.Right; break;
- case AlignedNumericValues.T.ShortType : result = (short )values.Left - (short )values.Right; break;
- case AlignedNumericValues.T.UShortType: result = (ushort)values.Left - (ushort)values.Right; break;
- case AlignedNumericValues.T.IntType : result = (int )values.Left - (int )values.Right; break;
- case AlignedNumericValues.T.UIntType : result = (uint )values.Left - (uint )values.Right; break;
- case AlignedNumericValues.T.LongType : result = (long )values.Left - (long )values.Right; break;
- case AlignedNumericValues.T.ULongType : result = (ulong )values.Left - (ulong )values.Right; break;
- case AlignedNumericValues.T.FloatType : result = (float )values.Left - (float )values.Right; break;
- case AlignedNumericValues.T.DoubleType: result = (double)values.Left - (double)values.Right; break;
- }
-
- return result;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a substraction of two expressions.
+ /// </summary>
+ public class MinusExpression : ArithmeticExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "-"; }
+ }
+
+ public MinusExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null) return null;
+
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ object result = null;
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left - (sbyte )values.Right; break;
+ case AlignedNumericValues.T.ByteType : result = (byte )values.Left - (byte )values.Right; break;
+ case AlignedNumericValues.T.CharType : result = (char )values.Left - (char )values.Right; break;
+ case AlignedNumericValues.T.ShortType : result = (short )values.Left - (short )values.Right; break;
+ case AlignedNumericValues.T.UShortType: result = (ushort)values.Left - (ushort)values.Right; break;
+ case AlignedNumericValues.T.IntType : result = (int )values.Left - (int )values.Right; break;
+ case AlignedNumericValues.T.UIntType : result = (uint )values.Left - (uint )values.Right; break;
+ case AlignedNumericValues.T.LongType : result = (long )values.Left - (long )values.Right; break;
+ case AlignedNumericValues.T.ULongType : result = (ulong )values.Left - (ulong )values.Right; break;
+ case AlignedNumericValues.T.FloatType : result = (float )values.Left - (float )values.Right; break;
+ case AlignedNumericValues.T.DoubleType: result = (double)values.Left - (double)values.Right; break;
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ModExpression.cs b/src/main/csharp/Selector/ModExpression.cs
index 386c08d..0ed5234 100644
--- a/src/main/csharp/Selector/ModExpression.cs
+++ b/src/main/csharp/Selector/ModExpression.cs
@@ -1,67 +1,66 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a modulo of two expressions.
- /// </summary>
- public class ModExpression : ArithmeticExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "%"; }
- }
-
- public ModExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
-
- object rvalue = Right.Evaluate(message);
- if(rvalue == null) return null;
-
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- object result = null;
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left % (sbyte )values.Right; break;
- case AlignedNumericValues.T.ByteType : result = (byte )values.Left % (byte )values.Right; break;
- case AlignedNumericValues.T.CharType : result = (char )values.Left % (char )values.Right; break;
- case AlignedNumericValues.T.ShortType : result = (short )values.Left % (short )values.Right; break;
- case AlignedNumericValues.T.UShortType: result = (ushort)values.Left % (ushort)values.Right; break;
- case AlignedNumericValues.T.IntType : result = (int )values.Left % (int )values.Right; break;
- case AlignedNumericValues.T.UIntType : result = (uint )values.Left % (uint )values.Right; break;
- case AlignedNumericValues.T.LongType : result = (long )values.Left % (long )values.Right; break;
- case AlignedNumericValues.T.ULongType : result = (ulong )values.Left % (ulong )values.Right; break;
- case AlignedNumericValues.T.FloatType : result = (float )values.Left % (float )values.Right; break;
- case AlignedNumericValues.T.DoubleType: result = (double)values.Left % (double)values.Right; break;
- }
-
- return result;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a modulo of two expressions.
+ /// </summary>
+ public class ModExpression : ArithmeticExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "%"; }
+ }
+
+ public ModExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null) return null;
+
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ object result = null;
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left % (sbyte )values.Right; break;
+ case AlignedNumericValues.T.ByteType : result = (byte )values.Left % (byte )values.Right; break;
+ case AlignedNumericValues.T.CharType : result = (char )values.Left % (char )values.Right; break;
+ case AlignedNumericValues.T.ShortType : result = (short )values.Left % (short )values.Right; break;
+ case AlignedNumericValues.T.UShortType: result = (ushort)values.Left % (ushort)values.Right; break;
+ case AlignedNumericValues.T.IntType : result = (int )values.Left % (int )values.Right; break;
+ case AlignedNumericValues.T.UIntType : result = (uint )values.Left % (uint )values.Right; break;
+ case AlignedNumericValues.T.LongType : result = (long )values.Left % (long )values.Right; break;
+ case AlignedNumericValues.T.ULongType : result = (ulong )values.Left % (ulong )values.Right; break;
+ case AlignedNumericValues.T.FloatType : result = (float )values.Left % (float )values.Right; break;
+ case AlignedNumericValues.T.DoubleType: result = (double)values.Left % (double)values.Right; break;
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/MultiplyExpression.cs b/src/main/csharp/Selector/MultiplyExpression.cs
index 0009092..130783f 100644
--- a/src/main/csharp/Selector/MultiplyExpression.cs
+++ b/src/main/csharp/Selector/MultiplyExpression.cs
@@ -1,67 +1,66 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a multiplication of two expressions.
- /// </summary>
- public class MultiplyExpression : ArithmeticExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "*"; }
- }
-
- public MultiplyExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
-
- object rvalue = Right.Evaluate(message);
- if(rvalue == null) return null;
-
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- object result = null;
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left * (sbyte )values.Right; break;
- case AlignedNumericValues.T.ByteType : result = (byte )values.Left * (byte )values.Right; break;
- case AlignedNumericValues.T.CharType : result = (char )values.Left * (char )values.Right; break;
- case AlignedNumericValues.T.ShortType : result = (short )values.Left * (short )values.Right; break;
- case AlignedNumericValues.T.UShortType: result = (ushort)values.Left * (ushort)values.Right; break;
- case AlignedNumericValues.T.IntType : result = (int )values.Left * (int )values.Right; break;
- case AlignedNumericValues.T.UIntType : result = (uint )values.Left * (uint )values.Right; break;
- case AlignedNumericValues.T.LongType : result = (long )values.Left * (long )values.Right; break;
- case AlignedNumericValues.T.ULongType : result = (ulong )values.Left * (ulong )values.Right; break;
- case AlignedNumericValues.T.FloatType : result = (float )values.Left * (float )values.Right; break;
- case AlignedNumericValues.T.DoubleType: result = (double)values.Left * (double)values.Right; break;
- }
-
- return result;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a multiplication of two expressions.
+ /// </summary>
+ public class MultiplyExpression : ArithmeticExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "*"; }
+ }
+
+ public MultiplyExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null) return null;
+
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ object result = null;
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left * (sbyte )values.Right; break;
+ case AlignedNumericValues.T.ByteType : result = (byte )values.Left * (byte )values.Right; break;
+ case AlignedNumericValues.T.CharType : result = (char )values.Left * (char )values.Right; break;
+ case AlignedNumericValues.T.ShortType : result = (short )values.Left * (short )values.Right; break;
+ case AlignedNumericValues.T.UShortType: result = (ushort)values.Left * (ushort)values.Right; break;
+ case AlignedNumericValues.T.IntType : result = (int )values.Left * (int )values.Right; break;
+ case AlignedNumericValues.T.UIntType : result = (uint )values.Left * (uint )values.Right; break;
+ case AlignedNumericValues.T.LongType : result = (long )values.Left * (long )values.Right; break;
+ case AlignedNumericValues.T.ULongType : result = (ulong )values.Left * (ulong )values.Right; break;
+ case AlignedNumericValues.T.FloatType : result = (float )values.Left * (float )values.Right; break;
+ case AlignedNumericValues.T.DoubleType: result = (double)values.Left * (double)values.Right; break;
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/NOTExpression.cs b/src/main/csharp/Selector/NOTExpression.cs
index 6d6ef55..a8b1c33 100644
--- a/src/main/csharp/Selector/NOTExpression.cs
+++ b/src/main/csharp/Selector/NOTExpression.cs
@@ -1,45 +1,44 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which negates a boolean expression value.
- /// </summary>
- public class NOTExpression : BooleanUnaryExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "NOT"; }
- }
-
- public NOTExpression(IExpression left)
- : base(left)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = Right.Evaluate(message);
- if(rvalue == null ) return null;
- if(rvalue is bool ) return !(bool)rvalue;
- return null;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which negates a boolean expression value.
+ /// </summary>
+ public class NOTExpression : BooleanUnaryExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "NOT"; }
+ }
+
+ public NOTExpression(IExpression left)
+ : base(left)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null ) return null;
+ if(rvalue is bool ) return !(bool)rvalue;
+ return null;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/NegateExpression.cs b/src/main/csharp/Selector/NegateExpression.cs
index 0496b6f..f074590 100644
--- a/src/main/csharp/Selector/NegateExpression.cs
+++ b/src/main/csharp/Selector/NegateExpression.cs
@@ -1,51 +1,50 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// An expression which negates a numeric expression value.
- /// </summary>
- public class NegateExpression : UnaryExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "-"; }
- }
-
- public NegateExpression(IExpression left)
- : base(left)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object rvalue = Right.Evaluate(message);
- if(rvalue == null ) return null;
- if(rvalue is int ) return -(int )rvalue;
- if(rvalue is long ) return -(long )rvalue;
- if(rvalue is double ) return -(double )rvalue;
- if(rvalue is float ) return -(float )rvalue;
- if(rvalue is decimal) return -(decimal)rvalue;
- if(rvalue is short ) return -(short )rvalue;
- if(rvalue is byte ) return -(byte )rvalue;
- return null;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// An expression which negates a numeric expression value.
+ /// </summary>
+ public class NegateExpression : UnaryExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "-"; }
+ }
+
+ public NegateExpression(IExpression left)
+ : base(left)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object rvalue = Right.Evaluate(message);
+ if(rvalue == null ) return null;
+ if(rvalue is int ) return -(int )rvalue;
+ if(rvalue is long ) return -(long )rvalue;
+ if(rvalue is double ) return -(double )rvalue;
+ if(rvalue is float ) return -(float )rvalue;
+ if(rvalue is decimal) return -(decimal)rvalue;
+ if(rvalue is short ) return -(short )rvalue;
+ if(rvalue is byte ) return -(byte )rvalue;
+ return null;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ORExpression.cs b/src/main/csharp/Selector/ORExpression.cs
index 86648bc..b2ed7f3 100644
--- a/src/main/csharp/Selector/ORExpression.cs
+++ b/src/main/csharp/Selector/ORExpression.cs
@@ -1,46 +1,45 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing a logical OR combination of two expressions.
- /// </summary>
- public class ORExpression : LogicExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "OR"; }
- }
-
- public ORExpression(IBooleanExpression left, IBooleanExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue != null && (bool)lvalue) return true;
-
- object rvalue = Right.Evaluate(message);
- return rvalue == null ? null : rvalue;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing a logical OR combination of two expressions.
+ /// </summary>
+ public class ORExpression : LogicExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "OR"; }
+ }
+
+ public ORExpression(IBooleanExpression left, IBooleanExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue != null && (bool)lvalue) return true;
+
+ object rvalue = Right.Evaluate(message);
+ return rvalue == null ? null : rvalue;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/ParseException.cs b/src/main/csharp/Selector/ParseException.cs
index f1b6d60..17706e1 100644
--- a/src/main/csharp/Selector/ParseException.cs
+++ b/src/main/csharp/Selector/ParseException.cs
@@ -1,197 +1,197 @@
-/* Generated By:CSharpCC: Do not edit this line. ParseException.cs Version 3.2 */
-/// <summary>
-/// This exception is thrown when parse errors are encountered.
-/// </summary>
-/// <remarks>
-/// You can explicitly create objects of this exception type by
-/// calling the method GenerateParseException in the generated
-/// parser.
-/// <para>
-/// You can modify this class to customize your error reporting
-/// mechanisms so long as you retain the public fields.
-/// </para>
-/// </remarks>
-public class ParseException : System.Exception {
-
- /**
- * This constructor is used by the method "GenerateParseException"
- * in the generated parser. Calling this constructor generates
- * a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set. The boolean
- * flag "specialConstructor" is also set to true to indicate that
- * this constructor was used to create this object.
- * This constructor calls its super class with the empty string
- * to force the "toString" method of parent class "Throwable" to
- * print the error message in the form:
- * ParseException: result of getMessage
- */
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal,
- string[] tokenImageVal
- ) : base("") {
- specialConstructor = true;
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- tokenImage = tokenImageVal;
- }
-
- /**
- * The following constructors are for use by you for whatever
- * purpose you can think of. Constructing the exception in this
- * manner makes the exception behave in the normal way - i.e., as
- * documented in the class "Exception". The fields "errorToken",
- * "expectedTokenSequences", and "tokenImage" do not contain
- * relevant information. The CSharpCC generated code does not use
- * these constructors.
- */
-
- public ParseException() :
- base() {
- specialConstructor = false;
- }
-
- public ParseException(string message) :
- base(message) {
- specialConstructor = false;
- }
-
- /**
- * This variable determines which constructor was used to create
- * this object and thereby affects the semantics of the
- * "getMessage" method (see below).
- */
- protected bool specialConstructor;
-
- /**
- * This is the last token that has been consumed successfully. If
- * this object has been created due to a parse error, the token
- * followng this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers. Each array
- * of integers represents a sequence of tokens (by their ordinal
- * values) that is expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * This is a reference to the "tokenImage" array of the generated
- * parser within which the parse error occurred. This array is
- * defined in the generated ...Constants interface.
- */
- public string[] tokenImage;
-
- /**
- * This method has the standard behavior when this object has been
- * created using the standard constructors. Otherwise, it uses
- * "currentToken" and "expectedTokenSequences" to generate a parse
- * error message and returns it. If this object has been created
- * due to a parse error, and you do not catch it (it gets thrown
- * from the parser), then this method is called during the printing
- * of the final stack trace, and hence the correct error message
- * gets displayed.
- */
- public override string Message {
- get {
- if (!specialConstructor) {
- return base.Message;
- }
- string expected = "";
- int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.Length; i++) {
- if (maxSize < expectedTokenSequences[i].Length) {
- maxSize = expectedTokenSequences[i].Length;
- }
- for (int j = 0; j < expectedTokenSequences[i].Length; j++) {
- expected += tokenImage[expectedTokenSequences[i][j]] + " ";
- }
- if (expectedTokenSequences[i][expectedTokenSequences[i].Length - 1] != 0) {
- expected += "...";
- }
- expected += eol + " ";
- }
- string retval = "Encountered \"";
- Token tok = currentToken.next;
- for (int i = 0; i < maxSize; i++) {
- if (i != 0) retval += " ";
- if (tok.kind == 0) {
- retval += tokenImage[0];
- break;
- }
- retval += AddEscapes(tok.image);
- tok = tok.next;
- }
- if (currentToken.next.kind == 0) {
- retval += "\" after line ";
- } else {
- retval += "\" at line ";
- }
- retval += currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
- retval += "." + eol;
- if (expectedTokenSequences.Length == 1) {
- retval += "Was expecting:" + eol + " ";
- } else {
- retval += "Was expecting one of:" + eol + " ";
- }
- retval += expected;
- return retval;
- }
- }
-
- /**
- * The end of line string for this machine.
- */
- protected string eol = System.Environment.NewLine;
-
- /**
- * Used to convert raw characters to their escaped version
- * when these raw version cannot be used as part of an ASCII
- * string literal.
- */
- protected string AddEscapes(string str) {
- System.Text.StringBuilder retval = new System.Text.StringBuilder();
- char ch;
- for (int i = 0; i < str.Length; i++) {
- switch (str[i]) {
- case '\0' :
- continue;
- case '\b':
- retval.Append("\\b");
- continue;
- case '\t':
- retval.Append("\\t");
- continue;
- case '\n':
- retval.Append("\\n");
- continue;
- case '\f':
- retval.Append("\\f");
- continue;
- case '\r':
- retval.Append("\\r");
- continue;
- case '\"':
- retval.Append("\\\"");
- continue;
- case '\'':
- retval.Append("\\\'");
- continue;
- case '\\':
- retval.Append("\\\\");
- continue;
- default:
- if ((ch = str[i]) < 0x20 || ch > 0x7e) {
- string s = "0000" + System.Convert.ToString((int)ch, 16);
- retval.Append("\\u" + s.Substring(s.Length - 4, s.Length - (s.Length - 4)));
- } else {
- retval.Append(ch);
- }
- continue;
- }
- }
- return retval.ToString();
- }
-
-}
+/* Generated By:CSharpCC: Do not edit this line. ParseException.cs Version 3.2 */
+/// <summary>
+/// This exception is thrown when parse errors are encountered.
+/// </summary>
+/// <remarks>
+/// You can explicitly create objects of this exception type by
+/// calling the method GenerateParseException in the generated
+/// parser.
+/// <para>
+/// You can modify this class to customize your error reporting
+/// mechanisms so long as you retain the public fields.
+/// </para>
+/// </remarks>
+public class ParseException : System.Exception {
+
+ /**
+ * This constructor is used by the method "GenerateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: result of getMessage
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ string[] tokenImageVal
+ ) : base("") {
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Exception". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The CSharpCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() :
+ base() {
+ specialConstructor = false;
+ }
+
+ public ParseException(string message) :
+ base(message) {
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected bool specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public string[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public override string Message {
+ get {
+ if (!specialConstructor) {
+ return base.Message;
+ }
+ string expected = "";
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.Length; i++) {
+ if (maxSize < expectedTokenSequences[i].Length) {
+ maxSize = expectedTokenSequences[i].Length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].Length; j++) {
+ expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].Length - 1] != 0) {
+ expected += "...";
+ }
+ expected += eol + " ";
+ }
+ string retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += AddEscapes(tok.image);
+ tok = tok.next;
+ }
+ if (currentToken.next.kind == 0) {
+ retval += "\" after line ";
+ } else {
+ retval += "\" at line ";
+ }
+ retval += currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.Length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected;
+ return retval;
+ }
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected string eol = System.Environment.NewLine;
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected string AddEscapes(string str) {
+ System.Text.StringBuilder retval = new System.Text.StringBuilder();
+ char ch;
+ for (int i = 0; i < str.Length; i++) {
+ switch (str[i]) {
+ case '\0' :
+ continue;
+ case '\b':
+ retval.Append("\\b");
+ continue;
+ case '\t':
+ retval.Append("\\t");
+ continue;
+ case '\n':
+ retval.Append("\\n");
+ continue;
+ case '\f':
+ retval.Append("\\f");
+ continue;
+ case '\r':
+ retval.Append("\\r");
+ continue;
+ case '\"':
+ retval.Append("\\\"");
+ continue;
+ case '\'':
+ retval.Append("\\\'");
+ continue;
+ case '\\':
+ retval.Append("\\\\");
+ continue;
+ default:
+ if ((ch = str[i]) < 0x20 || ch > 0x7e) {
+ string s = "0000" + System.Convert.ToString((int)ch, 16);
+ retval.Append("\\u" + s.Substring(s.Length - 4, s.Length - (s.Length - 4)));
+ } else {
+ retval.Append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.ToString();
+ }
+
+}
diff --git a/src/main/csharp/Selector/PlusExpression.cs b/src/main/csharp/Selector/PlusExpression.cs
index 450b653..b966765 100644
--- a/src/main/csharp/Selector/PlusExpression.cs
+++ b/src/main/csharp/Selector/PlusExpression.cs
@@ -1,68 +1,67 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// A filter performing an addition of two expressions.
- /// </summary>
- public class PlusExpression : ArithmeticExpression
- {
- protected override string ExpressionSymbol
- {
- get { return "+"; }
- }
-
- public PlusExpression(IExpression left, IExpression right)
- : base(left, right)
- {
- }
-
- public override object Evaluate(MessageEvaluationContext message)
- {
- object lvalue = Left.Evaluate(message);
- if(lvalue == null) return null;
-
- object rvalue = Right.Evaluate(message);
- if(lvalue is string) return (string)lvalue + rvalue;
- if(rvalue == null) return null;
-
- AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
-
- object result = null;
-
- switch(values.TypeEnum)
- {
- case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left + (sbyte )values.Right; break;
- case AlignedNumericValues.T.ByteType : result = (byte )values.Left + (byte )values.Right; break;
- case AlignedNumericValues.T.CharType : result = (char )values.Left + (char )values.Right; break;
- case AlignedNumericValues.T.ShortType : result = (short )values.Left + (short )values.Right; break;
- case AlignedNumericValues.T.UShortType: result = (ushort)values.Left + (ushort)values.Right; break;
- case AlignedNumericValues.T.IntType : result = (int )values.Left + (int )values.Right; break;
- case AlignedNumericValues.T.UIntType : result = (uint )values.Left + (uint )values.Right; break;
- case AlignedNumericValues.T.LongType : result = (long )values.Left + (long )values.Right; break;
- case AlignedNumericValues.T.ULongType : result = (ulong )values.Left + (ulong )values.Right; break;
- case AlignedNumericValues.T.FloatType : result = (float )values.Left + (float )values.Right; break;
- case AlignedNumericValues.T.DoubleType: result = (double)values.Left + (double)values.Right; break;
- }
-
- return result;
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// A filter performing an addition of two expressions.
+ /// </summary>
+ public class PlusExpression : ArithmeticExpression
+ {
+ protected override string ExpressionSymbol
+ {
+ get { return "+"; }
+ }
+
+ public PlusExpression(IExpression left, IExpression right)
+ : base(left, right)
+ {
+ }
+
+ public override object Evaluate(MessageEvaluationContext message)
+ {
+ object lvalue = Left.Evaluate(message);
+ if(lvalue == null) return null;
+
+ object rvalue = Right.Evaluate(message);
+ if(lvalue is string) return (string)lvalue + rvalue;
+ if(rvalue == null) return null;
+
+ AlignedNumericValues values = new AlignedNumericValues(lvalue, rvalue);
+
+ object result = null;
+
+ switch(values.TypeEnum)
+ {
+ case AlignedNumericValues.T.SByteType : result = (sbyte )values.Left + (sbyte )values.Right; break;
+ case AlignedNumericValues.T.ByteType : result = (byte )values.Left + (byte )values.Right; break;
+ case AlignedNumericValues.T.CharType : result = (char )values.Left + (char )values.Right; break;
+ case AlignedNumericValues.T.ShortType : result = (short )values.Left + (short )values.Right; break;
+ case AlignedNumericValues.T.UShortType: result = (ushort)values.Left + (ushort)values.Right; break;
+ case AlignedNumericValues.T.IntType : result = (int )values.Left + (int )values.Right; break;
+ case AlignedNumericValues.T.UIntType : result = (uint )values.Left + (uint )values.Right; break;
+ case AlignedNumericValues.T.LongType : result = (long )values.Left + (long )values.Right; break;
+ case AlignedNumericValues.T.ULongType : result = (ulong )values.Left + (ulong )values.Right; break;
+ case AlignedNumericValues.T.FloatType : result = (float )values.Left + (float )values.Right; break;
+ case AlignedNumericValues.T.DoubleType: result = (double)values.Left + (double)values.Right; break;
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/PropertyExpression.cs b/src/main/csharp/Selector/PropertyExpression.cs
index 8d00757..0cd5c47 100644
--- a/src/main/csharp/Selector/PropertyExpression.cs
+++ b/src/main/csharp/Selector/PropertyExpression.cs
@@ -1,53 +1,52 @@
-using System;
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// Represents a property expression.
- /// </summary>
- public class PropertyExpression : IExpression
- {
- private string name;
- public string Name
- {
- get { return name; }
- }
-
- public PropertyExpression(string name)
- {
- this.name = name;
- }
-
- public object Evaluate(MessageEvaluationContext message)
- {
- return message.GetProperty(name);
- }
-
- public override string ToString()
- {
- return name;
- }
-
- public override int GetHashCode()
- {
- return name.GetHashCode();
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// Represents a property expression.
+ /// </summary>
+ public class PropertyExpression : IExpression
+ {
+ private string name;
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public PropertyExpression(string name)
+ {
+ this.name = name;
+ }
+
+ public object Evaluate(MessageEvaluationContext message)
+ {
+ return message.GetProperty(name);
+ }
+
+ public override string ToString()
+ {
+ return name;
+ }
+
+ public override int GetHashCode()
+ {
+ return name.GetHashCode();
+ }
+ }
+}
diff --git a/src/main/csharp/Selector/SelectorParser.cs b/src/main/csharp/Selector/SelectorParser.cs
index 92226ac..efb05f5 100644
--- a/src/main/csharp/Selector/SelectorParser.cs
+++ b/src/main/csharp/Selector/SelectorParser.cs
@@ -1,1172 +1,1171 @@
-/* Generated By:CSharpCC: Do not edit this line. SelectorParser.cs */
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-using System;
-using System.IO;
-using System.Text;
-using System.Collections;
-
-using Apache.NMS;
-
-namespace Apache.NMS.Selector
-{
- /// <summary>
- /// JMS Selector Parser generated by <a href="https://github.com/deveel/csharpcc">CSharpCC</a>
- ///
- /// Do not edit this .cs file directly - it is autogenerated from SelectorParser.csc
- /// using <c>csharpcc.exe -UNICODE_INPUT=true SelectorParser.csc</c>.
- ///
- /// SelectorParser.csc is adapted from
- /// <a href="https://raw.githubusercontent.com/apache/activemq/activemq-4.0/activemq-core/src/main/grammar/SelectorParser.jj">
- /// ActiveMQ 4.0 SelectorParser.jj</a>
- /// </summary>
- public class SelectorParser : SelectorParserConstants {
-
- public SelectorParser()
- : this(new StringReader(""))
- {
- }
-
- public IBooleanExpression Parse(string selector)
- {
- this.ReInit(new StringReader(selector));
-
- try
- {
- return this.JmsSelector();
- }
- catch(Exception e)
- {
- throw new InvalidSelectorException(selector, e);
- }
- }
-
- private IBooleanExpression AsBooleanExpression(IExpression value)
- {
- if(value is IBooleanExpression)
- {
- return (IBooleanExpression)value;
- }
- if(value is PropertyExpression)
- {
- return UnaryExpression.CreateBooleanCast(value);
- }
- throw new ParseException("IExpression will not result in a boolean value: " + value);
- }
-
-// ----------------------------------------------------------------------------
-// Grammar
-// ----------------------------------------------------------------------------
- public IBooleanExpression JmsSelector() {
- IExpression left = null;
- left = GetOrExpression();
- {return AsBooleanExpression(left);}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetOrExpression() {
- IExpression left;
- IExpression right;
- left = GetAndExpression();
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case OR:
- ;
- break;
- default:
- goto label_1;
- }
- mcc_consume_token(OR);
- right = GetAndExpression();
- left = LogicExpression.CreateOR(AsBooleanExpression(left), AsBooleanExpression(right));
- }label_1: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetAndExpression() {
- IExpression left;
- IExpression right;
- left = GetEqualityExpression();
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case AND:
- ;
- break;
- default:
- goto label_2;
- }
- mcc_consume_token(AND);
- right = GetEqualityExpression();
- left = LogicExpression.CreateAND(AsBooleanExpression(left), AsBooleanExpression(right));
- }label_2: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetEqualityExpression() {
- IExpression left;
- IExpression right;
- left = GetComparisonExpression();
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case IS:
- case 28:
- case 29:
- ;
- break;
- default:
- goto label_3;
- }
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 28:
- mcc_consume_token(28);
- right = GetComparisonExpression();
- left = ComparisonExpression.CreateEqual(left, right);
- break;
- case 29:
- mcc_consume_token(29);
- right = GetComparisonExpression();
- left = ComparisonExpression.CreateNotEqual(left, right);
- break;
- default:
- if (mcc_2_1(2)) {
- mcc_consume_token(IS);
- mcc_consume_token(NULL);
- left = ComparisonExpression.CreateIsNull(left);
- } else {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case IS:
- mcc_consume_token(IS);
- mcc_consume_token(NOT);
- mcc_consume_token(NULL);
- left = ComparisonExpression.CreateIsNotNull(left);
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- }
- break;
- }
- }label_3: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetComparisonExpression() {
- IExpression left;
- IExpression right;
- IExpression low;
- IExpression high;
- string t;
- string u;
- ArrayList list;
- left = GetAddExpression();
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case NOT:
- case BETWEEN:
- case LIKE:
- case IN:
- case 30:
- case 31:
- case 32:
- case 33:
- ;
- break;
- default:
- goto label_4;
- }
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 30:
- mcc_consume_token(30);
- right = GetAddExpression();
- left = ComparisonExpression.CreateGreaterThan(left, right);
- break;
- case 31:
- mcc_consume_token(31);
- right = GetAddExpression();
- left = ComparisonExpression.CreateGreaterThanOrEqual(left, right);
- break;
- case 32:
- mcc_consume_token(32);
- right = GetAddExpression();
- left = ComparisonExpression.CreateLesserThan(left, right);
- break;
- case 33:
- mcc_consume_token(33);
- right = GetAddExpression();
- left = ComparisonExpression.CreateLesserThanOrEqual(left, right);
- break;
- case LIKE:
- u = null;
- mcc_consume_token(LIKE);
- t = GetStringLitteral();
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case ESCAPE:
- mcc_consume_token(ESCAPE);
- u = GetStringLitteral();
- break;
- default:
- ;
- break;
- }
- left = ComparisonExpression.CreateLike(left, t, u);
- break;
- default:
- if (mcc_2_2(2)) {
- u=null;
- mcc_consume_token(NOT);
- mcc_consume_token(LIKE);
- t = GetStringLitteral();
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case ESCAPE:
- mcc_consume_token(ESCAPE);
- u = GetStringLitteral();
- break;
- default:
- ;
- break;
- }
- left = ComparisonExpression.CreateNotLike(left, t, u);
- } else {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case BETWEEN:
- mcc_consume_token(BETWEEN);
- low = GetAddExpression();
- mcc_consume_token(AND);
- high = GetAddExpression();
- left = ComparisonExpression.CreateBetween(left, low, high);
- break;
- default:
- if (mcc_2_3(2)) {
- mcc_consume_token(NOT);
- mcc_consume_token(BETWEEN);
- low = GetAddExpression();
- mcc_consume_token(AND);
- high = GetAddExpression();
- left = ComparisonExpression.CreateNotBetween(left, low, high);
- } else {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case IN:
- mcc_consume_token(IN);
- mcc_consume_token(34);
- t = GetStringLitteral();
- list = new ArrayList();
- list.Add(t);
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 35:
- ;
- break;
- default:
- goto label_5;
- }
- mcc_consume_token(35);
- t = GetStringLitteral();
- list.Add(t);
- }label_5: ;
-
- mcc_consume_token(36);
- left = ComparisonExpression.CreateIn(left, list);
- break;
- default:
- if (mcc_2_4(2)) {
- mcc_consume_token(NOT);
- mcc_consume_token(IN);
- mcc_consume_token(34);
- t = GetStringLitteral();
- list = new ArrayList();
- list.Add(t);
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 35:
- ;
- break;
- default:
- goto label_6;
- }
- mcc_consume_token(35);
- t = GetStringLitteral();
- list.Add(t);
- }label_6: ;
-
- mcc_consume_token(36);
- left = ComparisonExpression.CreateNotIn(left, list);
- } else {
- mcc_consume_token(-1);
- throw new ParseException();
- }
- break;
- }
- }
- break;
- }
- }
- break;
- }
- }label_4: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetAddExpression() {
- IExpression left;
- IExpression right;
- left = GetMultiplyExpression();
- while (true) {
- if (mcc_2_5(2147483647)) {
- ;
- } else {
- goto label_7;
- }
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 37:
- mcc_consume_token(37);
- right = GetMultiplyExpression();
- left = ArithmeticExpression.CreatePlus(left, right);
- break;
- case 38:
- mcc_consume_token(38);
- right = GetMultiplyExpression();
- left = ArithmeticExpression.CreateMinus(left, right);
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- }label_7: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetMultiplyExpression() {
- IExpression left;
- IExpression right;
- left = GetUnaryExpression();
- while (true) {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 39:
- case 40:
- case 41:
- ;
- break;
- default:
- goto label_8;
- }
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 39:
- mcc_consume_token(39);
- right = GetUnaryExpression();
- left = ArithmeticExpression.CreateMultiply(left, right);
- break;
- case 40:
- mcc_consume_token(40);
- right = GetUnaryExpression();
- left = ArithmeticExpression.CreateDivide(left, right);
- break;
- case 41:
- mcc_consume_token(41);
- right = GetUnaryExpression();
- left = ArithmeticExpression.CreateMod(left, right);
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- }label_8: ;
-
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetUnaryExpression() {
- IExpression left = null;
- if (mcc_2_6(2147483647)) {
- mcc_consume_token(37);
- left = GetUnaryExpression();
- } else {
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case 38:
- mcc_consume_token(38);
- left = GetUnaryExpression();
- left = UnaryExpression.CreateNegate(left);
- break;
- case NOT:
- mcc_consume_token(NOT);
- left = GetUnaryExpression();
- left = UnaryExpression.CreateNOT(AsBooleanExpression(left));
- break;
- case TRUE:
- case FALSE:
- case NULL:
- case DECIMAL_LITERAL:
- case HEX_LITERAL:
- case OCTAL_LITERAL:
- case FLOATING_POINT_LITERAL:
- case STRING_LITERAL:
- case ID:
- case 34:
- left = GetPrimaryExpression();
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- }
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public IExpression GetPrimaryExpression() {
- IExpression left = null;
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case TRUE:
- case FALSE:
- case NULL:
- case DECIMAL_LITERAL:
- case HEX_LITERAL:
- case OCTAL_LITERAL:
- case FLOATING_POINT_LITERAL:
- case STRING_LITERAL:
- left = GetLiteral();
- break;
- case ID:
- left = GetVariable();
- break;
- case 34:
- mcc_consume_token(34);
- left = GetOrExpression();
- mcc_consume_token(36);
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public ConstantExpression GetLiteral() {
- Token t;
- string s;
- ConstantExpression left = null;
- switch ((mcc_ntk==-1)?mcc_mntk():mcc_ntk) {
- case STRING_LITERAL:
- s = GetStringLitteral();
- left = new ConstantExpression(s);
- break;
- case DECIMAL_LITERAL:
- t = mcc_consume_token(DECIMAL_LITERAL);
- left = ConstantExpression.CreateFromDecimal(t.image);
- break;
- case HEX_LITERAL:
- t = mcc_consume_token(HEX_LITERAL);
- left = ConstantExpression.CreateFromHex(t.image);
- break;
- case OCTAL_LITERAL:
- t = mcc_consume_token(OCTAL_LITERAL);
- left = ConstantExpression.CreateFromOctal(t.image);
- break;
- case FLOATING_POINT_LITERAL:
- t = mcc_consume_token(FLOATING_POINT_LITERAL);
- left = ConstantExpression.CreateFloat(t.image);
- break;
- case TRUE:
- mcc_consume_token(TRUE);
- left = ConstantExpression.TRUE;
- break;
- case FALSE:
- mcc_consume_token(FALSE);
- left = ConstantExpression.FALSE;
- break;
- case NULL:
- mcc_consume_token(NULL);
- left = ConstantExpression.NULL;
- break;
- default:
- mcc_consume_token(-1);
- throw new ParseException();
- }
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- public string GetStringLitteral() {
- Token t;
- StringBuilder rc = new StringBuilder();
- t = mcc_consume_token(STRING_LITERAL);
- // Decode the sting value.
- String image = t.image;
- for(int c = 1; c < image.Length - 1; c++)
- {
- char ch = image[c];
- if(ch == '\'')
- {
- c++;
- }
- rc.Append(ch);
- }
- {return rc.ToString();}
- throw new Exception("Missing return statement in function");
- }
-
- public PropertyExpression GetVariable() {
- Token t;
- PropertyExpression left = null;
- t = mcc_consume_token(ID);
- left = new PropertyExpression(t.image);
- {return left;}
- throw new Exception("Missing return statement in function");
- }
-
- private bool mcc_2_1(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_1(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_2_2(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_2(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_2_3(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_3(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_2_4(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_4(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_2_5(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_5(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_2_6(int xla) {
- mcc_la = xla; mcc_lastpos = mcc_scanpos = token;
- try { return !mcc_3_6(); }
- catch(LookaheadSuccess) { return true; }
- }
-
- private bool mcc_3R_57() {
- if (mcc_scan_token(ESCAPE)) return true;
- if (mcc_3R_36()) return true;
- return false;
- }
-
- private bool mcc_3R_19() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_20()) {
- mcc_scanpos = xsp;
- if (mcc_3R_21()) {
- mcc_scanpos = xsp;
- if (mcc_3R_22()) return true;
- }
- }
- return false;
- }
-
- private bool mcc_3R_39() {
- if (mcc_3R_41()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_42()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3_4() {
- if (mcc_scan_token(NOT)) return true;
- if (mcc_scan_token(IN)) return true;
- if (mcc_scan_token(34)) return true;
- if (mcc_3R_36()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_59()) { mcc_scanpos = xsp; break; }
- }
- if (mcc_scan_token(36)) return true;
- return false;
- }
-
- private bool mcc_3_6() {
- if (mcc_scan_token(37)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_15() {
- if (mcc_3R_19()) return true;
- return false;
- }
-
- private bool mcc_3R_36() {
- if (mcc_scan_token(STRING_LITERAL)) return true;
- return false;
- }
-
- private bool mcc_3R_14() {
- if (mcc_scan_token(NOT)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_12() {
- if (mcc_scan_token(37)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_53() {
- if (mcc_scan_token(IN)) return true;
- if (mcc_scan_token(34)) return true;
- if (mcc_3R_36()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_58()) { mcc_scanpos = xsp; break; }
- }
- if (mcc_scan_token(36)) return true;
- return false;
- }
-
- private bool mcc_3R_45() {
- if (mcc_scan_token(IS)) return true;
- if (mcc_scan_token(NOT)) return true;
- if (mcc_scan_token(NULL)) return true;
- return false;
- }
-
- private bool mcc_3R_13() {
- if (mcc_scan_token(38)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_33() {
- if (mcc_scan_token(NULL)) return true;
- return false;
- }
-
- private bool mcc_3_1() {
- if (mcc_scan_token(IS)) return true;
- if (mcc_scan_token(NULL)) return true;
- return false;
- }
-
- private bool mcc_3R_10() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_12()) {
- mcc_scanpos = xsp;
- if (mcc_3R_13()) {
- mcc_scanpos = xsp;
- if (mcc_3R_14()) {
- mcc_scanpos = xsp;
- if (mcc_3R_15()) return true;
- }
- }
- }
- return false;
- }
-
- private bool mcc_3R_44() {
- if (mcc_scan_token(29)) return true;
- if (mcc_3R_39()) return true;
- return false;
- }
-
- private bool mcc_3R_32() {
- if (mcc_scan_token(FALSE)) return true;
- return false;
- }
-
- private bool mcc_3_3() {
- if (mcc_scan_token(NOT)) return true;
- if (mcc_scan_token(BETWEEN)) return true;
- if (mcc_3R_41()) return true;
- if (mcc_scan_token(AND)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_43() {
- if (mcc_scan_token(28)) return true;
- if (mcc_3R_39()) return true;
- return false;
- }
-
- private bool mcc_3R_40() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_43()) {
- mcc_scanpos = xsp;
- if (mcc_3R_44()) {
- mcc_scanpos = xsp;
- if (mcc_3_1()) {
- mcc_scanpos = xsp;
- if (mcc_3R_45()) return true;
- }
- }
- }
- return false;
- }
-
- private bool mcc_3R_52() {
- if (mcc_scan_token(BETWEEN)) return true;
- if (mcc_3R_41()) return true;
- if (mcc_scan_token(AND)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_31() {
- if (mcc_scan_token(TRUE)) return true;
- return false;
- }
-
- private bool mcc_3R_56() {
- if (mcc_scan_token(ESCAPE)) return true;
- if (mcc_3R_36()) return true;
- return false;
- }
-
- private bool mcc_3R_18() {
- if (mcc_scan_token(41)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_30() {
- if (mcc_scan_token(FLOATING_POINT_LITERAL)) return true;
- return false;
- }
-
- private bool mcc_3R_37() {
- if (mcc_3R_39()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_40()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3_2() {
- if (mcc_scan_token(NOT)) return true;
- if (mcc_scan_token(LIKE)) return true;
- if (mcc_3R_36()) return true;
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_57()) mcc_scanpos = xsp;
- return false;
- }
-
- private bool mcc_3R_51() {
- if (mcc_scan_token(LIKE)) return true;
- if (mcc_3R_36()) return true;
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_56()) mcc_scanpos = xsp;
- return false;
- }
-
- private bool mcc_3R_17() {
- if (mcc_scan_token(40)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_29() {
- if (mcc_scan_token(OCTAL_LITERAL)) return true;
- return false;
- }
-
- private bool mcc_3R_16() {
- if (mcc_scan_token(39)) return true;
- if (mcc_3R_10()) return true;
- return false;
- }
-
- private bool mcc_3R_11() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_16()) {
- mcc_scanpos = xsp;
- if (mcc_3R_17()) {
- mcc_scanpos = xsp;
- if (mcc_3R_18()) return true;
- }
- }
- return false;
- }
-
- private bool mcc_3R_38() {
- if (mcc_scan_token(AND)) return true;
- if (mcc_3R_37()) return true;
- return false;
- }
-
- private bool mcc_3R_28() {
- if (mcc_scan_token(HEX_LITERAL)) return true;
- return false;
- }
-
- private bool mcc_3R_9() {
- if (mcc_3R_10()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_11()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3R_27() {
- if (mcc_scan_token(DECIMAL_LITERAL)) return true;
- return false;
- }
-
- private bool mcc_3R_55() {
- if (mcc_scan_token(38)) return true;
- if (mcc_3R_9()) return true;
- return false;
- }
-
- private bool mcc_3R_34() {
- if (mcc_3R_37()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_38()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3_5() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_scan_token(37)) {
- mcc_scanpos = xsp;
- if (mcc_scan_token(38)) return true;
- }
- if (mcc_3R_9()) return true;
- return false;
- }
-
- private bool mcc_3R_50() {
- if (mcc_scan_token(33)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_54() {
- if (mcc_scan_token(37)) return true;
- if (mcc_3R_9()) return true;
- return false;
- }
-
- private bool mcc_3R_26() {
- if (mcc_3R_36()) return true;
- return false;
- }
-
- private bool mcc_3R_49() {
- if (mcc_scan_token(32)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_59() {
- if (mcc_scan_token(35)) return true;
- if (mcc_3R_36()) return true;
- return false;
- }
-
- private bool mcc_3R_46() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_54()) {
- mcc_scanpos = xsp;
- if (mcc_3R_55()) return true;
- }
- return false;
- }
-
- private bool mcc_3R_35() {
- if (mcc_scan_token(OR)) return true;
- if (mcc_3R_34()) return true;
- return false;
- }
-
- private bool mcc_3R_23() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_26()) {
- mcc_scanpos = xsp;
- if (mcc_3R_27()) {
- mcc_scanpos = xsp;
- if (mcc_3R_28()) {
- mcc_scanpos = xsp;
- if (mcc_3R_29()) {
- mcc_scanpos = xsp;
- if (mcc_3R_30()) {
- mcc_scanpos = xsp;
- if (mcc_3R_31()) {
- mcc_scanpos = xsp;
- if (mcc_3R_32()) {
- mcc_scanpos = xsp;
- if (mcc_3R_33()) return true;
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- private bool mcc_3R_48() {
- if (mcc_scan_token(31)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_24() {
- if (mcc_scan_token(ID)) return true;
- return false;
- }
-
- private bool mcc_3R_47() {
- if (mcc_scan_token(30)) return true;
- if (mcc_3R_41()) return true;
- return false;
- }
-
- private bool mcc_3R_42() {
- Token xsp;
- xsp = mcc_scanpos;
- if (mcc_3R_47()) {
- mcc_scanpos = xsp;
- if (mcc_3R_48()) {
- mcc_scanpos = xsp;
- if (mcc_3R_49()) {
- mcc_scanpos = xsp;
- if (mcc_3R_50()) {
- mcc_scanpos = xsp;
- if (mcc_3R_51()) {
- mcc_scanpos = xsp;
- if (mcc_3_2()) {
- mcc_scanpos = xsp;
- if (mcc_3R_52()) {
- mcc_scanpos = xsp;
- if (mcc_3_3()) {
- mcc_scanpos = xsp;
- if (mcc_3R_53()) {
- mcc_scanpos = xsp;
- if (mcc_3_4()) return true;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- private bool mcc_3R_41() {
- if (mcc_3R_9()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_46()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3R_25() {
- if (mcc_3R_34()) return true;
- Token xsp;
- while (true) {
- xsp = mcc_scanpos;
- if (mcc_3R_35()) { mcc_scanpos = xsp; break; }
- }
- return false;
- }
-
- private bool mcc_3R_22() {
- if (mcc_scan_token(34)) return true;
- if (mcc_3R_25()) return true;
- if (mcc_scan_token(36)) return true;
- return false;
- }
-
- private bool mcc_3R_21() {
- if (mcc_3R_24()) return true;
- return false;
- }
-
- private bool mcc_3R_20() {
- if (mcc_3R_23()) return true;
- return false;
- }
-
- private bool mcc_3R_58() {
- if (mcc_scan_token(35)) return true;
- if (mcc_3R_36()) return true;
- return false;
- }
-
- public SelectorParserTokenManager token_source;
- SimpleCharStream mcc_input_stream;
- public Token token, mcc_nt;
- private int mcc_ntk;
- private Token mcc_scanpos, mcc_lastpos;
- private int mcc_la;
- public bool lookingAhead = false;
- //private bool mcc_semLA;
-
- public SelectorParser(System.IO.Stream stream) {
- mcc_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new SelectorParserTokenManager(mcc_input_stream);
- token = new Token();
- mcc_ntk = -1;
- }
-
- public void ReInit(System.IO.Stream stream) {
- mcc_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(mcc_input_stream);
- token = new Token();
- mcc_ntk = -1;
- }
-
- public SelectorParser(System.IO.TextReader stream) {
- mcc_input_stream = new SimpleCharStream(stream, 1, 1);
- token_source = new SelectorParserTokenManager(mcc_input_stream);
- token = new Token();
- mcc_ntk = -1;
- }
-
- public void ReInit(System.IO.TextReader stream) {
- mcc_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(mcc_input_stream);
- token = new Token();
- mcc_ntk = -1;
- }
-
- public SelectorParser(SelectorParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- mcc_ntk = -1;
- }
-
- public void ReInit(SelectorParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- mcc_ntk = -1;
- }
-
- private Token mcc_consume_token(int kind) {
- Token oldToken = null;
- if ((oldToken = token).next != null) token = token.next;
- else token = token.next = token_source.GetNextToken();
- mcc_ntk = -1;
- if (token.kind == kind) {
- return token;
- }
- token = oldToken;
- throw GenerateParseException();
- }
-
- private class LookaheadSuccess : System.Exception { }
- private LookaheadSuccess mcc_ls = new LookaheadSuccess();
- private bool mcc_scan_token(int kind) {
- if (mcc_scanpos == mcc_lastpos) {
- mcc_la--;
- if (mcc_scanpos.next == null) {
- mcc_lastpos = mcc_scanpos = mcc_scanpos.next = token_source.GetNextToken();
- } else {
- mcc_lastpos = mcc_scanpos = mcc_scanpos.next;
- }
- } else {
- mcc_scanpos = mcc_scanpos.next;
- }
- if (mcc_scanpos.kind != kind) return true;
- if (mcc_la == 0 && mcc_scanpos == mcc_lastpos) throw mcc_ls;
- return false;
- }
-
- public Token GetNextToken() {
- if (token.next != null) token = token.next;
- else token = token.next = token_source.GetNextToken();
- mcc_ntk = -1;
- return token;
- }
-
- public Token GetToken(int index) {
- Token t = lookingAhead ? mcc_scanpos : token;
- for (int i = 0; i < index; i++) {
- if (t.next != null) t = t.next;
- else t = t.next = token_source.GetNextToken();
- }
- return t;
- }
-
- private int mcc_mntk() {
- if ((mcc_nt=token.next) == null)
- return (mcc_ntk = (token.next=token_source.GetNextToken()).kind);
- else
- return (mcc_ntk = mcc_nt.kind);
- }
-
- public ParseException GenerateParseException() {
- Token errortok = token.next;
- int line = errortok.beginLine, column = errortok.beginColumn;
- string mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
- return new ParseException("Parse error at line " + line + ", column " + column + ". Encountered: " + mess);
- }
-
- public void enable_tracing() {
- }
-
- public void disable_tracing() {
- }
-
-}
-
+/* Generated By:CSharpCC: Do not edit this line. SelectorParser.cs */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+
+using Apache.NMS;
+
+namespace Apache.NMS.Selector
+{
+ /// <summary>
+ /// JMS Selector Parser generated by <a href="https://github.com/deveel/csharpcc">CSharpCC</a>
+ ///
+ /// Do not edit this .cs file directly - it is autogenerated from SelectorParser.csc
+ /// using <c>csharpcc.exe -UNICODE_INPUT=true SelectorParser.csc</c>.
+ ///
+ /// SelectorParser.csc is adapted from
+ /// <a href="https://raw.githubusercontent.com/apache/activemq/activemq-4.0/activemq-core/src/main/grammar/SelectorParser.jj">
+ /// ActiveMQ 4.0 SelectorParser.jj</a>
+ /// </summary>
+ public class SelectorParser : SelectorParserConstants {
+
+ public SelectorParser()
+ : this(new StringReader(""))
+ {
+ }
+
+ public IBooleanExpression Parse(string selector)
+ {
+ this.ReInit(new StringReader(selector));
+
+ try
+ {
+ return this.JmsSelector();
+ }
+ catch(Exception e)
... 15527 lines suppressed ...