source: trunk/loci/formats/auto/AggregateMetadata.vm @ 3481

Revision 3481, 4.7 KB checked in by curtis, 12 years ago (diff)

Use Velocity template engine for metadata logic autogenerator.

Line 
1//
2// AggregateMetadata.java
3//
4
5/*
6LOCI Bio-Formats package for reading and converting biological file formats.
7Copyright (C) 2005-@year@ Melissa Linkert, Curtis Rueden, Chris Allan,
8Eric Kjellman and Brian Loranger.
9
10This program is free software; you can redistribute it and/or modify
11it under the terms of the GNU Library General Public License as published by
12the Free Software Foundation; either version 2 of the License, or
13(at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18GNU Library General Public License for more details.
19
20You should have received a copy of the GNU Library General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23*/
24
25/*-----------------------------------------------------------------------------
26 *
27 * THIS IS AUTOMATICALLY GENERATED CODE.  DO NOT MODIFY.
28 * Created by $user via MetadataAutogen on $timestamp
29 *
30 *-----------------------------------------------------------------------------
31 */
32
33package loci.formats.meta;
34
35import java.util.Iterator;
36import java.util.List;
37
38/**
39 * A metadata store which delegates the actual storage to one or more <i>sub</i>
40 * metadata stores.
41 *
42 * <dl><dt><b>Source code:</b></dt>
43 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/formats/AggregateMetadata.java">Trac</a>,
44 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/formats/AggregateMetadata.java">SVN</a></dd></dl>
45 *
46 * @author Chris Allan callan at blackcat.ca
47 * @author Curtis Rueden ctrueden at wisc.edu
48 */
49public class AggregateMetadata implements MetadataRetrieve, MetadataStore {
50
51  // -- Fields --
52
53  /** The active metadata store delegates. */
54  private List delegates;
55
56  // -- Constructor --
57
58  /**
59   * Creates a new instance.
60   * @param delegates of type {@link MetadataRetrieve}
61   *   and/or {@link MetadataStore}.
62   */
63  public AggregateMetadata(List delegates) {
64    this.delegates = delegates;
65  }
66
67  // -- AggregateMetadata API methods --
68
69  /**
70   * Adds a delegate to the metadata store.
71   * @param delegate a <code>MetadataStore</code>
72   */
73  public void addDelegate(MetadataStore delegate) {
74    delegates.add(delegate);
75  }
76
77  /**
78   * Removes a delegate from the metadata store.
79   * @param delegate a <code>MetadataStore</code>
80   */
81  public void removeDelegate(MetadataStore delegate) {
82    delegates.remove(delegate);
83  }
84
85  /**
86   * Retrieves the current list of metadata store delegates.
87   * @return list of {@link MetadataStore} delegates.
88   */
89  public List getDelegates() {
90    return delegates;
91  }
92
93  // -- MetadataRetrieve API methods --
94
95#foreach ($entity in $entities)
96  // -- $entity.name() property retrieval --
97
98#foreach ($prop in $entity.props())
99  /* @see MetadataRetrieve#get$entity.name()$prop.name()($entity.indicesList(true, false)) */
100  public $prop.type() get$entity.name()$prop.name()($entity.indicesList(true, true)) {
101    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
102      Object o = iter.next();
103      if (o instanceof MetadataRetrieve) {
104        MetadataRetrieve retrieve = (MetadataRetrieve) o;
105        $prop.type() result = retrieve.get$entity.name()$prop.name()($entity.indicesList(false, true));
106        if (result != null) return result;
107      }
108    }
109    return null;
110  }
111
112#end
113#end
114  // -- MetadataStore API methods --
115
116  /* @see MetadataStore#createRoot() */
117  public void createRoot() {
118    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
119      Object o = iter.next();
120      if (o instanceof MetadataStore) {
121        ((MetadataStore) o).createRoot();
122      }
123    }
124  }
125
126  /**
127   * Unsupported with an AggregateMetadata.
128   * @throws RuntimeException Always.
129   */
130  public Object getRoot() {
131    throw new RuntimeException("Unsupported with AggregateMetadata. " +
132      "Use getDelegates() and getRoot().");
133  }
134
135  /**
136   * Unsupported with an AggregateMetadata.
137   * @throws RuntimeException Always.
138   */
139  public void setRoot(Object root) {
140    throw new RuntimeException("Unsupported with AggregateMetadata. " +
141      "Use getDelegates() and setRoot().");
142  }
143
144#foreach ($entity in $entities)
145  /* @see MetadataStore#set$entity.name()($entity.argsList(true, false)) */
146  public void set$entity.name()($entity.argsList(true, true)) {
147    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
148      Object o = iter.next();
149      if (o instanceof MetadataStore) {
150        MetadataStore store = (MetadataStore) o;
151        store.set$entity.name()($entity.argsList(false, true));
152      }
153    }
154  }
155
156#end
157}
Note: See TracBrowser for help on using the repository browser.