OpenSPCoop2MessageProperties.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.message;

  21. import java.util.HashMap;
  22. import java.util.Iterator;
  23. import java.util.List;
  24. import java.util.Map;

  25. import org.openspcoop2.utils.transport.TransportUtils;

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

  34.     private Map<String, List<String>> props = new HashMap<>();  

  35.     private boolean initialize = false;
  36.    
  37.     public boolean isInitialize() {
  38.         return this.initialize;
  39.     }

  40.     public void setInitialize(boolean initialize) {
  41.         this.initialize = initialize;
  42.     }

  43.     public void addProperty(String key,String value){
  44.         TransportUtils.put(this.props, key, value, true);
  45.     }
  46.     public void setProperty(String key,List<String> values){
  47.         this.props.put(key, values);
  48.     }
  49.    
  50.     @Deprecated
  51.     public String removeProperty(String key){
  52.         Object o = TransportUtils.removeObjectAsString(this.props, key);
  53.         return (o!=null && o instanceof String) ? ((String)o) : null;
  54.     }
  55.     public List<String> removePropertyValues(String key){
  56.         return TransportUtils.removeRawObject(this.props, key);
  57.     }
  58.    
  59.     public Iterator<String> getKeys(){
  60.         return this.props.keySet().iterator();
  61.     }
  62.    
  63.     public boolean containsKey(String key){
  64.         return TransportUtils.containsKey(this.props, key);
  65.     }
  66.    
  67.     @Deprecated
  68.     public String getProperty(String key){
  69.         return TransportUtils.getObjectAsString(this.props, key);
  70.     }
  71.     public List<String> getPropertyValues(String key){
  72.         return TransportUtils.getRawObject(this.props, key);
  73.     }
  74.    
  75.     @Deprecated
  76.     public Map<String, String> getAsMap(){
  77.         return TransportUtils.convertToMapSingleValue(this.props);
  78.     }
  79.     public Map<String, List<String>> map(){
  80.         return this.props;
  81.     }
  82.    
  83.     public int size(){
  84.         return this.props.size();
  85.     }
  86. }