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 implements AssociationMetadata {
31      public static final String ID = XmlAssociationMetadata.class.getName();
32  
33      public static final String EXPLODE_MODE = "explode";
34  
35      public static final String INLINE_MODE = "inline";
36  
37      public static final String ITEMS_STYLE_FLAT = "flat";
38  
39      public static final String ITEMS_STYLE_WRAPPED = "wrapped";
40  
41      private String tagName;
42  
43      private String itemsStyle = ITEMS_STYLE_WRAPPED;
44  
45      private String mapStyle = INLINE_MODE;
46  
47      private boolean reference;
48  
49      public String getTagName() {
50          return tagName;
51      }
52  
53      public void setTagName(String tagName) {
54          this.tagName = tagName;
55      }
56  
57      public String getItemsStyle() {
58          return itemsStyle;
59      }
60  
61      public void setItemsStyle(String itemsStyle) {
62          if (ITEMS_STYLE_FLAT.equals(itemsStyle) || ITEMS_STYLE_WRAPPED.equals(itemsStyle)) {
63              this.itemsStyle = itemsStyle;
64          } else {
65              // default
66              this.itemsStyle = ITEMS_STYLE_WRAPPED;
67          }
68      }
69  
70      public boolean isFlatItems() {
71          return ITEMS_STYLE_FLAT.equals(itemsStyle);
72      }
73  
74      public boolean isWrappedItems() {
75          return ITEMS_STYLE_WRAPPED.equals(itemsStyle);
76      }
77  
78      /**
79       * @return Returns the map style.
80       */
81      public String getMapStyle() {
82          return mapStyle;
83      }
84  
85      /**
86       * @param mapStyle The map style (inline or explode).
87       */
88      public void setMapStyle(String mapStyle) {
89          if (mapStyle == null) {
90              this.mapStyle = INLINE_MODE;
91          } else {
92              this.mapStyle = mapStyle;
93          }
94      }
95  
96      public boolean isMapInline() {
97          return INLINE_MODE.equals(mapStyle);
98      }
99  
100     public boolean isMapExplode() {
101         return EXPLODE_MODE.equals(mapStyle);
102     }
103 
104     public boolean isReference() {
105         return reference;
106     }
107 
108     public void setReference(boolean reference) {
109         this.reference = reference;
110     }
111 }