View Javadoc

1   /*
2    * Copyright 2006 Outsource Cafe, Inc.
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  package org.javagen.agile.core.xml.jaxb;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.xml.bind.annotation.XmlElement;
22  import javax.xml.bind.annotation.XmlType;
23  
24  import org.javagen.agile.core.model.Model;
25  
26  // Example XML:
27  
28  @XmlType
29  public class ContextType {
30      
31      private List<ContextEntryType> entries;
32  
33      private List<ContextModelEntryType> entryRefs;
34  
35      @XmlElement(name="entry")
36      public List<ContextEntryType> getEntries() {
37          return entries;
38      }
39  
40      public void setEntries(List<ContextEntryType> entries) {
41          this.entries = entries;
42      }
43  
44      public void addEntry(ContextEntryType entry) {
45          if (entries == null)
46              entries = new ArrayList<ContextEntryType>();
47          entries.add(entry);
48      }
49  
50      public void addEntry(String key, Object value) {
51          addEntry( new ContextEntryType(key, value) );
52      }
53  
54      @XmlElement(name="modelRef")
55      public List<ContextModelEntryType> getEntryRefs() {
56          return entryRefs;
57      }
58  
59      public void setEntryRefs(List<ContextModelEntryType> entryRefs) {
60          this.entryRefs = entryRefs;
61      }
62  
63      public void addEntryRef(ContextModelEntryType entryRef) {
64          if (entryRefs == null) 
65              entryRefs = new ArrayList<ContextModelEntryType>();
66          entryRefs.add(entryRef);
67      }
68  
69      public void addEntryRef(String name, Model model) {
70          addEntryRef(new ContextModelEntryType(name, model));
71      }
72  
73  }