本文整理了Java中org.apache.tuscany.sca.interfacedef.util.XMLType.getElementName()
方法的一些代码示例,展示了XMLType.getElementName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLType.getElementName()
方法的具体详情如下:
包路径:org.apache.tuscany.sca.interfacedef.util.XMLType
类名称:XMLType
方法名:getElementName
暂无
代码示例来源:origin: org.apache.tuscany.sca/tuscany-assembly
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding-axiom
/**
* @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());
}
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding-sdo-axiom
/**
* @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());
}
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding-json
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);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
namespace = returnXMLType.getElementName().getNamespaceURI();
} else {
namespace = returnXMLType.getTypeName().getNamespaceURI();
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding
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);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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);
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding
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);
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding-sdo-axiom
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding
@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;
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-wsdlgen
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;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
@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;
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
@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);
}
内容来源于网络,如有侵权,请联系作者删除!