Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.xb.annotations;
 
A JBossXmlMapEntry. Binds Java maps to XSD structures. The annotation can be used on a type which implements java.util.Map or property of type that implements java.util.Map. Some of the possible bindings:

sequence of key and value elements

 <key>key1</key><value>value1</value>
 <key>key2</key><value>value2</value>
 
 @JBossXmlMapKeyElement(name="key")
 @JBossXmlMapValueElement(name="value")
 public Map getMap(){ return map; }
 

sequence of key and value elements wrapped inside entry element

 <entry>
   <key>key1</key>
   <value>value1</value>
 </entry>
 <entry>
   <key>key2</key>
   <value>value2</value>
 </entry>
 
 @JBossXmlMapEntry(name="entry")
 @JBossXmlMapKeyElemenet(name="key")
 @JBossXmlMapValueElement(name="value")
 public Map getMap(){ return map; }
 

key and value attributes in entry element

 <entry key='key1' value='value1'/>
 <entry key='key2' value='value2'/>
 
 @JBossXmlMapEntry(name="entry")
 @JBossXmlMapKeyAttribute(name="key")
 @JBossXmlMapValueAttribute(name="value")
 public Map getMap(){ return map; }
 

key is an attribute and the value is the value of entry element

 <entry key='key1'>value1</entry>
 <entry key='key2'>value2</entry>
 
 /**
  * value binding is not specified, it's supposed to be the value of entry element
  */
 @JBossXmlMapEntry(name="entry")
 @JBossXmlMapKeyAttribute(name="key")
 public Map getMap(){ return map; }
 

Author(s):
Alexey Loubyansky
Version:
$Revision: 1.1 $
 
 public @interface JBossXmlMapEntry
 {
    String name() default .;
    
    
    Class type() default DEFAULT.class;
   
   class DEFAULT {};
New to GrepCode? Check out our FAQ X