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_CHAR;
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 java.util.Map;
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.NXsubentry;
import org.eclipse.january.dataset.IDataset;
/**
* Validator for the application definition 'NXscan'.
*/
public class NXscanValidator extends AbstractNexusValidator implements NexusApplicationValidator {
@Override
public void validate(NXroot root) throws NexusValidationException {
// validate unnamed child group of type NXentry (possibly multiple)
final Map allEntry = root.getAllEntry();
for (final NXentry entry : allEntry.values()) {
validateGroup_NXentry(entry);
}
}
@Override
public void validate(NXentry entry) throws NexusValidationException {
validateGroup_NXentry(entry);
}
@Override
public void validate(NXsubentry subentry) throws NexusValidationException {
validateGroup_NXentry(subentry);
}
/**
* Validate unnamed group of type NXentry.
*/
private void validateGroup_NXentry(final NXsubentry group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, 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 'end_time' of type NX_DATE_TIME.
final IDataset end_time = group.getEnd_time();
validateFieldNotNull("end_time", end_time);
validateFieldType("end_time", end_time, NX_DATE_TIME);
// validate field 'definition' of type NX_CHAR.
final IDataset definition = group.getDefinition();
validateFieldNotNull("definition", definition);
validateFieldType("definition", definition, NX_CHAR);
validateFieldEnumeration("definition", definition,
"NXscan");
// validate unnamed child group of type NXinstrument (possibly multiple)
final Map allInstrument = group.getAllInstrument();
for (final NXinstrument instrument : allInstrument.values()) {
validateGroup_NXentry_NXinstrument(instrument);
}
// validate unnamed child group of type NXsample (possibly multiple)
final Map allSample = group.getAllSample();
for (final NXsample sample : allSample.values()) {
validateGroup_NXentry_NXsample(sample);
}
// validate unnamed child group of type NXmonitor (possibly multiple)
final Map allMonitor = group.getAllMonitor();
for (final NXmonitor monitor : allMonitor.values()) {
validateGroup_NXentry_NXmonitor(monitor);
}
// validate unnamed child group of type NXdata (possibly multiple)
final Map allData = group.getAllData();
for (final NXdata data : allData.values()) {
validateGroup_NXentry_NXdata(data);
}
}
/**
* Validate unnamed group of type NXinstrument.
*/
private void validateGroup_NXentry_NXinstrument(final NXinstrument group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXinstrument.class, group);
// validate unnamed child group of type NXdetector (possibly multiple)
final Map allDetector = group.getAllDetector();
for (final NXdetector detector : allDetector.values()) {
validateGroup_NXentry_NXinstrument_NXdetector(detector);
}
}
/**
* Validate unnamed group of type NXdetector.
*/
private void validateGroup_NXentry_NXinstrument_NXdetector(final NXdetector group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXdetector.class, group);
clearLocalGroupDimensionPlaceholderValues();
// 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, 3);
validateFieldDimensions("data", data, null, "NP", "xdim", "ydim");
}
/**
* Validate unnamed group of type NXsample.
*/
private void validateGroup_NXentry_NXsample(final NXsample group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXsample.class, group);
clearLocalGroupDimensionPlaceholderValues();
// 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);
validateFieldRank("rotation_angle", rotation_angle, 1);
validateFieldDimensions("rotation_angle", rotation_angle, null, "NP");
}
/**
* Validate unnamed group of type NXmonitor.
*/
private void validateGroup_NXentry_NXmonitor(final NXmonitor group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXmonitor.class, group);
clearLocalGroupDimensionPlaceholderValues();
// 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, "NP");
}
/**
* Validate unnamed group of type NXdata.
*/
private void validateGroup_NXentry_NXdata(final NXdata group) throws NexusValidationException {
// validate that the group is not null
validateGroupNotNull(null, NXdata.class, group);
clearLocalGroupDimensionPlaceholderValues();
}
}