/** * INTERNAL * @since 2.5.0 */ @Override public UnmarshalRecord createRootUnmarshalRecord(Class clazz) { return new XMLRootRecord(clazz, this); }
@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { // set the root element's prefix qualified name and namespace prefix if (getRootElementName() == null) { setRootElementName(qName); setLocalName(localName); setRootElementNamespaceUri(namespaceURI); } if(Constants.EMPTY_STRING.equals(localName)) { return; } elementCount++; if (elementCount > 1) { // we only want to process characters from the first text child; // if a subelement occurs, we will stop shouldReadChars = false; } }
@Override public void characters(CharSequence characters) throws SAXException { if(null != characters) { String string = characters.toString(); characters(string.toCharArray(), 0, string.length()); } }
/** * Return a populated XMLRoot object. */ public Object getCurrentObject() { // this assumes that since we're unmarshalling to a primitive wrapper, the root // element has a single text node. if, however, the root element doesn't have // a text node as a first child, we'll try converting null String val = null; if (characters != null) { val = characters.toString(); } XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setObject(((XMLConversionManager) session.getDatasourcePlatform().getConversionManager()).convertObject(val, targetClass)); xmlRoot.setLocalName(getRootElementName()); xmlRoot.setNamespaceURI(getRootElementNamespaceUri()); return xmlRoot; }
/** * Return a populated XMLRoot object. */ @Override public Object getCurrentObject() { Root xmlRoot = unmarshaller.createRoot(); xmlRoot.setLocalName(getLocalName()); xmlRoot.setNamespaceURI(getRootElementNamespaceUri()); if(currentObject == null) { // this assumes that since we're unmarshalling to a primitive wrapper, the root // element has a single text node. if, however, the root element doesn't have // a text node as a first child, we'll try converting null String val = null; if (characters != null) { val = characters.toString(); } xmlRoot.setObject(session.getDatasourcePlatform().getConversionManager().convertObject(val, targetClass)); } else { xmlRoot.setObject(currentObject); } return xmlRoot; }
/** * Default constructor. */ public XMLRootRecord(Class cls, XMLUnmarshaller unmarshaller) { this.targetClass = cls; this.unmarshaller = unmarshaller; setSession((CoreAbstractSession) unmarshaller.getContext().getSession()); }
/** * Return a populated XMLRoot object. */ @Override public Object getCurrentObject() { Root xmlRoot = unmarshaller.createRoot(); xmlRoot.setLocalName(getLocalName()); xmlRoot.setNamespaceURI(getRootElementNamespaceUri()); if(currentObject == null) { // this assumes that since we're unmarshalling to a primitive wrapper, the root // element has a single text node. if, however, the root element doesn't have // a text node as a first child, we'll try converting null String val = null; if (characters != null) { val = characters.toString(); } xmlRoot.setObject(session.getDatasourcePlatform().getConversionManager().convertObject(val, targetClass)); } else { xmlRoot.setObject(currentObject); } return xmlRoot; }
/** * Default constructor. */ public XMLRootRecord(Class cls, XMLUnmarshaller unmarshaller) { this.targetClass = cls; this.unmarshaller = unmarshaller; setSession((CoreAbstractSession) unmarshaller.getContext().getSession()); }
@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { // set the root element's prefix qualified name and namespace prefix if (getRootElementName() == null) { setRootElementName(qName); setLocalName(localName); setRootElementNamespaceUri(namespaceURI); } if(Constants.EMPTY_STRING.equals(localName)) { return; } elementCount++; if (elementCount > 1) { // we only want to process characters from the first text child; // if a subelement occurs, we will stop shouldReadChars = false; } }
/** * INTERNAL * @since 2.5.0 */ @Override public UnmarshalRecord createRootUnmarshalRecord(Class clazz) { return new XMLRootRecord(clazz, this); }
@Override public void characters(CharSequence characters) throws SAXException { if(null != characters) { String string = characters.toString(); characters(string.toCharArray(), 0, string.length()); } }
unmarshalRecord = new XMLRootRecord(clazz); unmarshalRecord.setSession((AbstractSession) xmlUnmarshaller.getXMLContext().getSession(0)); } else if(clazz == ClassConstants.OBJECT) {
unmarshalRecord = new XMLRootRecord(primitiveWrapperClass); unmarshalRecord.setSession((AbstractSession) unmarshaller.getXMLContext().getSession(0)); } else if (xmlDescriptor.hasInheritance()) {
unmarshalRecord = new XMLRootRecord(clazz); unmarshalRecord.setSession((AbstractSession)xmlUnmarshaller.getXMLContext().getSession(0)); } else if(clazz == ClassConstants.OBJECT) {
unmarshalRecord = new XMLRootRecord(clazz); } else if(clazz == ClassConstants.OBJECT) {
unmarshalRecord = new XMLRootRecord(clazz); unmarshalRecord.setSession((AbstractSession) xmlUnmarshaller.getXMLContext().getSession(0)); } else if(clazz == ClassConstants.OBJECT) {