/*
* ome.xml.model.LightPath
*
*-----------------------------------------------------------------------------
*
* Copyright (C) @year@ Open Microscopy Environment
* Massachusetts Institute of Technology,
* National Institutes of Health,
* University of Dundee,
* University of Wisconsin-Madison
*
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*-----------------------------------------------------------------------------
*/
/*-----------------------------------------------------------------------------
*
* THIS IS AUTOMATICALLY GENERATED CODE. DO NOT MODIFY.
* Created by melissa via xsd-fu on 2011-11-09 10:55:09-0500
*
*-----------------------------------------------------------------------------
*/
package ome.xml.model;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ome.xml.model.enums.*;
import ome.xml.model.primitives.*;
public class LightPath extends AbstractOMEModelObject
{
// Base: -- Name: LightPath -- Type: LightPath -- javaBase: AbstractOMEModelObject -- javaType: Object
// -- Constants --
public static final String NAMESPACE = "http://www.openmicroscopy.org/Schemas/OME/2011-06";
/** Logger for this class. */
private static final Logger LOGGER =
LoggerFactory.getLogger(LightPath.class);
// -- Instance variables --
// Reference ExcitationFilterRef
private List<Filter> excitationFilterList = new ArrayList<Filter>();
// Property
private Dichroic dichroic;
// Reference EmissionFilterRef
private List<Filter> emissionFilterList = new ArrayList<Filter>();
// -- Constructors --
/** Default constructor. */
public LightPath()
{
super();
}
/**
* Constructs LightPath recursively from an XML DOM tree.
* @param element Root of the XML DOM tree to construct a model object
* graph from.
* @param model Handler for the OME model which keeps track of instances
* and references seen during object population.
* @throws EnumerationException If there is an error instantiating an
* enumeration during model object creation.
*/
public LightPath(Element element, OMEModel model)
throws EnumerationException
{
update(element, model);
}
// -- Custom content from LightPath specific template --
// -- OMEModelObject API methods --
/**
* Updates LightPath recursively from an XML DOM tree. <b>NOTE:</b> No
* properties are removed, only added or updated.
* @param element Root of the XML DOM tree to construct a model object
* graph from.
* @param model Handler for the OME model which keeps track of instances
* and references seen during object population.
* @throws EnumerationException If there is an error instantiating an
* enumeration during model object creation.
*/
public void update(Element element, OMEModel model)
throws EnumerationException
{
super.update(element, model);
String tagName = element.getTagName();
if (!"LightPath".equals(tagName))
{
LOGGER.debug("Expecting node name of LightPath got {}", tagName);
}
// Element reference ExcitationFilterRef
List<Element> ExcitationFilterRef_nodeList =
getChildrenByTagName(element, "ExcitationFilterRef");
for (Element ExcitationFilterRef_element : ExcitationFilterRef_nodeList)
{
ExcitationFilterRef excitationFilterList_reference = new ExcitationFilterRef();
excitationFilterList_reference.setID(ExcitationFilterRef_element.getAttribute("ID"));
model.addReference(this, excitationFilterList_reference);
}
// Element reference DichroicRef
List<Element> DichroicRef_nodeList =
getChildrenByTagName(element, "DichroicRef");
for (Element DichroicRef_element : DichroicRef_nodeList)
{
DichroicRef dichroic_reference = new DichroicRef();
dichroic_reference.setID(DichroicRef_element.getAttribute("ID"));
model.addReference(this, dichroic_reference);
}
// Element reference EmissionFilterRef
List<Element> EmissionFilterRef_nodeList =
getChildrenByTagName(element, "EmissionFilterRef");
for (Element EmissionFilterRef_element : EmissionFilterRef_nodeList)
{
EmissionFilterRef emissionFilterList_reference = new EmissionFilterRef();
emissionFilterList_reference.setID(EmissionFilterRef_element.getAttribute("ID"));
model.addReference(this, emissionFilterList_reference);
}
}
// -- LightPath API methods --
public boolean link(Reference reference, OMEModelObject o)
{
boolean wasHandledBySuperClass = super.link(reference, o);
if (wasHandledBySuperClass)
{
return true;
}
if (reference instanceof ExcitationFilterRef)
{
Filter o_casted = (Filter) o;
o_casted.linkLightPath(this);
excitationFilterList.add(o_casted);
return true;
}
if (reference instanceof DichroicRef)
{
Dichroic o_casted = (Dichroic) o;
o_casted.linkLightPath(this);
dichroic = o_casted;
return true;
}
if (reference instanceof EmissionFilterRef)
{
Filter o_casted = (Filter) o;
o_casted.linkLightPath(this);
emissionFilterList.add(o_casted);
return true;
}
LOGGER.debug("Unable to handle reference of type: {}", reference.getClass());
return false;
}
// Reference which occurs more than once
public int sizeOfLinkedExcitationFilterList()
{
return excitationFilterList.size();
}
public List<Filter> copyLinkedExcitationFilterList()
{
return new ArrayList<Filter>(excitationFilterList);
}
public Filter getLinkedExcitationFilter(int index)
{
return excitationFilterList.get(index);
}
public Filter setLinkedExcitationFilter(int index, Filter o)
{
return excitationFilterList.set(index, o);
}
public boolean linkExcitationFilter(Filter o)
{
o.linkLightPath(this);
return excitationFilterList.add(o);
}
public boolean unlinkExcitationFilter(Filter o)
{
o.unlinkLightPath(this);
return excitationFilterList.remove(o);
}
// Reference
public Dichroic getLinkedDichroic()
{
return dichroic;
}
public void linkDichroic(Dichroic o)
{
dichroic = o;
}
public void unlinkDichroic(Dichroic o)
{
if (dichroic == o)
{
dichroic = null;
}
}
// Reference which occurs more than once
public int sizeOfLinkedEmissionFilterList()
{
return emissionFilterList.size();
}
public List<Filter> copyLinkedEmissionFilterList()
{
return new ArrayList<Filter>(emissionFilterList);
}
public Filter getLinkedEmissionFilter(int index)
{
return emissionFilterList.get(index);
}
public Filter setLinkedEmissionFilter(int index, Filter o)
{
return emissionFilterList.set(index, o);
}
public boolean linkEmissionFilter(Filter o)
{
o.linkLightPath(this);
return emissionFilterList.add(o);
}
public boolean unlinkEmissionFilter(Filter o)
{
o.unlinkLightPath(this);
return emissionFilterList.remove(o);
}
public Element asXMLElement(Document document)
{
return asXMLElement(document, null);
}
protected Element asXMLElement(Document document, Element LightPath_element)
{
// Creating XML block for LightPath
if (LightPath_element == null)
{
LightPath_element =
document.createElementNS(NAMESPACE, "LightPath");
}
if (excitationFilterList != null)
{
// Reference property ExcitationFilterRef which occurs more than once
for (Filter excitationFilterList_value : excitationFilterList)
{
ExcitationFilterRef o = new ExcitationFilterRef();
o.setID(excitationFilterList_value.getID());
LightPath_element.appendChild(o.asXMLElement(document));
}
}
if (dichroic != null)
{
// Reference property DichroicRef
DichroicRef o = new DichroicRef();
o.setID(dichroic.getID());
LightPath_element.appendChild(o.asXMLElement(document));
}
if (emissionFilterList != null)
{
// Reference property EmissionFilterRef which occurs more than once
for (Filter emissionFilterList_value : emissionFilterList)
{
EmissionFilterRef o = new EmissionFilterRef();
o.setID(emissionFilterList_value.getID());
LightPath_element.appendChild(o.asXMLElement(document));
}
}
return super.asXMLElement(document, LightPath_element);
}
}