本文整理汇总了Java中com.sforce.ws.parser.XmlInputStream类的典型用法代码示例。如果您正苦于以下问题:Java XmlInputStream类的具体用法?Java XmlInputStream怎么用?Java XmlInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlInputStream类属于com.sforce.ws.parser包,在下文中一共展示了XmlInputStream类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMetadata
import com.sforce.ws.parser.XmlInputStream; //导入依赖的package包/类
/**
* Sets the metadata on the containerMember reflectively. We do it this way because the containerMembers are
* generated from the WSDL and do not implement a common interface/hierarchy. If we don't use reflection, we end up
* with a lot of boilerplate code. The downside of reflection is that it can be slower - though this is not in a
* critical code path.
*
* @param containerMember
* This object must have a setMetadata method on it since it will be called reflectively.
* @param metadataComponent
* The component that contains the metadata as its body
* @throws Exception
*/
static void setMetadata(Object containerMember, Component metadataComponent) throws Exception {
Method[] methods = containerMember.getClass().getMethods();
Method setMetadataMethod = null;
for (Method method : methods) {
if (method.getName().equals("setMetadata")) {
setMetadataMethod = method;
break;
}
}
if (setMetadataMethod != null) {
Class<?> metadataType = (setMetadataMethod.getParameterTypes())[0]; // There is only one parameter
Object metadataInstance = metadataType.newInstance();
XmlInputStream xis = createCorrespondingXmlInputStream(metadataComponent);
Method loadMethod = metadataType.getMethod("load", XmlInputStream.class, TypeMapper.class);
loadMethod.invoke(metadataInstance, xis, new TypeMapper());
setMetadataMethod.invoke(containerMember, metadataInstance);
}
}
示例2: createCorrespondingXmlInputStream
import com.sforce.ws.parser.XmlInputStream; //导入依赖的package包/类
private static XmlInputStream createCorrespondingXmlInputStream(Component metadata) throws Exception, PullParserException {
String body = replaceNamespace(metadata.getBody(), "urn:metadata.tooling.soap.sforce.com");
XmlInputStream xis = new XmlInputStream();
xis.setInput(new ByteArrayInputStream(body.getBytes()), "UTF-8");
return xis;
}