public BaseUnit getBaseUnit(String code) { for (BaseUnit unit : getBaseUnits()) { if (unit.getCode().equals(code)) return unit; } return null; }
private BaseUnit parseBaseUnit(XmlPullParser xpp) throws XmlPullParserException, IOException { BaseUnit base = new BaseUnit(xpp.getAttributeValue(null, "Code"), xpp.getAttributeValue(null, "CODE")); base.setDim(xpp.getAttributeValue(null, "dim").charAt(0)); xpp.next(); skipWhitespace(xpp); base.getNames().add(readElement(xpp, "name", "base-unit "+base.getCode(), false)); base.setPrintSymbol(readElement(xpp, "printSymbol", "base-unit "+base.getCode(), false)); base.setProperty(readElement(xpp, "property", "base-unit "+base.getCode(), false)); xpp.next(); skipWhitespace(xpp); return base; }
public String compose(Canonical can, boolean value) { StringBuilder b = new StringBuilder(); if (value) b.append(can.getValue().asDecimal()); boolean first = true; for (CanonicalUnit c : can.getUnits()) { if (first) first = false; else b.append("."); b.append(c.getBase().getCode()); if (c.getExponent() != 1) b.append(c.getExponent()); } return b.toString(); }
public BaseUnit getBaseUnit(String code) { for (BaseUnit unit : getBaseUnits()) { if (unit.getCode().equals(code)) return unit; } return null; }
private BaseUnit parseBaseUnit(XmlPullParser xpp) throws XmlPullParserException, IOException { BaseUnit base = new BaseUnit(xpp.getAttributeValue(null, "Code"), xpp.getAttributeValue(null, "CODE")); base.setDim(xpp.getAttributeValue(null, "dim").charAt(0)); xpp.next(); skipWhitespace(xpp); base.getNames().add(readElement(xpp, "name", "base-unit "+base.getCode(), false)); base.setPrintSymbol(readElement(xpp, "printSymbol", "base-unit "+base.getCode(), false)); base.setProperty(readElement(xpp, "property", "base-unit "+base.getCode(), false)); xpp.next(); skipWhitespace(xpp); return base; }
public String compose(Canonical can, boolean value) { StringBuilder b = new StringBuilder(); if (value) b.append(can.getValue().asDecimal()); boolean first = true; for (CanonicalUnit c : can.getUnits()) { if (first) first = false; else b.append("."); b.append(c.getBase().getCode()); if (c.getExponent() != 1) b.append(c.getExponent()); } return b.toString(); }