if (rotationParams.length == 2) {
String pageNumber = rotationParams[0].trim();
int degrees = Integer.parseInt(rotationParams[1]) % 360;
// must be a multiple of 90
if ((degrees % 90) != 0) {
throw new ValidationException(ValidationException.ERR_DEGREES_NOT_ALLOWED, new String[] { Integer.toString(degrees) });
}
// rotate all
if (ALL_STRING.equals(pageNumber)) {
if (!retVal.isEmpty()) {
LOG.warn("Page rotation for every page found, other rotations removed");
retVal.clear();
}
retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.ALL_PAGES));
break;
} else if (ODD_STRING.equals(pageNumber)) {
if (!retVal.isEmpty()) {
LOG.warn("Page rotation for odd pages found, other rotations removed");
retVal.clear();
}
retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.ODD_PAGES));
break;
} else if (EVEN_STRING.equals(pageNumber)) {
if (!retVal.isEmpty()) {
LOG.warn("Page rotation for even pages found, other rotations removed");
retVal.clear();
}
retVal.add(new PageRotation(PageRotation.NO_PAGE, degrees, PageRotation.EVEN_PAGES));
break;
} else {
if (allowSinglePagesRotation) {
retVal.add(new PageRotation(Integer.parseInt(pageNumber), degrees));
}
}
} else {
throw new ValidationException(ValidationException.ERR_PARAM_ROTATION, new String[] { currentRotation });
}
} else {
throw new ValidationException(ValidationException.ERR_PARAM_ROTATION, new String[] { currentRotation });
}
}
}
} catch (Exception e) {
throw new ValidationException(ValidationException.ERR_WRONG_ROTATION, e);
}
return (PageRotation[]) retVal.toArray(new PageRotation[retVal.size()]);
}