public NormalPlayTime(long milliseconds) { if (milliseconds < 0) { throw new InvalidValueException("Invalid parameter milliseconds: " + milliseconds); } this.milliseconds = milliseconds; }
public void setString(String s) throws InvalidHeaderException { try { setValue(PragmaType.valueOf(s)); } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage()); } }
mode = AvailableSeekRangeType.Mode.valueOf("MODE_" + params[0]); } catch (IllegalArgumentException e) { throw new InvalidValueException("Invalid AvailableSeekRange Mode"); useTime = false; } catch (InvalidValueException bytesInvalidValueException) { throw new InvalidValueException("Invalid AvailableSeekRange Range"); throw new InvalidHeaderException("Invalid AvailableSeekRange header value: " + s + "; " + invalidValueException.getMessage());
public void setString(String s) throws InvalidHeaderException { try { setValue(BytesRange.valueOf(s)); } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage()); } }
/** * @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 void setString(String s) throws InvalidHeaderException { try { setValue(BytesRange.valueOf(s,PREFIX)); } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage()); } }
public NormalPlayTime(long hours, long minutes, long seconds, long milliseconds) throws InvalidValueException { if (hours < 0) { throw new InvalidValueException("Invalid parameter hours: " + hours); } if (minutes < 0 || minutes > 59) { throw new InvalidValueException("Invalid parameter minutes: " + hours); } if (seconds < 0 || seconds > 59) { throw new InvalidValueException("Invalid parameter seconds: " + hours); } if (milliseconds < 0 || milliseconds > 999) { throw new InvalidValueException("Invalid parameter milliseconds: " + milliseconds); } this.milliseconds = (hours * 60 * 60 + minutes * 60 + seconds) * 1000 + milliseconds; }
/** * Creates an instance of {@link ActionArgumentValue} and wraps an * {@link InvalidValueException} as an {@link ActionException} with the * appropriate {@link ErrorCode}. */ protected ActionArgumentValue createValue(ActionArgument arg, String value) throws ActionException { try { return new ActionArgumentValue(arg, value); } catch (InvalidValueException ex) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Wrong type or invalid value for '" + arg.getName() + "': " + ex.getMessage(), ex ); } }
public TransportPlaySpeed(String value) { super(value); if (!pattern.matcher(value).matches()) { throw new InvalidValueException("Can't parse TransportPlaySpeed speeds."); } }
@Override public void setString(String s) throws InvalidHeaderException { if (s.length() != 0) { String[] params = s.split(" "); if (params.length>0) { try { TimeSeekRangeType t = new TimeSeekRangeType(NormalPlayTimeRange.valueOf(params[0])); if (params.length > 1) { t.setBytesRange(BytesRange.valueOf(params[1])); } setValue(t); return; } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s + "; "+invalidValueException.getMessage()); } } } throw new InvalidHeaderException("Invalid TimeSeekRange header value: " + s); }
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); } }
/** * Sets the output argument value on the {@link org.fourthline.cling.model.action.ActionInvocation}, considers string conversion. */ protected void setOutputArgumentValue(ActionInvocation<LocalService> actionInvocation, ActionArgument<LocalService> argument, Object result) throws ActionException { LocalService service = actionInvocation.getAction().getService(); if (result != null) { try { if (service.isStringConvertibleType(result)) { log.fine("Result of invocation matches convertible type, setting toString() single output argument value"); actionInvocation.setOutput(new ActionArgumentValue(argument, result.toString())); } else { log.fine("Result of invocation is Object, setting single output argument value"); actionInvocation.setOutput(new ActionArgumentValue(argument, result)); } } catch (InvalidValueException ex) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Wrong type or invalid value for '" + argument.getName() + "': " + ex.getMessage(), ex ); } } else { log.fine("Result of invocation is null, not setting any output argument value(s)"); } }
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); } }
} catch (InvalidValueException ex) { log.warning( "UPnP specification violation, skipping invalid service declaration. " + ex.getMessage() );
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); } }
@Override public void endElement(ELEMENT element) throws SAXException { try { switch (element) { case serviceType: getInstance().serviceType = ServiceType.valueOf(getCharacters()); break; case serviceId: getInstance().serviceId = ServiceId.valueOf(getCharacters()); break; case SCPDURL: getInstance().descriptorURI = parseURI(getCharacters()); break; case controlURL: getInstance().controlURI = parseURI(getCharacters()); break; case eventSubURL: getInstance().eventSubscriptionURI = parseURI(getCharacters()); break; } } catch (InvalidValueException ex) { log.warning( "UPnP specification violation, skipping invalid service declaration. " + ex.getMessage() ); } }
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 void setString(String s) throws InvalidHeaderException { try { setValue(PragmaType.valueOf(s)); } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage()); } }
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 void setString(String s) throws InvalidHeaderException { try { setValue(BytesRange.valueOf(s,PREFIX)); } catch (InvalidValueException invalidValueException) { throw new InvalidHeaderException("Invalid Range Header: " + invalidValueException.getMessage()); } }