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)); attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
} else if (property.isString()) { } else if (property.isString()) {
intProperties[i] = storage.getDictionaryValue(vl); intProperties[i] = storage.getDictionaryValue(vl);
} else if (property.isFloat()) { } else {
if (floatProperties == null) { float floatVal = property.parseFloatValue(vl);
if (floatProperties == null && floatVal != 0) {
// lazy creates // lazy creates
floatProperties = new float[attributes.size()]; 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); intProperties[i] = property.parseIntValue(vl);
} }
i++; i++;

View file

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