Fix parse complex properties

This commit is contained in:
Victor Shcherb 2020-10-18 02:28:44 +02:00
parent 28fdd139fb
commit 07c297a95a
2 changed files with 22 additions and 23 deletions

View file

@ -58,14 +58,13 @@ public class RenderingRule {
attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
} else if (property.isString()) {
intProperties[i] = storage.getDictionaryValue(vl);
} else if (property.isFloat()) {
if (floatProperties == null) {
} else {
float floatVal = property.parseFloatValue(vl);
if (floatProperties == null && floatVal != 0) {
// lazy creates
floatProperties = new float[attributes.size()];
floatProperties[i] = property.parseFloatValue(vl);
}
floatProperties[i] = property.parseFloatValue(vl);
intProperties[i] = property.parseIntValue(vl);
} else {
intProperties[i] = property.parseIntValue(vl);
}
i++;

View file

@ -155,12 +155,7 @@ public class RenderingRuleProperty {
try {
int colon = value.indexOf(':');
if(colon != -1) {
int c = 0;
if(colon > 0) {
c += (int) Float.parseFloat(value.substring(0, colon));
}
c += (int) Float.parseFloat(value.substring(colon + 1));
return c;
return (int) Float.parseFloat(value.substring(colon + 1));
}
return (int) Float.parseFloat(value);
} catch (NumberFormatException e) {
@ -190,30 +185,35 @@ public class RenderingRuleProperty {
} catch (NumberFormatException e) {
log.error("Rendering parse " + value + " in " + attrName);
}
return -1;
return 0;
} else {
return -1;
}
}
public float parseFloatValue(String value){
if(type == FLOAT_TYPE){
try {
public float parseFloatValue(String value) {
try {
if (type == FLOAT_TYPE) {
int colon = value.indexOf(':');
if(colon != -1) {
if(colon > 0) {
if (colon != -1) {
if (colon > 0) {
return Float.parseFloat(value.substring(0, colon));
}
}
return 0;
}
return Float.parseFloat(value);
} catch (NumberFormatException e) {
log.error("Rendering parse " + value + " in " + attrName);
} else if (type == INT_TYPE) {
int colon = value.indexOf(':');
if (colon != -1 && colon > 0) {
return Float.parseFloat(value.substring(0, colon));
}
return 0;
}
return -1;
} else {
return -1;
} catch (NumberFormatException e) {
log.error("Rendering parse " + value + " in " + attrName);
}
return 0;
}