ProtocolPropertiesFactory.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.protocol.sdk.properties;

  21. import org.openspcoop2.protocol.sdk.ProtocolException;
  22. import org.openspcoop2.protocol.sdk.constants.ConsoleItemType;
  23. import org.openspcoop2.protocol.sdk.constants.ConsoleItemValueType;
  24. import org.openspcoop2.utils.sql.LikeConfig;

  25. /**
  26.  * ProtocolPropertiesFactory
  27.  *
  28.  * @author Poli Andrea (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class ProtocolPropertiesFactory {
  33.    
  34.     private ProtocolPropertiesFactory() {}

  35.     public static BaseConsoleItem newTitleItem(String id, String label) throws ProtocolException{
  36.         return new TitleConsoleItem(id, label);
  37.     }
  38.     public static BaseConsoleItem newSubTitleItem(String id, String label) throws ProtocolException{
  39.         return new SubtitleConsoleItem(id, label);
  40.     }
  41.     public static BaseConsoleItem newNoteItem(String id, String label) throws ProtocolException{
  42.         return new BaseConsoleItem(id, label, ConsoleItemType.NOTE);
  43.     }
  44.    
  45.     public static AbstractConsoleItem<?> newConsoleItem(ConsoleItemType itemType, String id, String label) throws ProtocolException{
  46.         return newConsoleItem(ConsoleItemValueType.STRING, itemType, id, label);
  47.     }
  48.     public static AbstractConsoleItem<?> newConsoleItem(ConsoleItemValueType type, ConsoleItemType itemType, String id, String label) throws ProtocolException{
  49.         switch (type) {
  50.             case STRING:
  51.                 return new StringConsoleItem(id, label, itemType);
  52.             case NUMBER:
  53.                 return new NumberConsoleItem(id, label, itemType);
  54.             case BOOLEAN:
  55.                 return new BooleanConsoleItem(id, label, itemType);
  56.             case BINARY:
  57.                 return new BinaryConsoleItem(id, label, itemType);
  58.         }
  59.         throw new ProtocolException("Type ["+type+"] unsupported");
  60.     }
  61.     public static AbstractConsoleItem<?> newBinaryConsoleItem(ConsoleItemType itemType, String id, String label, String fileName, String fileId) throws ProtocolException{
  62.         return new BinaryConsoleItem(id, label, itemType, fileName, fileId);
  63.     }
  64.     public static BinaryProperty newProperty(String id, byte[] value, String fileName, String fileId){
  65.         return new BinaryProperty(id, value, fileName, fileId);
  66.     }
  67.     public static NumberProperty newProperty(String id, Long value){
  68.         return new NumberProperty(id, value);
  69.     }
  70.     public static NumberProperty newProperty(String id, Integer value){
  71.         return new NumberProperty(id, (value != null ? value.longValue() : null));
  72.     }
  73.     public static BooleanProperty newProperty(String id, Boolean value){
  74.         return new BooleanProperty(id, value);
  75.     }
  76.     public static StringProperty newProperty(String id, String value){
  77.         return new StringProperty(id, value);
  78.     }
  79.     public static StringProperty newProperty(String id, String value, LikeConfig searchWithLike){
  80.         return new StringProperty(id, value, searchWithLike);
  81.     }
  82. }