public boolean matches(final Node node) throws IllegalArgumentException
   {
      // Precondition checks
      if (node == null)
      {
         throw new IllegalArgumentException("node must be specified");
      }

      if (!name.equals(node.getName()))
      {
         return false;
      }

      if ((text != null && node.getText() == null) || (text != null && !text.trim().equals(node.getText().trim())))
      {
         return false;
      }

      if (attributes != null)
      {
         for (final Map.Entry<String, String> attribute : attributes.entrySet())
         {
            final String attrValue = attribute.getValue();
            final String attrName = attribute.getKey();

            if (!attrValue.equals(node.getAttribute(attrName)))
            {
               return false;
            }
         }
      }

      return true;
   }