@Override public Enum<?> convertValue(String value, Class<? extends Enum> datatype) throws ParseException { if (value == null) { return null; } Enum<?> result = Enum.valueOf(datatype, value.toUpperCase()); if (result == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such enum of type " + datatype + " named " + value.toUpperCase())); } return result; } }
@Override public Enum<?> convertValue(String value, Class<? extends Enum> datatype) throws ParseException { if (value == null) { return null; } Enum<?> result = Enum.valueOf(datatype, value.toUpperCase()); if (result == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such enum of type " + datatype + " named " + value.toUpperCase())); } return result; } }
@Override public Enum<?> convertValue(String value, Class<? extends Enum> datatype) throws ParseException { if (value == null) { return null; } Enum<?> result = Enum.valueOf(datatype, value.toUpperCase()); if (result == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such enum of type " + datatype + " named " + value.toUpperCase())); } return result; } }
/** Gets the value of a NPT attribute and remove it from the list. */ public static NormalPlayTime consumeNormalPlayTime(AttributeHelper attrHelper, String name) throws ParseException { String value = attrHelper.consume(name, false); if (value == null) { return null; } try { return NormalPlayTime.parse(value); } catch (java.text.ParseException e) { throw new ParseException( CoreErrorDomain.ERR.invalidTimeOffset.withInternalReason( "Invalid time offset value for attribute '" + name + "'"), e); } } }
/** Gets the value of a NPT attribute and remove it from the list. */ public static NormalPlayTime consumeNormalPlayTime(AttributeHelper attrHelper, String name) throws ParseException { String value = attrHelper.consume(name, false); if (value == null) { return null; } try { return NormalPlayTime.parse(value); } catch (java.text.ParseException e) { throw new ParseException( CoreErrorDomain.ERR.invalidTimeOffset.withInternalReason( "Invalid time offset value for attribute '" + name + "'"), e); } } }
@Override public void processAttribute(QName qn, String value) throws ParseException { if (element.hasAttribute(qn)) { throw new ParseException( CoreErrorDomain.ERR.duplicateAttributeValue.withInternalReason( "Duplicate value for attribute " + qn)); } AttributeKey<?> attKey = (metadata == null) ? null : metadata.findAttribute(qn); if (attKey != null) { element.setAttributeValue(attKey, ObjectConverter.getValue(value, attKey.getDatatype())); } else { element.setAttributeValue(qn, value); } }
@Override public void processAttribute(QName qn, String value) throws ParseException { if (element.hasAttribute(qn)) { throw new ParseException( CoreErrorDomain.ERR.duplicateAttributeValue.withInternalReason( "Duplicate value for attribute " + qn)); } AttributeKey<?> attKey = (metadata == null) ? null : metadata.findAttribute(qn); if (attKey != null) { element.setAttributeValue(attKey, ObjectConverter.getValue(value, attKey.getDatatype())); } else { element.setAttributeValue(qn, value); } }
@Override public void processAttribute(QName qn, String value) throws ParseException { if (element.hasAttribute(qn)) { throw new ParseException( CoreErrorDomain.ERR.duplicateAttributeValue.withInternalReason( "Duplicate value for attribute " + qn)); } AttributeKey<?> attKey = (metadata == null) ? null : metadata.findAttribute(qn); if (attKey != null) { element.setAttributeValue(attKey, ObjectConverter.getValue(value, attKey.getDatatype())); } else { element.setAttributeValue(qn, value); } }
/** * Processes this element; overrides inherited method. */ @Override public void processEndElement() throws ParseException { try { dateTime = DateTime.parseDateTime(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime.withInternalReason( "Invalid date/time format: '" + value + "'.")); } } }
/** * Processes this element; overrides inherited method. */ @Override public void processEndElement() throws ParseException { try { dateTime = DateTime.parseDateTime(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime.withInternalReason( "Invalid date/time format: '" + value + "'.")); } } }
@Override public T convertValue(String value, Class<? extends T> datatype) throws ParseException { T converted = map.get(value); if (converted == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such pseudo enum value of type " + datatype + " named " + value)); } return converted; } }
/** * Processes this element; overrides inherited method. */ @Override public void processEndElement() throws ParseException { try { dateTime = DateTime.parseDateTime(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime.withInternalReason( "Invalid date/time format: '" + value + "'.")); } } }
/** * Add an error by error string. This will register an error in the core * gdata domain with an error code of "invalidElement" and the internal reason * set to the given error string. For a more useful error message, * {@link #addError(Element, ErrorContent)} should be used instead. */ public void addError(Element element, String error) { addError(element, CoreErrorDomain.ERR.invalidExtension.withInternalReason(error)); }
@Override public T convertValue(String value, Class<? extends T> datatype) throws ParseException { T converted = map.get(value); if (converted == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such pseudo enum value of type " + datatype + " named " + value)); } return converted; } }
@Override public T convertValue(String value, Class<? extends T> datatype) throws ParseException { T converted = map.get(value); if (converted == null) { throw new ParseException( CoreErrorDomain.ERR.invalidEnumValue.withInternalReason( "No such pseudo enum value of type " + datatype + " named " + value)); } return converted; } }
/** * @deprecated Use {@link #withInternalReason(String)} instead. */ @Deprecated public ErrorCode setInternalReason(String newInternalReason) { return withInternalReason(newInternalReason); }
/** * @deprecated Use {@link #withInternalReason(String)} instead. */ @Deprecated public ErrorCode setInternalReason(String newInternalReason) { return withInternalReason(newInternalReason); }
/** * Add an error by error string. This will register an error in the core * gdata domain with an error code of "invalidElement" and the internal reason * set to the given error string. For a more useful error message, * {@link #addError(Element, ErrorContent)} should be used instead. */ public void addError(Element element, String error) { addError(element, CoreErrorDomain.ERR.invalidExtension.withInternalReason(error)); }
/** * @deprecated Use {@link #withInternalReason(String)} instead. */ @Deprecated public ErrorCode setInternalReason(String newInternalReason) { return withInternalReason(newInternalReason); }
/** * Add an error by error string. This will register an error in the core * gdata domain with an error code of "invalidElement" and the internal reason * set to the given error string. For a more useful error message, * {@link #addError(Element, ErrorContent)} should be used instead. */ public void addError(Element element, String error) { addError(element, CoreErrorDomain.ERR.invalidExtension.withInternalReason(error)); }