int gcd = findGreatestCommonDenominator(height, width);
if (outputFormat == AspectRatioOutputFormat.RATIO) {
String ratio = "" + (width/gcd) + SEPARATOR + (height/gcd);
// return the whole ratio as a string value
value = new SimpleStringValue(factory, ratio);
} else if (outputFormat == AspectRatioOutputFormat.WIDTH) {
// return the ratio component as a int value
value = new SimpleIntValue(factory, width/gcd);
} else if (outputFormat == AspectRatioOutputFormat.HEIGHT) {
// return the ratio component as a int value
value = new SimpleIntValue(factory, height/gcd);
}
} catch (NumberFormatException e) {
// log it but return continue
String badValue = "One of " + heightInPixels + " or " +
widthInPixels;
String policyNames = "One of "+
DevicePolicyConstants.ACTUAL_HEIGHT_IN_PIXELS +
" or " + DevicePolicyConstants.ACTUAL_WIDTH_IN_PIXELS;
LOGGER.info("function-bad-parameter-value",
new Object[] {badValue, policyNames});
}
}
if (value == null) {
// No value could be retrieved from the repository, so verify that
// the default value is of the correct type.
if (outputFormat == AspectRatioOutputFormat.RATIO) {
if (defaultValue instanceof StringValue) {
value = defaultValue;
} else {
if (defaultValue != null) {
// log the fact that the default was present but wrong
LOGGER.info("function-bad-default-value", "StringValue");
}
value = new SimpleStringValue(factory, "");
}
} else if (outputFormat == AspectRatioOutputFormat.WIDTH ||
outputFormat == AspectRatioOutputFormat.HEIGHT ) {
if (defaultValue instanceof IntValue) {
value = defaultValue;