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

Revision 3605, 6.2 KB checked in by curtis, 12 years ago (diff)

Initial version of metadata framework with working object references
(i.e., DetectorSettings's Detector and LightSourceSettings's LightSource).

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/meta/AggregateMetadata.java">Trac</a>,
44 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/formats/meta/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  // - Entity counting -
96#foreach ($entity in $entities)
97#if ($entity.countable())
98
99  /* @see MetadataRetrieve#get$entity.name()Count($entity.indicesList(true, false, false)) */
100  public int get$entity.name()Count($entity.indicesList(true, true, false)) {
101    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
102      Object o = iter.next();
103      if (o instanceof MetadataRetrieve) {
104        MetadataRetrieve retrieve = (MetadataRetrieve) o;
105        int result = retrieve.get$entity.name()Count($entity.indicesList(false, true, false));
106        if (result >= 0) return result;
107      }
108    }
109    return -1;
110  }
111#end##if countable
112#end##foreach $entity
113
114  // - Entity retrieval -
115#foreach ($entity in $entities)
116
117  /* @see MetadataRetrieve#get$entity.name()($entity.indicesList(true, false)) */
118  public Object get$entity.name()($entity.indicesList(true, true)) {
119    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
120      Object o = iter.next();
121      if (o instanceof MetadataRetrieve) {
122        MetadataRetrieve retrieve = (MetadataRetrieve) o;
123        Object result = retrieve.get$entity.name()($entity.indicesList(false, true));
124        if (result != null) return result;
125      }
126    }
127    return null;
128  }
129#end##foreach $entity
130#foreach ($entity in $entities)
131
132  // - $entity.name() property retrieval -
133#foreach ($prop in $entity.props())
134
135  /* @see MetadataRetrieve#get$entity.name()$prop.name()($entity.indicesList(true, false)) */
136  public $prop.type(true) get$entity.name()$prop.name()($entity.indicesList(true, true)) {
137    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
138      Object o = iter.next();
139      if (o instanceof MetadataRetrieve) {
140        MetadataRetrieve retrieve = (MetadataRetrieve) o;
141        $prop.type(true) result = retrieve.get$entity.name()$prop.name()($entity.indicesList(false, true));
142        if (result != null) return result;
143      }
144    }
145    return null;
146  }
147#end##foreach $prop
148#end##foreach $entity
149
150  // -- MetadataStore API methods --
151
152  /* @see MetadataStore#createRoot() */
153  public void createRoot() {
154    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
155      Object o = iter.next();
156      if (o instanceof MetadataStore) {
157        ((MetadataStore) o).createRoot();
158      }
159    }
160  }
161
162  /**
163   * Unsupported with an AggregateMetadata.
164   * @throws RuntimeException Always.
165   */
166  public Object getRoot() {
167    throw new RuntimeException("Unsupported with AggregateMetadata. " +
168      "Use getDelegates() and getRoot().");
169  }
170
171  /**
172   * Unsupported with an AggregateMetadata.
173   * @throws RuntimeException Always.
174   */
175  public void setRoot(Object root) {
176    throw new RuntimeException("Unsupported with AggregateMetadata. " +
177      "Use getDelegates() and setRoot().");
178  }
179#foreach ($entity in $entities)
180
181  // - $entity.name() property storage -
182#foreach ($prop in $entity.props())
183
184  /* @see MetadataStore#set$entity.name()$prop.name()($prop.type(true), $entity.indicesList(true, false)) */
185  public void set$entity.name()$prop.name()($prop.type(true) $prop.varName(), $entity.indicesList(true, true)) {
186    for (Iterator iter = delegates.iterator(); iter.hasNext();) {
187      Object o = iter.next();
188      if (o instanceof MetadataStore) {
189        MetadataStore store = (MetadataStore) o;
190        store.set$entity.name()$prop.name()($prop.varName(), $entity.indicesList(false, true));
191      }
192    }
193  }
194#end##foreach $prop
195#end##foreach $entity
196
197}
Note: See TracBrowser for help on using the repository browser.