JsonPathReturnType.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.json;



  21. import javax.xml.namespace.QName;
  22. import javax.xml.xpath.XPathConstants;


  23. /**
  24.  * XPathReturnType
  25.  *
  26.  *
  27.  * @author Poli Andrea
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public enum JsonPathReturnType {

  32.     STRING (XPathConstants.STRING),
  33.     NUMBER (XPathConstants.NUMBER),
  34.     BOOLEAN (XPathConstants.BOOLEAN),
  35.     NODE (XPathConstants.NODE),
  36.     JSON_PATH_OBJECT(new QName("net.minidev.json.JSONObject"));
  37. //  NODESET (XPathConstants.NODESET);

  38.     private final QName valore;

  39.     JsonPathReturnType(QName valore)
  40.     {
  41.         this.valore = valore;
  42.     }

  43.     public QName getValore()
  44.     {
  45.         return this.valore;
  46.     }

  47.     public static String[] toStringArray(){
  48.         String[] res = new String[JsonPathReturnType.values().length];
  49.         int i=0;
  50.         for (JsonPathReturnType tmp : JsonPathReturnType.values()) {
  51.             res[i]=tmp.getValore().getLocalPart();
  52.             i++;
  53.         }
  54.         return res;
  55.     }
  56.    
  57.     public static String[] toEnumNameArray(){
  58.         String[] res = new String[JsonPathReturnType.values().length];
  59.         int i=0;
  60.         for (JsonPathReturnType tmp : JsonPathReturnType.values()) {
  61.             res[i]=tmp.name();
  62.             i++;
  63.         }
  64.         return res;
  65.     }

  66.    
  67.     @Override
  68.     public String toString(){
  69.         return this.valore.toString();
  70.     }
  71.     public boolean equals(QName esito){
  72.         return this.toString().equals(esito.toString());
  73.     }

  74. }