public boolean isMatchingType(Object type) { if (faultName == null) { return false; } if ((type instanceof QName) && faultName.equals(type)) { return true; } if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) { return true; } return false; }
public boolean isMatchingType(Object type) { if (faultName == null) { return false; } if ((type instanceof QName) && faultName.equals(type)) { return true; } if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) { return true; } return false; }
private boolean typesMatch(Object first, Object second) { if (first.equals(second)) { return true; } if (first instanceof XMLType && second instanceof XMLType) { XMLType t1 = (XMLType)first; XMLType t2 = (XMLType)second; // TUSCANY-2113, we should compare element names only return matches(t1.getElementName(), t2.getElementName()); } return false; }
private boolean typesMatch(Object first, Object second) { if (first.equals(second)) { return true; } if (first instanceof XMLType && second instanceof XMLType) { XMLType t1 = (XMLType)first; XMLType t2 = (XMLType)second; // TUSCANY-2113, we should compare element names only return matches(t1.getElementName(), t2.getElementName()); } return false; }
/** * @param context * @param element */ public static void adjustElementName(TransformationContext context, OMElement element) { if (context != null) { DataType dataType = context.getTargetDataType(); Object logical = dataType == null ? null : dataType.getLogical(); if (!(logical instanceof XMLType)) { return; } XMLType xmlType = (XMLType)logical; if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) { // FIXME:: Throw exception or switch to the new Element? OMFactory factory = OMAbstractFactory.getOMFactory(); QName name = xmlType.getElementName(); OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix()); element.setNamespace(namespace); element.setLocalName(name.getLocalPart()); } } }
/** * @param context * @param element */ public static void adjustElementName(TransformationContext context, OMElement element) { if (context != null) { DataType dataType = context.getTargetDataType(); Object logical = dataType == null ? null : dataType.getLogical(); if (!(logical instanceof XMLType)) { return; } XMLType xmlType = (XMLType)logical; if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) { // FIXME:: Throw exception or switch to the new Element? OMFactory factory = OMAbstractFactory.getOMFactory(); QName name = xmlType.getElementName(); OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix()); element.setNamespace(namespace); element.setLocalName(name.getLocalPart()); } } }
public OMElement transform(Object source, TransformationContext context) { try { JSONObject json = JSONHelper.toJettison(source); if (json == null) { return null; } String ns = JSONDataBinding.ROOT_ELEMENT.getNamespaceURI(); String name = JSONDataBinding.ROOT_ELEMENT.getLocalPart(); if (context != null) { DataType<?> dataType = context.getTargetDataType(); Object logical = dataType.getLogical(); if (logical instanceof XMLType) { XMLType xmlType = (XMLType)logical; if (xmlType.isElement()) { ns = xmlType.getElementName().getNamespaceURI(); name = xmlType.getElementName().getLocalPart(); } } } JSONBadgerfishDataSource ds = new JSONBadgerfishDataSource(json); OMNamespace namespace = factory.createOMNamespace(ns, ""); return factory.createOMElement(ds, name, namespace); } catch (Exception e) { throw new TransformationException(e); } }
public T transform(Object source, TransformationContext context) { QName rootElement = null; if (context != null) { DataType<?> type = context.getTargetDataType(); if (type != null) { Object logical = type.getLogical(); if (logical instanceof XMLType) { rootElement = ((XMLType)logical).getElementName(); } } } //FIXME See how/if we still need to get the metadata here //QName rootElementName = (QName)context.getTargetDataType().getMetadata("RootElementName"); //if (rootElementName == null) { QName rootElementName = new QName(resolveRootElementName(source.getClass())); //} T root = createElement(rootElementName); appendChildElements(root, resolveElementName(source.getClass()), source.getClass(), source, context); return root; }
public T transform(Object source, TransformationContext context) { QName rootElement = null; if (context != null) { DataType<?> type = context.getTargetDataType(); if (type != null) { Object logical = type.getLogical(); if (logical instanceof XMLType) { rootElement = ((XMLType)logical).getElementName(); } } } //FIXME See how/if we still need to get the metadata here //QName rootElementName = (QName)context.getTargetDataType().getMetadata("RootElementName"); //if (rootElementName == null) { QName rootElementName = new QName(resolveRootElementName(source.getClass())); //} T root = createElement(rootElementName); appendChildElements(root, resolveElementName(source.getClass()), source.getClass(), source, context); return root; }
namespace = returnXMLType.getElementName().getNamespaceURI(); } else { namespace = returnXMLType.getTypeName().getNamespaceURI();
public XMLStreamReader transform(Object source, TransformationContext context) { try { javax.xml.namespace.QName name = null; if (context != null) { Object logical = context.getSourceDataType().getLogical(); if (logical instanceof XMLType) { name = ((XMLType)logical).getElementName(); } } return new BeanXMLStreamReaderImpl(name, source); } catch (Exception e) { throw new TransformationException(e); } }
public XMLStreamReader transform(Object source, TransformationContext context) { try { javax.xml.namespace.QName name = null; if (context != null) { Object logical = context.getSourceDataType().getLogical(); if (logical instanceof XMLType) { name = ((XMLType)logical).getElementName(); } } return new BeanXMLStreamReaderImpl(name, source); } catch (Exception e) { throw new TransformationException(e); } }
public T transform(Object source, TransformationContext context) { XMLType xmlType = (XMLType) context.getTargetDataType().getLogical(); String text = mapper.toXMLLiteral(xmlType.getTypeName(), source, context); return createElement(xmlType.getElementName(), text, context); }
public T transform(Object source, TransformationContext context) { XMLType xmlType = (XMLType) context.getTargetDataType().getLogical(); String text = mapper.toXMLLiteral(xmlType.getTypeName(), source, context); return createElement(xmlType.getElementName(), text, context); }
public OMElement transform(DataObject source, TransformationContext context) { HelperContext helperContext = SDOContextHelper.getHelperContext(context, true); OMFactory factory = OMAbstractFactory.getOMFactory(); QName name = ROOT_ELEMENT; if (context != null) { DataType dataType = context.getTargetDataType(); Object logical = dataType == null ? null : dataType.getLogical(); if (logical instanceof XMLType) { XMLType xmlType = (XMLType)logical; if (xmlType.isElement()) { name = xmlType.getElementName(); } } } XMLDocument document = helperContext.getXMLHelper().createDocument(source, name.getNamespaceURI(), name.getLocalPart()); SDODataSource dataSource = new SDODataSource(document, helperContext); OMElement element = AxiomHelper.createOMElement(factory, name, dataSource); return element; }
public Part generatePart(Definition definition, DataType arg, String partName) { Part part = definition.createPart(); part.setName(partName); if (arg != null && arg.getLogical() instanceof XMLType) { XMLType xmlType = (XMLType)arg.getLogical(); QName elementName = xmlType.getElementName(); part.setElementName(elementName); addNamespace(definition, elementName); if (xmlType.getElementName() == null) { QName typeName = xmlType.getTypeName(); part.setTypeName(typeName); addNamespace(definition, typeName); } } return part; }
@Override public boolean introspect(DataType type, Operation operation) { Class<?> cls = type.getPhysical(); if (cls == Object.class) { return false; } // HACK: [rfeng] By pass the one know to XMLString String db = type.getDataBinding(); if (db != null && (XMLStringDataBinding.NAME.equals(db))) { return false; } if (SimpleTypeMapperImpl.JAVA2XML.keySet().contains(cls)) { type.setDataBinding(NAME); QName elementName = null; Object logical = type.getLogical(); if (logical instanceof XMLType) { elementName = ((XMLType)logical).getElementName(); } TypeInfo typeInfo = simpleTypeMapper.getXMLType(cls); type.setLogical(new XMLType(elementName, typeInfo == null ? null : typeInfo.getQName())); return true; } else { return false; } }
public Part generatePart(Definition definition, DataType arg, String partName) { Part part = definition.createPart(); part.setName(partName); if (arg != null && arg.getLogical() instanceof XMLType) { XMLType xmlType = (XMLType)arg.getLogical(); QName elementName = xmlType.getElementName(); part.setElementName(elementName); addNamespace(definition, elementName); if (xmlType.getElementName() == null) { QName typeName = xmlType.getTypeName(); part.setTypeName(typeName); addNamespace(definition, typeName); } } return part; }
@Override public boolean introspect(DataType type, Operation operation) { Class<?> cls = type.getPhysical(); if (cls == Object.class) { return false; } // HACK: [rfeng] By pass the one know to XMLString String db = type.getDataBinding(); if (db != null && (XMLStringDataBinding.NAME.equals(db))) { return false; } if (SimpleTypeMapperImpl.JAVA2XML.keySet().contains(cls)) { type.setDataBinding(NAME); QName elementName = null; Object logical = type.getLogical(); if (logical instanceof XMLType) { elementName = ((XMLType)logical).getElementName(); } TypeInfo typeInfo = simpleTypeMapper.getXMLType(cls); type.setLogical(new XMLType(elementName, typeInfo == null ? null : typeInfo.getQName())); return true; } else { return false; } }
@Override public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException { for (Property property : type.getProperties()) { String name = property.getName(); JavaElementImpl element = type.getPropertyMembers().get(name); introspect(property, element); DataType dt = property.getDataType(); Object logical = dt.getLogical(); if (logical instanceof XMLType && logical != XMLType.UNKNOWN) { XMLType xmlType = (XMLType)logical; property.setXSDType(xmlType.getTypeName()); property.setXSDElement(xmlType.getElementName()); } else { Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType()); QName typeName = JavaXMLMapper.getXMLType(baseType); property.setXSDType(typeName); } } super.visitEnd(clazz, type); }