package com.l7tech.xml.xpath;

public interface XpathResult {
   short TYPE_NODESET = 1;
   short TYPE_BOOLEAN = 2;
   short TYPE_NUMBER = 3;
   short TYPE_STRING = 4;
   XpathResult RESULT_TRUE = new XpathResult.Truth();
   XpathResult RESULT_FALSE = new XpathResult.Falsehood();
   XpathResult RESULT_EMPTY = new ac();

   boolean matches();

   short getType();

   String getString();

   boolean getBoolean();

   Number getNumber();

   XpathResultNodeSet getNodeSet();

   class Falsehood extends XpathResult.XpathResultAdapter {
      private Falsehood() {
      }

      @Override
      public short getType() {
         return 2;
      }

      @Override
      public boolean getBoolean() {
         return false;
      }
   }

   abstract class MultiValuedXpathResultAdapter extends XpathResult.XpathResultAdapter {
      protected MultiValuedXpathResultAdapter() {
      }

      public abstract XpathResultValueSet getValueSet();

      public abstract String[] getStringArray();

      public abstract Boolean[] getBooleanArray();

      public abstract Number[] getNumberArray();
   }

   class Truth extends XpathResult.XpathResultAdapter {
      private Truth() {
      }

      @Override
      public short getType() {
         return 2;
      }

      @Override
      public boolean getBoolean() {
         return true;
      }
   }

   abstract class XpathResultAdapter implements XpathResult {
      protected XpathResultAdapter() {
      }

      @Override
      public boolean matches() {
         switch (this.getType()) {
            case 1:
               XpathResultNodeSet var1 = this.getNodeSet();
               return var1 != null && !var1.isEmpty();
            case 2:
               return this.getBoolean();
            case 3:
            case 4:
               return true;
            default:
               return false;
         }
      }

      @Override
      public String getString() {
         return null;
      }

      @Override
      public boolean getBoolean() {
         return false;
      }

      @Override
      public Number getNumber() {
         return 0;
      }

      @Override
      public XpathResultNodeSet getNodeSet() {
         return null;
      }
   }
}
