http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/InExpression.cs ---------------------------------------------------------------------- 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(); + } + } +}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/IsNullExpression.cs ---------------------------------------------------------------------- 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(); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/LesserExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/LesserOrEqualExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/LikeExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/LogicExpression.cs ---------------------------------------------------------------------- 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); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/MessageEvaluationContext.cs ---------------------------------------------------------------------- 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 http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/MinusExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/ModExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/MultiplyExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/NOTExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/NegateExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/ORExpression.cs ---------------------------------------------------------------------- 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; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/main/csharp/Selector/ParseException.cs ---------------------------------------------------------------------- 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(); + } + +}
