Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*-
*******************************************************************************
* Copyright (c) 2015 Diamond Light Source Ltd.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* This file was auto-generated from the NXDL XML definition.
*******************************************************************************/
package org.eclipse.dawnsci.nexus.validation;
import static org.eclipse.dawnsci.nexus.validation.NexusDataType.NX_DATE_TIME;
import static org.eclipse.dawnsci.nexus.validation.NexusDataType.NX_FLOAT;
import static org.eclipse.dawnsci.nexus.validation.NexusDataType.NX_INT;
import static org.eclipse.dawnsci.nexus.validation.NexusUnitCategory.NX_ANGLE;
import static org.eclipse.dawnsci.nexus.validation.NexusUnitCategory.NX_ANY;
import static org.eclipse.dawnsci.nexus.validation.NexusUnitCategory.NX_WAVELENGTH;
import java.util.Map;
import org.eclipse.dawnsci.nexus.NXcrystal;
import org.eclipse.dawnsci.nexus.NXdata;
import org.eclipse.dawnsci.nexus.NXdetector;
import org.eclipse.dawnsci.nexus.NXentry;
import org.eclipse.dawnsci.nexus.NXinstrument;
import org.eclipse.dawnsci.nexus.NXmonitor;
import org.eclipse.dawnsci.nexus.NXroot;
import org.eclipse.dawnsci.nexus.NXsample;
import org.eclipse.dawnsci.nexus.NXsource;
import org.eclipse.dawnsci.nexus.NXsubentry;
import org.eclipse.january.dataset.IDataset;
/**
* Validator for the application definition 'NXmonopd'.
*/
public class NXmonopdValidator extends AbstractNexusValidator implements NexusApplicationValidator {
@Override
public void validate(NXroot root) throws NexusValidationException {
// validate child group 'entry' of type NXentry
validateGroup_entry(root.getEntry());
}
@Override
public void validate(NXentry entry) throws NexusValidationException {
validateGroup_entry(entry);
}
@Override
public void validate(NXsubentry subentry) throws NexusValidationException {
validateGroup_entry(subentry);
}
/**
* Validate group 'entry' of type NXentry.
*/
private void validateGroup_entry(final NXsubentry group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull("entry", NXentry.class, group);
// validate field 'title' of unknown type.
final IDataset title = group.getTitle();
validateFieldNotNull("title", title);
// validate field 'start_time' of type NX_DATE_TIME.
final IDataset start_time = group.getStart_time();
validateFieldNotNull("start_time", start_time);
validateFieldType("start_time", start_time, NX_DATE_TIME);
// validate field 'definition' of unknown type.
final IDataset definition = group.getDefinition();
validateFieldNotNull("definition", definition);
validateFieldEnumeration("definition", definition,
"NXmonopd");
// validate unnamed child group of type NXinstrument (possibly multiple)
final Map allInstrument = group.getAllInstrument();
for (final NXinstrument instrument : allInstrument.values()) {
validateGroup_entry_NXinstrument(instrument);
}
// validate unnamed child group of type NXsample (possibly multiple)
final Map allSample = group.getAllSample();
for (final NXsample sample : allSample.values()) {
validateGroup_entry_NXsample(sample);
}
// validate unnamed child group of type NXmonitor (possibly multiple)
final Map allMonitor = group.getAllMonitor();
for (final NXmonitor monitor : allMonitor.values()) {
validateGroup_entry_NXmonitor(monitor);
}
// validate unnamed child group of type NXdata (possibly multiple)
final Map allData = group.getAllData();
for (final NXdata data : allData.values()) {
validateGroup_entry_NXdata(data);
}
}
/**
* Validate unnamed group of type NXinstrument.
*/
private void validateGroup_entry_NXinstrument(final NXinstrument group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXinstrument.class, group);
// validate unnamed child group of type NXsource (possibly multiple)
final Map allSource = group.getAllSource();
for (final NXsource source : allSource.values()) {
validateGroup_entry_NXinstrument_NXsource(source);
}
// validate unnamed child group of type NXcrystal (possibly multiple)
final Map allCrystal = group.getAllCrystal();
for (final NXcrystal crystal : allCrystal.values()) {
validateGroup_entry_NXinstrument_NXcrystal(crystal);
}
// validate unnamed child group of type NXdetector (possibly multiple)
final Map allDetector = group.getAllDetector();
for (final NXdetector detector : allDetector.values()) {
validateGroup_entry_NXinstrument_NXdetector(detector);
}
}
/**
* Validate unnamed group of type NXsource.
*/
private void validateGroup_entry_NXinstrument_NXsource(final NXsource group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXsource.class, group);
// validate field 'type' of unknown type.
final IDataset type = group.getType();
validateFieldNotNull("type", type);
validateFieldEnumeration("type", type,
"Spallation Neutron Source",
"Pulsed Reactor Neutron Source",
"Reactor Neutron Source",
"Synchrotron X-ray Source",
"Pulsed Muon Source",
"Rotating Anode X-ray",
"Fixed Tube X-ray",
"UV Laser",
"Free-Electron Laser",
"Optical Laser",
"Ion Source",
"UV Plasma Source");
// validate field 'name' of unknown type.
final IDataset name = group.getName();
validateFieldNotNull("name", name);
// validate field 'probe' of unknown type.
final IDataset probe = group.getProbe();
validateFieldNotNull("probe", probe);
validateFieldEnumeration("probe", probe,
"neutron",
"x-ray",
"electron");
}
/**
* Validate unnamed group of type NXcrystal.
*/
private void validateGroup_entry_NXinstrument_NXcrystal(final NXcrystal group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXcrystal.class, group);
clearLocalGroupDimensionPlaceholderValues();
// validate field 'wavelength' of type NX_FLOAT.
final IDataset wavelength = group.getWavelength();
validateFieldNotNull("wavelength", wavelength);
validateFieldType("wavelength", wavelength, NX_FLOAT);
validateFieldUnits("wavelength", wavelength, NX_WAVELENGTH);
validateFieldRank("wavelength", wavelength, 1);
validateFieldDimensions("wavelength", wavelength, null, "i");
}
/**
* Validate unnamed group of type NXdetector.
*/
private void validateGroup_entry_NXinstrument_NXdetector(final NXdetector group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXdetector.class, group);
clearLocalGroupDimensionPlaceholderValues();
// validate field 'polar_angle' of type NX_FLOAT.
final IDataset polar_angle = group.getPolar_angle();
validateFieldNotNull("polar_angle", polar_angle);
validateFieldType("polar_angle", polar_angle, NX_FLOAT);
validateFieldUnits("polar_angle", polar_angle, NX_ANGLE);
validateFieldRank("polar_angle", polar_angle, 1);
validateFieldDimensions("polar_angle", polar_angle, null, "ndet");
// validate field 'data' of type NX_INT.
final IDataset data = group.getData();
validateFieldNotNull("data", data);
validateFieldType("data", data, NX_INT);
validateFieldUnits("data", data, NX_ANY);
validateFieldRank("data", data, 1);
validateFieldDimensions("data", data, null, "ndet");
}
/**
* Validate unnamed group of type NXsample.
*/
private void validateGroup_entry_NXsample(final NXsample group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXsample.class, group);
clearLocalGroupDimensionPlaceholderValues();
// validate field 'name' of unknown type.
final IDataset name = group.getName();
validateFieldNotNull("name", name);
// validate field 'rotation_angle' of type NX_FLOAT.
final IDataset rotation_angle = group.getRotation_angle();
validateFieldNotNull("rotation_angle", rotation_angle);
validateFieldType("rotation_angle", rotation_angle, NX_FLOAT);
validateFieldUnits("rotation_angle", rotation_angle, NX_ANGLE);
}
/**
* Validate unnamed group of type NXmonitor.
*/
private void validateGroup_entry_NXmonitor(final NXmonitor group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXmonitor.class, group);
clearLocalGroupDimensionPlaceholderValues();
// validate field 'mode' of unknown type.
final IDataset mode = group.getMode();
validateFieldNotNull("mode", mode);
validateFieldEnumeration("mode", mode,
"monitor",
"timer");
// validate field 'preset' of type NX_FLOAT.
final IDataset preset = group.getPreset();
validateFieldNotNull("preset", preset);
validateFieldType("preset", preset, NX_FLOAT);
validateFieldUnits("preset", preset, NX_ANY);
// validate field 'integral' of type NX_FLOAT.
final IDataset integral = group.getIntegral();
validateFieldNotNull("integral", integral);
validateFieldType("integral", integral, NX_FLOAT);
validateFieldUnits("integral", integral, NX_ANY);
}
/**
* Validate unnamed group of type NXdata.
*/
private void validateGroup_entry_NXdata(final NXdata group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXdata.class, group);
clearLocalGroupDimensionPlaceholderValues();
}
}