super("band", AxisSubsetType.class);
setService("wcs");
}
public Object parse(String value) throws Exception {
final AxisSubsetType axisSubset = Wcs10Factory.eINSTANCE.createAxisSubsetType();
axisSubset.setName("Band");
if (value.contains("/")) {
List<String> unparsed = KvpUtils.readFlat(value, new Tokenizer("/"));
IntervalType interval = Wcs10Factory.eINSTANCE.createIntervalType();
TypedLiteralType min = Wcs10Factory.eINSTANCE.createTypedLiteralType();
TypedLiteralType max = Wcs10Factory.eINSTANCE.createTypedLiteralType();
TypedLiteralType res = Wcs10Factory.eINSTANCE.createTypedLiteralType();
if (unparsed.size() == 2) {
min.setValue(unparsed.get(0));
max.setValue(unparsed.get(1));
interval.setMin(min);
interval.setMax(max);
} else {
min.setValue(unparsed.get(0));
max.setValue(unparsed.get(1));
res.setValue(unparsed.get(2));
interval.setMin(min);
interval.setMax(max);
interval.setRes(res);
}
axisSubset.getInterval().add(interval);
} else {
List<String> unparsed = KvpUtils.readFlat(value, KvpUtils.INNER_DELIMETER);
if (unparsed.size() == 0) {
throw new WcsException(
"Requested axis subset contains wrong number of values (should have at least 1): "
+ unparsed.size(), WcsExceptionCode.InvalidParameterValue, "band");
}
for (String bandValue : unparsed) {
TypedLiteralType singleValue = Wcs10Factory.eINSTANCE.createTypedLiteralType();
singleValue.setValue(bandValue);
axisSubset.getSingleValue().add(singleValue);
}
}
return axisSubset;
}