View Javadoc
1   /*
2    * Copyright 2011 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.ws.cxf.payload;
17  
18  import java.util.EnumMap;
19  
20  /**
21   * Holder for various types of String message payloads.
22   * @author Dmytro Rud
23   */
24  public class StringPayloadHolder {
25  
26      /**
27       * Types of supported payload:
28       * <ul>
29       *     <li>HTTP (probably multi-part, i.e. with all attachments),
30       *     <li>SOAP Body.
31       * </ul>
32       */
33      public enum PayloadType {
34          HTTP, SOAP_BODY
35      }
36  
37  
38      // not synchronized, because parallel access is not expected
39      private final EnumMap<PayloadType, String> map =
40              new EnumMap<>(PayloadType.class);
41  
42  
43      public String get(PayloadType payloadType) {
44          return map.get(payloadType);
45      }
46  
47      public void put(PayloadType payloadType, String payload) {
48          map.put(payloadType, payload);
49      }
50  
51      public void remove(PayloadType payloadType) {
52          map.remove(payloadType);
53      }
54  }