public NormalPlayTime(long milliseconds) { if (milliseconds < 0) { throw new InvalidValueException("Invalid parameter milliseconds: " + milliseconds); } this.milliseconds = milliseconds; }
/** * @param milliseconds the milliseconds to set */ public void setMilliseconds(long milliseconds) { if (milliseconds < 0) { throw new InvalidValueException("Invalid parameter milliseconds: " + milliseconds); } this.milliseconds = milliseconds; }
public TransportPlaySpeed(String value) { super(value); if (!pattern.matcher(value).matches()) { throw new InvalidValueException("Can't parse TransportPlaySpeed speeds."); } }
public Double valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return Double.parseDouble(s); } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number: " + s, ex); } }
public Float valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return Float.parseFloat(s.trim()); } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number: " + s, ex); } }
public URI valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return new URI(s); } catch (URISyntaxException ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
public Short valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { Short value = Short.parseShort(s.trim()); if (!isValid(value)) { throw new InvalidValueException("Not a valid short: " + s); } return value; } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number: " + s, ex); } }
public static UDAServiceType valueOf(String s) throws InvalidValueException { Matcher matcher = UDAServiceType.PATTERN.matcher(s); try { if (matcher.matches()) return new UDAServiceType(matcher.group(1), Integer.valueOf(matcher.group(2))); } catch (RuntimeException e) { throw new InvalidValueException(String.format( "Can't parse UDA service type string (namespace/type/version) '%s': %s", s, e.toString())); } throw new InvalidValueException("Can't parse UDA service type string (namespace/type/version): " + s); }
public Boolean valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; if (s.equals("1") || s.toUpperCase(Locale.ROOT).equals("YES") || s.toUpperCase(Locale.ROOT).equals("TRUE")) { return true; } else if (s.equals("0") || s.toUpperCase(Locale.ROOT).equals("NO") || s.toUpperCase(Locale.ROOT).equals("FALSE")) { return false; } else { throw new InvalidValueException("Invalid boolean value string: " + s); } }
public ProtocolInfo(String s) throws InvalidValueException { if (s == null) throw new NullPointerException(); s = s.trim(); String[] split = s.split(":"); if (split.length != 4) { throw new InvalidValueException("Can't parse ProtocolInfo string: " + s); } this.protocol = Protocol.value(split[0]); this.network = split[1]; this.contentFormat = split[2]; this.additionalInfo = split[3]; }
public UnsignedIntegerFourBytes valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return new UnsignedIntegerFourBytes(s); } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number or not in range: " + s, ex); } }
public static DLNADoc valueOf(String s) throws InvalidValueException { Matcher matcher = PATTERN.matcher(s); if (matcher.matches()) { return new DLNADoc(matcher.group(1), matcher.group(2)); } else { throw new InvalidValueException("Can't parse DLNADoc: " + s); } }
public byte[] valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return Base64Coder.decode(s); } catch (Exception ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
@Override public String getString(byte[] value) throws InvalidValueException { if (value == null) return ""; try { return HexBin.bytesToString(value); } catch (Exception ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
public String getString(V value) throws InvalidValueException { if (value == null) return ""; if (!isValid(value)) { throw new InvalidValueException("Value is not valid: " + value); } return value.toString(); }
@Override public String getString(byte[] value) throws InvalidValueException { if (value == null) return ""; try { return new String(Base64Coder.encode(value), "UTF-8"); } catch (Exception ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
public byte[] valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return HexBin.stringToBytes(s); } catch (Exception ex) { throw new InvalidValueException(ex.getMessage(), ex); } }
public UnsignedIntegerTwoBytes valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return new UnsignedIntegerTwoBytes(s); } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number or not in range: " + s, ex); } }
public UnsignedIntegerOneByte valueOf(String s) throws InvalidValueException { if (s.equals("")) return null; try { return new UnsignedIntegerOneByte(s); } catch (NumberFormatException ex) { throw new InvalidValueException("Can't convert string to number or not in range: " + s, ex); } }
protected Datatype.Builtin getBuiltinDatatype() throws InvalidValueException { Class csvType = Reflections.getTypeArguments(ArrayList.class, getClass()).get(0); Datatype.Default defaultType = Datatype.Default.getByJavaType(csvType); if (defaultType == null) { throw new InvalidValueException("No built-in UPnP datatype for Java type of CSV: " + csvType); } return defaultType.getBuiltinType(); }