value = b!=null && b.getValue()!=null ? b.getValue().toString() : null; } else if (xmlObject instanceof XSDateTime) { DateTime d = ((XSDateTime)xmlObject).getValue(); value = d!=null ? d.toString() : null; } else if (xmlObject instanceof XSQName) {
/** * Validates the content of the XSDateTime object. * * @param xmlObject the object to evaluate * @throws ValidationException thrown if the content of the object is invalid */ protected void validateDateTimeContent(T xmlObject) throws ValidationException{ if(!allowEmptyContent && xmlObject.getValue() == null){ throw new ValidationException("dateTime content may not be empty"); } }
/** * Validates the content of the XSDateTime object. * * @param xmlObject the object to evaluate * @throws ValidationException thrown if the content of the object is invalid */ protected void validateDateTimeContent(T xmlObject) throws ValidationException{ if(!allowEmptyContent && xmlObject.getValue() == null){ throw new ValidationException("dateTime content may not be empty"); } }
/** {@inheritDoc} */ protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException { XSDateTime xsDateTime = (XSDateTime) xmlObject; XMLHelper.appendTextContent(domElement, xsDateTime.getDateTimeFormatter().print(xsDateTime.getValue())); }
/** {@inheritDoc} */ protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException { XSDateTime xsDateTime = (XSDateTime) xmlObject; XMLHelper.appendTextContent(domElement, xsDateTime.getDateTimeFormatter().print(xsDateTime.getValue())); }
@SuppressWarnings("unchecked") private static Attribute getAttribute(String attributeName, GregorianCalendar attributeValue) { Attribute attribute = buildXMLObject(Attribute.class, Attribute.DEFAULT_ELEMENT_NAME); attribute.setName(attributeName); XMLObjectBuilder<XSDateTime> builder = Configuration .getBuilderFactory().getBuilder(XSDateTime.TYPE_NAME); XSDateTime xmlAttributeValue = builder.buildObject( AttributeValue.DEFAULT_ELEMENT_NAME, XSDateTime.TYPE_NAME); // convert to Zulu timezone int day = attributeValue.get(Calendar.DAY_OF_MONTH); int month = attributeValue.get(Calendar.MONTH); int year = attributeValue.get(Calendar.YEAR); LOG.debug("day: " + day + " month: " + month + " year: " + year); DateTime zulu = new DateTime(year, month + 1, day, 0, 0, 0, 0, ISOChronology.getInstanceUTC()); xmlAttributeValue.setValue(zulu); attribute.getAttributeValues().add(xmlAttributeValue); LOG.debug("XmlAttributeValue: " + xmlAttributeValue.getValue()); return attribute; }
private static void processAttribute(Attribute attribute, Map<String, Object> attributeMap) throws AssertionValidationException { String attributeName = attribute.getName(); if (attribute.getAttributeValues().get(0) instanceof XSString) { XSString attributeValue = (XSString) attribute.getAttributeValues() .get(0); attributeMap.put(attributeName, attributeValue.getValue()); } else if (attribute.getAttributeValues().get(0) instanceof XSInteger) { XSInteger attributeValue = (XSInteger) attribute .getAttributeValues().get(0); attributeMap.put(attributeName, attributeValue.getValue()); } else if (attribute.getAttributeValues().get(0) instanceof XSDateTime) { XSDateTime attributeValue = (XSDateTime) attribute .getAttributeValues().get(0); attributeMap.put(attributeName, attributeValue.getValue() .toDateTime(ISOChronology.getInstanceUTC())); } else if (attribute.getAttributeValues().get(0) instanceof XSBase64Binary) { XSBase64Binary attributeValue = (XSBase64Binary) attribute .getAttributeValues().get(0); attributeMap.put(attributeName, Base64.decode(attributeValue.getValue())); } else { throw new AssertionValidationException("Unsupported attribute of " + "type: " + attribute.getAttributeValues().get(0).getClass() .getName()); } }
toMatch = ((XSInteger) xmlObj).getValue().toString(); } else if (xmlObj instanceof XSDateTime) { final DateTime dt = ((XSDateTime) xmlObj).getValue(); if (dt != null) { toMatch = ((XSDateTime) xmlObj).getDateTimeFormatter().print(dt);