View Javadoc

1   package org.codehaus.modello.plugins.xml.metadata;
2   
3   /*
4    * Copyright (c) 2004, Codehaus.org
5    *
6    * Permission is hereby granted, free of charge, to any person obtaining a copy of
7    * this software and associated documentation files (the "Software"), to deal in
8    * the Software without restriction, including without limitation the rights to
9    * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10   * of the Software, and to permit persons to whom the Software is furnished to do
11   * so, subject to the following conditions:
12   *
13   * The above copyright notice and this permission notice shall be included in all
14   * copies or substantial portions of the Software.
15   *
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22   * SOFTWARE.
23   */
24  
25  import org.codehaus.modello.metadata.AssociationMetadata;
26  
27  /**
28   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
29   */
30  public class XmlAssociationMetadata
31      implements AssociationMetadata
32  {
33      public static final String ID = XmlAssociationMetadata.class.getName();
34  
35      public static final String EXPLODE_MODE = "explode";
36  
37      public static final String INLINE_MODE = "inline";
38  
39      public static final String ITEMS_STYLE_FLAT = "flat";
40  
41      public static final String ITEMS_STYLE_WRAPPED = "wrapped";
42  
43      private String tagName;
44  
45      private String itemsStyle = ITEMS_STYLE_WRAPPED;
46  
47      private String mapStyle = INLINE_MODE;
48  
49      private boolean reference;
50  
51      public String getTagName()
52      {
53          return tagName;
54      }
55  
56      public void setTagName( String tagName )
57      {
58          this.tagName = tagName;
59      }
60  
61      public String getItemsStyle()
62      {
63          return itemsStyle;
64      }
65  
66      public void setItemsStyle( String itemsStyle )
67      {
68          if ( ITEMS_STYLE_FLAT.equals( itemsStyle ) || ITEMS_STYLE_WRAPPED.equals( itemsStyle ) )
69          {
70              this.itemsStyle = itemsStyle;
71          }
72          else
73          {
74              // default
75              this.itemsStyle = ITEMS_STYLE_WRAPPED;
76          }
77      }
78  
79      public boolean isFlatItems()
80      {
81          return ITEMS_STYLE_FLAT.equals( itemsStyle );
82      }
83  
84      public boolean isWrappedItems()
85      {
86          return ITEMS_STYLE_WRAPPED.equals( itemsStyle );
87      }
88  
89      /**
90       * @return Returns the map style.
91       */
92      public String getMapStyle()
93      {
94          return mapStyle;
95      }
96  
97      /**
98       * @param mapStyle The map style (inline or explode).
99       */
100     public void setMapStyle( String mapStyle )
101     {
102         if ( mapStyle == null )
103         {
104             this.mapStyle = INLINE_MODE;
105         }
106         else
107         {
108             this.mapStyle = mapStyle;
109         }
110     }
111 
112     public boolean isMapInline()
113     {
114         return INLINE_MODE.equals( mapStyle );
115     }
116 
117     public boolean isMapExplode()
118     {
119         return EXPLODE_MODE.equals( mapStyle );
120     }
121 
122     public boolean isReference()
123     {
124         return reference;
125     }
126 
127     public void setReference( boolean reference )
128     {
129         this.reference = reference;
130     }
131 }