User: chirino 
  Date: 01/08/22 20:57:12

  Added:       src/main/org/jboss/mq/selectors Tag: Branch_2_4
                        Identifier.java Operator.java Selector.java
                        parser.java parserval.java
  Log:
  Back porting JBossMQ 1.0.0 BETA 1 to 2_4 branch
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +1 -1      jbossmq/src/main/org/jboss/mq/selectors/Identifier.java
  
  Index: Identifier.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/Identifier.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- Identifier.java   2001/08/17 03:04:06     1.2
  +++ Identifier.java   2001/08/23 03:57:12     1.2.2.1
  @@ -41,7 +41,7 @@
    *
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @created    August 16, 2001
  - * @version    $Revision: 1.2 $
  + * @version    $Revision: 1.2.2.1 $
    */
   public class Identifier {
      String           name;
  
  
  
  1.3.2.1   +0 -2      jbossmq/src/main/org/jboss/mq/selectors/Operator.java
  
  Index: Operator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/Operator.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Operator.java     2001/08/22 00:44:44     1.3
  +++ Operator.java     2001/08/23 03:57:12     1.3.2.1
  @@ -14,7 +14,7 @@
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @author     [EMAIL PROTECTED]
    * @created    August 16, 2001
  - * @version    $Revision: 1.3 $
  + * @version    $Revision: 1.3.2.1 $
    */
   public class Operator {
      int              operation;
  @@ -183,9 +183,7 @@
            case STRING:
            case LONG:
            case DOUBLE:
  -         case BOOLEAN:
               computeArgument2();
  -            
               if ( arg2 == null ) {
                  return Boolean.FALSE;
               }
  
  
  
  1.3.2.1   +61 -104   jbossmq/src/main/org/jboss/mq/selectors/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/Selector.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- Selector.java     2001/08/22 00:53:35     1.3
  +++ Selector.java     2001/08/23 03:57:12     1.3.2.1
  @@ -8,11 +8,9 @@
   
   import java.util.HashMap;
   import java.util.Iterator;
  -
   import javax.jms.InvalidSelectorException;
  -import javax.jms.JMSException;
   
  -import org.apache.log4j.Category;
  +import javax.jms.JMSException;
   
   import org.jboss.mq.SpyMessage;
   
  @@ -21,153 +19,112 @@
    *
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @author     Juha Lindfors ([EMAIL PROTECTED])
  - * @author     <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
    * @created    August 16, 2001
  - * @version    $Revision: 1.3 $
  + * @version    $Revision: 1.3.2.1 $
    */
  -public class Selector
  -{
  -   public HashMap identifiers;
  -   public Object result;
  -   private Class resultType;
  -   
  -   static Category cat = Category.getInstance(Selector.class);
  +public class Selector {
  +   public HashMap   identifiers;
  +   // HashMap of Identifiers
  +   public Object    result;
   
  -   public Selector(String sel) throws JMSException {
  +   static org.apache.log4j.Category cat = org.apache.log4j.Category.getInstance( 
Selector.class );
  +
  +   public Selector( String sel )
  +      throws JMSException {
         parser bob = new parser();
         identifiers = new HashMap();
   
         try {
  -         result = bob.parse(sel, identifiers);
  -         resultType = result.getClass();
  -      }
  -      catch (Exception e) {
  -         InvalidSelectorException exception =
  -            new InvalidSelectorException("The selector is invalid.");
  -         exception.setLinkedException(e);
  +         result = bob.parse( sel, identifiers );
  +      } catch ( Exception e ) {
  +         InvalidSelectorException exception = new InvalidSelectorException( "The 
selector is invalid." );
  +         exception.setLinkedException( e );
            throw exception;
         }
   
  -//       if (cat.isDebugEnabled()) {
  -//          cat.debug("result: " + resultType + " = " + result);
  -//       }
  +      //Log.notice(result.toString());
      }
  +
  +   public boolean test( SpyMessage mes )
  +      throws JMSException {
   
  -   public boolean test(SpyMessage mes) throws JMSException {
         try {
  -         // Set the identifiers values
  +
  +         //Set the identifiers values
            Iterator i = identifiers.values().iterator();
  +
  +         while ( i.hasNext() ) {
  +            Identifier id = ( Identifier )i.next();
   
  -         while (i.hasNext()) {
  -            Identifier id = (Identifier)i.next();
  -            Object find = mes.getObjectProperty(id.name);
  -//             if (cat.isDebugEnabled()) {
  -//                cat.debug("Identifier: " + id);
  -//                cat.debug("Property: " + find);
  -//                if (find != null) {
  -//                   cat.debug("Property type: " + find.getClass());
  -//                }
  -//             }
  +            Object find = mes.getObjectProperty( id.name );
   
  -            if (find == null) {
  -               find = getHeaderFieldReferences(mes, id.name);
  +            if ( find == null ) {
  +               find = getHeaderFieldReferences( mes, id.name );
               }
   
  -            if (find == null) {
  -               if (cat.isDebugEnabled()) {
  -                  cat.debug("Warning : missing property " + id.name);
  -               }
  +            if ( find == null ) {
  +               cat.debug( "Warning : missing property " + id.name );
                  id.value = null;
  -            }
  -            else {
  +            } else {
                  Class type = find.getClass();
  -               if (type.equals(Boolean.class) ||
  -                   type.equals(String.class)  ||
  -                   type.equals(Double.class)  ||
  -                   type.equals(Float.class)   ||
  -                   type.equals(Integer.class) ||
  -                   type.equals(Long.class)    ||
  -                   type.equals(Short.class)   ||
  -                   type.equals(Byte.class))
  -               {
  +               if ( type.equals( Boolean.class ) || type.equals( String.class )
  +                      || type.equals( Double.class ) || type.equals( Float.class )
  +                      || type.equals( Integer.class ) || type.equals( Long.class )
  +                      || type.equals( Short.class ) || type.equals( Byte.class ) ) {
                     id.value = find;
  -               }
  -               else {
  -                  throw new Exception("Bad property type: " + type);
  +               } else {
  +                  throw new Exception( "Bad property type !" );
                  }
  -
  -//                if (cat.isDebugEnabled()) {
  -//                   cat.debug("SEL:" + id.name + " =>" + id.value);
  -//                }
  +               //Log.notice("SEL:"+id.name+" =>"+id.value);
               }
            }
   
  -         // Compute the result of this operator
  +         //Compute the result of this operator
            Object res;
   
  -         if (resultType.equals(Identifier.class)) {
  -            res = ((Identifier)result).value;
  -         }
  -         else if (resultType.equals(Operator.class)) {
  -            res = ((Operator)result).apply();
  -         }
  -         else {
  +         if ( result.getClass().equals( Identifier.class ) ) {
  +            res = ( ( Identifier )result ).value;
  +         } else if ( result.getClass().equals( Operator.class ) ) {
  +            res = ( ( Operator )result ).apply();
  +         } else {
               res = result;
            }
   
  -//          if (cat.isDebugEnabled()) {
  -//             cat.debug("res: " + res);
  -//             if (result != null) {
  -//                cat.debug("res type: " + res.getClass());
  -//             }
  -//          }
  -         
  -         if (res == null) {
  +         if ( res == null ) {
               return false;
            }
  -         
  -         if (!(res.getClass().equals(Boolean.class))) {
  -            throw new Exception("Bad object type: " + res);
  +         if ( !( res.getClass().equals( Boolean.class ) ) ) {
  +            throw new Exception( "Bad object type" );
            }
   
  -//          if (cat.isDebugEnabled()) {
  -//             cat.debug("Selectors =>" + res);
  -//          }
  +         //Log.notice("Selectors =>"+res);
   
  -         return ((Boolean )res).booleanValue();
  +         return ( ( Boolean )res ).booleanValue();
  +      } catch ( Exception e ) {
  +         throw new JMSException( "SELECTOR: " + e.getMessage() );
         }
  -      catch (Exception e) {
  -         throw new JMSException("SELECTOR: " + e.getMessage());
  -      }
      }
   
      // [JPL]
  -   private Object getHeaderFieldReferences(SpyMessage msg, String idName)
  -      throws JMSException
  -   {
  +   private Object getHeaderFieldReferences( SpyMessage msg, String idName )
  +      throws JMSException {
  +
         // JMS 3.8.1.1 -- Message header field references are restricted to:
         //                JMSDeliveryMode, JMSPriority, JMSMessageID,
         //                JMSTimeStamp, JMSCorrelationID and JMSType
  -      //
  -      if (idName.equals("JMSDeliveryMode")) {
  -         return new Integer(msg.getJMSDeliveryMode());
  -      }
  -      else if (idName.equals("JMSPriority")) {
  -         return new Integer(msg.getJMSPriority());
  -      }
  -      else if (idName.equals("JMSMessageID")) {
  +      if ( idName.equals( "JMSDeliveryMode" ) ) {
  +         return new Integer( msg.getJMSDeliveryMode() );
  +      } else if ( idName.equals( "JMSPriority" ) ) {
  +         return new Integer( msg.getJMSPriority() );
  +      } else if ( idName.equals( "JMSMessageID" ) ) {
            return msg.getJMSMessageID();
  -      }
  -      else if (idName.equals("JMSTimestamp")) {
  -         return new Long(msg.getJMSTimestamp());
  -      }
  -      else if (idName.equals("JMSCorrelationID")) {
  +      } else if ( idName.equals( "JMSTimestamp" ) ) {
  +         return new Long( msg.getJMSTimestamp() );
  +      } else if ( idName.equals( "JMSCorrelationID" ) ) {
            return msg.getJMSCorrelationID();
  -      }
  -      else if (idName.equals("JMSType")) {
  +      } else if ( idName.equals( "JMSType" ) ) {
            return msg.getJMSType();
  -      }
  -      else {
  +      } else {
            return null;
         }
      }
  
  
  
  1.3.2.1   +2 -2      jbossmq/src/main/org/jboss/mq/selectors/parser.java
  
  Index: parser.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/parser.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- parser.java       2001/08/22 00:52:31     1.3
  +++ parser.java       2001/08/23 03:57:12     1.3.2.1
  @@ -540,11 +540,11 @@
         }
   
         //CST group
  -      if ( s.equals( "TRUE" ) || s.equals("true") ) {
  +      if ( s.equals( "TRUE" ) ) {
            yylval = new parserval( ( Object )Boolean.TRUE );
            return CST;
         }
  -      if ( s.equals( "FALSE" ) || s.equals("false") ) {
  +      if ( s.equals( "FALSE" ) ) {
            yylval = new parserval( ( Object )Boolean.FALSE );
            return CST;
         }
  
  
  
  1.2.2.1   +0 -0      jbossmq/src/main/org/jboss/mq/selectors/parserval.java
  
  Index: parserval.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/parserval.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to