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

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

Use Velocity template engine for metadata logic autogenerator.

Line 
1//
2// $id
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.ome;
34
35import $basePackage.*;
36import $basePackage.$subPackage.*;
37import java.util.List;
38
39/**
40 * A utility class for constructing and manipulating OME-XML DOMs for the
41 * $version version of OME-XML. It requires the
42 * $basePackage package to compile (part of ome-java.jar).
43 *
44 * <dl><dt><b>Source code:</b></dt>
45 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/formats/ome/$id">Trac</a>,
46 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/loci/formats/ome/$id">SVN</a></dd></dl>
47 *
48 * @author Curtis Rueden ctrueden at wisc.edu
49 * @author Melissa Linkert linkert at wisc.edu
50 */
51public class $class extends OMEXMLMetadata {
52
53  // -- OMEXMLMetadata API methods --
54
55  /* @see OMEXMLMetadata#createRoot(String) */
56  public void createRoot(String xml) {
57    // CTR TEMP
58  }
59
60  /* @see OMEXMLMetadata#dumpXML() */
61  public String dumpXML() {
62    // CTR TEMP
63    return null;
64  }
65
66  // -- MetadataRetrieve API methods --
67#foreach ($entity in $entities)
68#set ($last = $entity.last($versionKey))
69#set ($lastVar = $entity.lastVar($versionKey))
70
71  // -- $entity.name() property retrieval --
72#foreach ($prop in $entity.props())
73#set ($mappedName = $prop.mappedName($versionKey))
74
75  public $prop.type() get$entity.name()$prop.name()($entity.indicesList(true, true)) {
76#if ($mappedName == "-")
77    // NB: $prop.name() unsupported for schema version $version
78    return null;
79#else
80    ${last}Node $lastVar = get$last($entity.indicesList(false, true), false);
81    return $lastVar == null ? null : ${lastVar}.get$mappedName();
82#end##if
83  }
84#end##foreach $prop
85#end##foreach $entity
86
87  // -- MetadataStore API methods --
88#foreach ($entity in $entities)
89#set ($last = $entity.last($versionKey))
90#set ($lastVar = $entity.lastVar($versionKey))
91
92  public void set$entity.name()($entity.argsList(true, true)) {
93    ${last}Node $lastVar = get$last($entity.indicesList(false, true), true);
94#foreach ($prop in $entity.props())
95#set ($mappedName = $prop.mappedName($versionKey))
96#set ($mappedNameVar = $prop.mappedNameVar($versionKey))
97#if ($mappedName == "-")
98    // NB: $prop.name() unsupported for schema version $version
99#else
100    if ($mappedNameVar != null) ${lastVar}.set$mappedName($mappedNameVar);
101#end##if
102#end##foreach $prop
103  }
104#end##foreach $entity
105
106  // -- Helper methods --
107#foreach ($entity in $unique)
108#set ($last = $entity.last($versionKey))
109#set ($lastVar = $entity.lastVar($versionKey))
110
111  // $entity.path($versionKey)
112  private ${last}Node get$last($entity.indicesList(true, true), boolean create) {
113    int ndx, count;
114    List list;
115    // get OME node
116    OMENode ome = (OMENode) root;
117#set ($var = "ome")
118#set ($pVar = "ome")
119#set ($pNode = "OME")
120#set ($multiCount = 0)
121#foreach ($node in $entity.pathNodes($versionKey))
122#set ($multi = $node.endsWith("+"))
123#set ($ref = $node.startsWith("@"))
124#set ($bang = $node.startsWith("@!"))
125#set ($node = $node.replaceAll("[@!+]", ""))
126#set ($ca = $pVar.equals("ca"))
127#set ($var = $entity.toVarName($node))
128    // get $node node
129#if ($node.equals("CA"))
130#set ($node = "CustomAttributes")
131#end##if
132#if ($multi)
133#set ($prop = $entity.indices().get($multiCount))
134#set ($multiCount = $multiCount + 1)
135    ndx = i2i($prop.varName());
136#if ($ca)
137    count = ${pVar}.countCAList("$node");
138#elseif ($legacy)
139    count = ${pVar}.count${node}List();
140#else
141    count = ${pVar}.get${node}Count();
142#end##if $ca
143    if (!create && ndx >= count) return null;
144#if ($ref)
145    for (int i=count; i<=ndx; i++) {
146      new ${node}Node(ca).set$pNode($pVar);
147    }
148#else
149    for (int i=count; i<=ndx; i++) new ${node}Node($pVar);
150#end##if $ref
151#if ($ca)
152    list = ${pVar}.getCAList("$node");
153#else
154    list = ${pVar}.get${node}List();
155#end##if $ca
156    ${node}Node $var = (${node}Node) list.get(ndx);
157#else
158#if ($ca || $ref)
159#if ($bang)
160#set ($extra = "By$pNode")
161#else
162#set ($extra = "")
163#end##if $bang
164    ${node}Node $var = null;
165#if ($ca)
166    count = ca.countCAList("$node");
167    if (count >= 1) {
168      $var = (${node}Node) ca.getCAList("$node").get(0);
169    }
170#else
171    count = ${pVar}.count${node}List$extra();
172    if (count >= 1) {
173      $var = (${node}Node) ${pVar}.get${node}List$extra().get(0);
174    }
175#end##if $ca
176#else
177    ${node}Node $var = ${pVar}.get$node();
178#end##if $ca || $ref
179    if ($var == null) {
180      if (!create) return null;
181#if ($ref)
182      $var = new ${node}Node(ca);
183      ${var}.set$pNode($pVar);
184#else
185      $var = new ${node}Node($pVar);
186#end##if $ref
187    }
188#end##if $multi
189#set ($pNode = $node)
190#set ($pVar = $var)
191#end##foreach $node
192    return $var;
193  }
194#end##foreach $entity
195}
Note: See TracBrowser for help on using the repository browser.