blob: 955e4bf3029eb9a1c4d18d468b13d955fb0c9701 [file] [log] [blame]
Shuyi Chend7955ce2013-05-22 14:51:55 -07001/*
2 * Copyright 2009 Mike Cumings
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
17package com.kenai.jbosh;
18
19import java.util.HashMap;
20import java.util.Map;
21
22/**
23 * Data extracted from a raw XML message by a BodyParser implementation.
24 * Currently, this is limited to the attributes of the wrapper element.
25 */
26final class BodyParserResults {
27
28 /**
29 * Map of qualified names to their values. This map is defined to
30 * match the requirement of the {@code Body} class to prevent
31 * excessive copying.
32 */
33 private final Map<BodyQName, String> attrs =
34 new HashMap<BodyQName, String>();
35
36 /**
37 * Constructor.
38 */
39 BodyParserResults() {
40 // Empty
41 }
42
43 /**
44 * Add an attribute definition to the results.
45 *
46 * @param name attribute's qualified name
47 * @param value attribute value
48 */
49 void addBodyAttributeValue(
50 final BodyQName name,
51 final String value) {
52 attrs.put(name, value);
53 }
54
55 /**
56 * Returns the map of attributes added by the parser.
57 *
58 * @return map of atributes. Note: This is the live instance, not a copy.
59 */
60 Map<BodyQName, String> getAttributes() {
61 return attrs;
62 }
63
64}