void setFormData(WObject.FormData formData) { if (!(formData.values.length == 0)) { List<String> attributes = new ArrayList<String>(); attributes = new ArrayList<String>(Arrays.asList(formData.values[0].split(";"))); if (attributes.size() == 6) { try { this.volume_ = Double.parseDouble(attributes.get(0)); } catch (RuntimeException e) { this.volume_ = -1; } try { this.current_ = Double.parseDouble(attributes.get(1)); } catch (RuntimeException e) { this.current_ = -1; } try { this.duration_ = Double.parseDouble(attributes.get(2)); } catch (RuntimeException e) { this.duration_ = -1; } this.playing_ = attributes.get(3).equals("0"); this.ended_ = attributes.get(4).equals("1"); try { this.readyState_ = intToReadyState(Integer.parseInt(attributes.get(5))); } catch (RuntimeException e) { throw new WException( "WAbstractMedia: error parsing: " + formData.values[0] + ": " + e.toString()); } } else { throw new WException("WAbstractMedia: error parsing: " + formData.values[0]); } } }
static void decodeTouches(String str, List<Touch> result) { if (str.length() == 0) { return; } List<String> s = new ArrayList<String>(); s = new ArrayList<String>(Arrays.asList(str.split(";"))); if (s.size() % 9 != 0) { logger.error( new StringWriter() .append("Could not parse touches array '") .append(str) .append("'") .toString()); return; } try { for (int i = 0; i < s.size(); i += 9) { result.add( new Touch( asUInt(s.get(i + 0)), asInt(s.get(i + 1)), asInt(s.get(i + 2)), asInt(s.get(i + 3)), asInt(s.get(i + 4)), asInt(s.get(i + 5)), asInt(s.get(i + 6)), asInt(s.get(i + 7)), asInt(s.get(i + 8)))); } } catch (NumberFormatException ee) { logger.error( new StringWriter() .append("Could not parse touches array '") .append(str) .append("'") .toString()); return; } }