code: static Length  parseLength(String val) throws SVGParseException
     {
        if (val.length() == 0)
           throw new SVGParseException("Invalid length value (empty string)");
        int   end = val.length();
        Unit  unit = Unit.px;
        char  lastChar = val.charAt(end-1);
  
        if (lastChar == '%') {
           end -= 1;
           unit = Unit.percent;
        } else if (end > 2 && Character.isLetter(lastChar) && Character.isLetter(val.charAt(end-2))) {
           end -= 2;
           String unitStr = val.substring(end);
           try {
              unit = Unit.valueOf(unitStr.toLowerCase(Locale.US));
           } catch (IllegalArgumentException e) {
              throw new SVGParseException("Invalid length unit specifier: "+val);
           }
        }
        try
        {
           float scalar = parseFloat(val, 0, end);
           return new Length(scalar, unit);
        }
        catch (NumberFormatException e)
        {
           throw new SVGParseException("Invalid length value: "+val, e);
        }
     }
docs: /*
  Parse an SVG 'Length' value (usually a coordinate).
  Spec says: length ::= number ("em" | "ex" | "px" | "in" | "cm" | "mm" | "pt" | "pc" | "%")?