Home | History | Annotate | Download | only in jbosh
      1 /*
      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 
     17 package com.kenai.jbosh;
     18 
     19 import java.util.HashMap;
     20 import 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  */
     26 final 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 }
     65