@Override public Boolean convertValue(String value, Class<? extends Boolean> datatype) throws ParseException { if (value == null) { return null; } // NOTE(sven): "ture" is a hack for panasonic, they shipped cameras with // this set before we became strict about boolean values. Photos could // try to override this but it seemed easier to just allow it here. if ("true".equals(value) || "1".equals(value) || "ture".equals(value)) { return Boolean.TRUE; } else if ("false".equals(value) || "0".equals(value)) { return Boolean.FALSE; } else { throw new ParseException( CoreErrorDomain.ERR.invalidBooleanAttribute.withInternalReason( "Invalid boolean value: '" + value + "'")); } } }
case UNKNOWN_TYPE: vc.addError(e, CoreErrorDomain.ERR.invalidTextContentType.withInternalReason( "Invalid type: " + type)); break; CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "Child elements not allowed on text content")); if (!e.hasElement(DIV)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "xhtml text content must have a div element")); } else if (e.getElementCount() != 1) { vc.addError(e, CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "xhtml must only have a single child element"));
case UNKNOWN_TYPE: vc.addError(e, CoreErrorDomain.ERR.invalidTextContentType.withInternalReason( "Invalid type: " + type)); break; CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "Child elements not allowed on text content")); if (!e.hasElement(DIV)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "xhtml text content must have a div element")); } else if (e.getElementCount() != 1) { vc.addError(e, CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "xhtml must only have a single child element"));
case UNKNOWN_TYPE: vc.addError(e, CoreErrorDomain.ERR.invalidTextContentType.withInternalReason( "Invalid type: " + type)); break; CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "Child elements not allowed on text content")); if (!e.hasElement(DIV)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "xhtml text content must have a div element")); } else if (e.getElementCount() != 1) { vc.addError(e, CoreErrorDomain.ERR.invalidChildElement.withInternalReason( "xhtml must only have a single child element"));
if (key.getDatatype() == Void.class) { vc.addError(e, CoreErrorDomain.ERR.invalidTextContent.withInternalReason( "Element " + key.getId() + " must not contain text content.")); vc.addError(e, CoreErrorDomain.ERR.missingTextContent.withInternalReason( "Element " + key.getId() + " must contain a text content value.")); AttributeMetadata<?> attMeta = metadata.bindAttribute(attributeKey); if (attMeta.isRequired() && e.getAttributeValue(attributeKey) == null) { vc.addError(e, CoreErrorDomain.ERR.missingAttribute.withInternalReason( "Element must contain value for attribute " + attributeKey.getId())); if (childMeta.isRequired() && !e.hasElement(childKey)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "Element must contain a child named " + childKey.getId()));
if (key.getDatatype() == Void.class) { vc.addError(e, CoreErrorDomain.ERR.invalidTextContent.withInternalReason( "Element " + key.getId() + " must not contain text content.")); vc.addError(e, CoreErrorDomain.ERR.missingTextContent.withInternalReason( "Element " + key.getId() + " must contain a text content value.")); AttributeMetadata<?> attMeta = metadata.bindAttribute(attributeKey); if (attMeta.isRequired() && e.getAttributeValue(attributeKey) == null) { vc.addError(e, CoreErrorDomain.ERR.missingAttribute.withInternalReason( "Element must contain value for attribute " + attributeKey.getId())); if (childMeta.isRequired() && !e.hasElement(childKey)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "Element must contain a child named " + childKey.getId()));
if (key.getDatatype() == Void.class) { vc.addError(e, CoreErrorDomain.ERR.invalidTextContent.withInternalReason( "Element " + key.getId() + " must not contain text content.")); vc.addError(e, CoreErrorDomain.ERR.missingTextContent.withInternalReason( "Element " + key.getId() + " must contain a text content value.")); AttributeMetadata<?> attMeta = metadata.bindAttribute(attributeKey); if (attMeta.isRequired() && e.getAttributeValue(attributeKey) == null) { vc.addError(e, CoreErrorDomain.ERR.missingAttribute.withInternalReason( "Element must contain value for attribute " + attributeKey.getId())); if (childMeta.isRequired() && !e.hasElement(childKey)) { vc.addError(e, CoreErrorDomain.ERR.missingExtensionElement.withInternalReason( "Element must contain a child named " + childKey.getId()));
/** 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 Boolean convertValue(String value, Class<? extends Boolean> datatype) throws ParseException { if (value == null) { return null; } // NOTE(sven): "ture" is a hack for panasonic, they shipped cameras with // this set before we became strict about boolean values. Photos could // try to override this but it seemed easier to just allow it here. if ("true".equals(value) || "1".equals(value) || "ture".equals(value)) { return Boolean.TRUE; } else if ("false".equals(value) || "0".equals(value)) { return Boolean.FALSE; } else { throw new ParseException( CoreErrorDomain.ERR.invalidBooleanAttribute.withInternalReason( "Invalid boolean value: '" + value + "'")); } } }
@Override public Boolean convertValue(String value, Class<? extends Boolean> datatype) throws ParseException { if (value == null) { return null; } // NOTE(sven): "ture" is a hack for panasonic, they shipped cameras with // this set before we became strict about boolean values. Photos could // try to override this but it seemed easier to just allow it here. if ("true".equals(value) || "1".equals(value) || "ture".equals(value)) { return Boolean.TRUE; } else if ("false".equals(value) || "0".equals(value)) { return Boolean.FALSE; } else { throw new ParseException( CoreErrorDomain.ERR.invalidBooleanAttribute.withInternalReason( "Invalid boolean value: '" + value + "'")); } } }
/** 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 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 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 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 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 + "'.")); } } }
public RateLimitExceededException(String message) { this(CoreErrorDomain.ERR.rateLimitExceeded.withExtendedHelp(message)); }