本文整理了Java中org.teiid.core.types.XMLType.setType()
方法的一些代码示例,展示了XMLType.setType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLType.setType()
方法的具体详情如下:
包路径:org.teiid.core.types.XMLType
类名称:XMLType
方法名:setType
暂无
代码示例来源:origin: org.jboss.teiid/teiid-engine
public static XMLType xmlPi(String name, String content) {
int start = 0;
char[] chars = content.toCharArray();
while (start < chars.length && chars[start] == ' ') {
start++;
}
XMLType result = new XMLType(new SQLXMLImpl("<?" + name + " " + content.substring(start) + "?>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
result.setType(Type.PI);
return result;
}
代码示例来源:origin: org.teiid/teiid-engine
public static XMLType xmlPi(String name, String content) {
int start = 0;
char[] chars = content.toCharArray();
while (start < chars.length && chars[start] == ' ') {
start++;
}
XMLType result = new XMLType(new SQLXMLImpl("<?" + name + " " + content.substring(start) + "?>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
result.setType(Type.PI);
return result;
}
代码示例来源:origin: teiid/teiid
public static XMLType xmlPi(String name, String content) {
int start = 0;
char[] chars = content.toCharArray();
while (start < chars.length && chars[start] == ' ') {
start++;
}
XMLType result = new XMLType(new SQLXMLImpl("<?" + name + " " + content.substring(start) + "?>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
result.setType(Type.PI);
return result;
}
代码示例来源:origin: org.teiid/teiid-engine
public static XMLType xmlComment(String comment) throws FunctionExecutionException {
if (comment.contains("--") || comment.endsWith("-")) { //$NON-NLS-1$ //$NON-NLS-2$
throw new FunctionExecutionException(QueryPlugin.Event.TEIID31159, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31159, comment));
}
XMLType result = new XMLType(new SQLXMLImpl("<!--" + comment + "-->")); //$NON-NLS-1$ //$NON-NLS-2$
result.setType(Type.COMMENT);
return result;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public static XMLType xmlComment(String comment) throws FunctionExecutionException {
if (comment.contains("--") || comment.endsWith("-")) { //$NON-NLS-1$ //$NON-NLS-2$
throw new FunctionExecutionException(QueryPlugin.Event.TEIID31159, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31159, comment));
}
XMLType result = new XMLType(new SQLXMLImpl("<!--" + comment + "-->")); //$NON-NLS-1$ //$NON-NLS-2$
result.setType(Type.COMMENT);
return result;
}
代码示例来源:origin: teiid/teiid
public static XMLType xmlComment(String comment) throws FunctionExecutionException {
if (comment.contains("--") || comment.endsWith("-")) { //$NON-NLS-1$ //$NON-NLS-2$
throw new FunctionExecutionException(QueryPlugin.Event.TEIID31159, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31159, comment));
}
XMLType result = new XMLType(new SQLXMLImpl("<!--" + comment + "-->")); //$NON-NLS-1$ //$NON-NLS-2$
result.setType(Type.COMMENT);
return result;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
@TeiidFunction(category=FunctionCategoryConstants.XML, nullOnNull=true)
public static XMLType xmlText(String val) throws XMLStreamException, FactoryConfigurationError, IOException, TransformerException {
//TODO: see if there is a less involved way to escape
StringWriter writer = new StringWriter();
XMLEventWriter eventWriter = getOutputFactory().createXMLEventWriter(writer);
convertValue(writer, eventWriter, threadLocalEventtFactory.get(), val);
XMLType result = new XMLType(new SQLXMLImpl(writer.toString()));
result.setType(Type.TEXT);
return result;
}
代码示例来源:origin: teiid/teiid
@TeiidFunction(category=FunctionCategoryConstants.XML, nullOnNull=true)
public static XMLType xmlText(String val) throws XMLStreamException, FactoryConfigurationError, IOException, TransformerException {
//TODO: see if there is a less involved way to escape
StringWriter writer = new StringWriter();
XMLEventWriter eventWriter = getOutputFactory().createXMLEventWriter(writer);
convertValue(writer, eventWriter, threadLocalEventtFactory.get(), val);
XMLType result = new XMLType(new SQLXMLImpl(writer.toString()));
result.setType(Type.TEXT);
return result;
}
代码示例来源:origin: org.teiid/teiid-engine
@TeiidFunction(category=FunctionCategoryConstants.XML, nullOnNull=true)
public static XMLType xmlText(String val) throws XMLStreamException, FactoryConfigurationError, IOException, TransformerException {
//TODO: see if there is a less involved way to escape
StringWriter writer = new StringWriter();
XMLEventWriter eventWriter = getOutputFactory().createXMLEventWriter(writer);
convertValue(writer, eventWriter, threadLocalEventtFactory.get(), val);
XMLType result = new XMLType(new SQLXMLImpl(writer.toString()));
result.setType(Type.TEXT);
return result;
}
代码示例来源:origin: org.teiid/teiid-common-core
/**
* This method transforms a value of the source type into a value
* of the target type.
* @param value Incoming value of source type
* @return Outgoing value of target type
* @throws TransformationException if value is an incorrect input type or
* the transformation fails
*/
public Object transformDirect(Object value) throws TransformationException {
String xml = (String)value;
Reader reader = new StringReader(xml);
Type type = isXml(reader);
XMLType result = new XMLType(new SQLXMLImpl(xml));
result.setType(type);
return result;
}
代码示例来源:origin: teiid/teiid
/**
* This method transforms a value of the source type into a value
* of the target type.
* @param value Incoming value of source type
* @return Outgoing value of target type
* @throws TransformationException if value is an incorrect input type or
* the transformation fails
*/
public Object transformDirect(Object value) throws TransformationException {
String xml = (String)value;
Reader reader = new StringReader(xml);
Type type = isXml(reader);
XMLType result = new XMLType(new SQLXMLImpl(xml));
result.setType(type);
return result;
}
代码示例来源:origin: org.teiid/teiid-engine
public XMLType close(CommandContext context) throws TeiidProcessingException {
try {
eventWriter.flush();
ew.close();
} catch (XMLStreamException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30441, e);
} catch (IOException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30442, e);
}
XMLType result = new XMLType(createSQLXML(fsisf, ew, context));
if (type == null) {
result.setType(Type.CONTENT);
} else {
result.setType(type);
}
return result;
}
代码示例来源:origin: teiid/teiid
public XMLType close(CommandContext context) throws TeiidProcessingException {
try {
eventWriter.flush();
ew.close();
} catch (XMLStreamException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30441, e);
} catch (IOException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30442, e);
}
XMLType result = new XMLType(createSQLXML(fsisf, ew, context));
if (type == null) {
result.setType(Type.CONTENT);
} else {
result.setType(type);
}
return result;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public XMLType close(CommandContext context) throws TeiidProcessingException {
try {
eventWriter.flush();
ew.close();
} catch (XMLStreamException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30441, e);
} catch (IOException e) {
fs.remove();
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30442, e);
}
XMLType result = new XMLType(createSQLXML(fsisf, ew, context));
if (type == null) {
result.setType(Type.CONTENT);
} else {
result.setType(type);
}
return result;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public XMLType createXMLType(final SequenceIterator iter, BufferManager bufferManager, boolean emptyOnEmpty, CommandContext context) throws XPathException, TeiidComponentException, TeiidProcessingException {
Item item = iter.next();
if (item == null && !emptyOnEmpty) {
return null;
}
XMLType.Type type = Type.CONTENT;
if (item instanceof NodeInfo) {
NodeInfo info = (NodeInfo)item;
type = getType(info);
}
Item next = iter.next();
if (next != null) {
type = Type.CONTENT;
}
SQLXMLImpl xml = XMLSystemFunctions.saveToBufferManager(bufferManager, new XMLTranslator() {
@Override
public void translate(Writer writer) throws TransformerException,
IOException {
QueryResult.serializeSequence(iter.getAnother(), config, writer, DEFAULT_OUTPUT_PROPERTIES);
}
}, context);
XMLType value = new XMLType(xml);
value.setType(type);
return value;
}
代码示例来源:origin: teiid/teiid
public XMLType createXMLType(final SequenceIterator iter, BufferManager bufferManager, boolean emptyOnEmpty, CommandContext context) throws XPathException, TeiidComponentException, TeiidProcessingException {
final Item item = iter.next();
if (item == null && !emptyOnEmpty) {
return null;
}
XMLType.Type type = Type.CONTENT;
if (item instanceof NodeInfo) {
NodeInfo info = (NodeInfo)item;
type = getType(info);
}
final Item next = iter.next();
if (next != null) {
type = Type.CONTENT;
}
SQLXMLImpl xml = XMLSystemFunctions.saveToBufferManager(bufferManager, new XMLTranslator() {
@Override
public void translate(Writer writer) throws TransformerException,
IOException {
QueryResult.serializeSequence(new PushBackSequenceIterator(iter, item, next), config, writer, DEFAULT_OUTPUT_PROPERTIES);
}
}, context);
XMLType value = new XMLType(xml);
value.setType(type);
return value;
}
代码示例来源:origin: teiid/teiid
@Test public void testStaxComment() throws Exception {
String sql = "select * from xmltable('/*:Person/phoneNumber' passing cast(? as xml) columns x string path 'type', y string path 'number') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList(null, "8881112222"),
};
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLEventReader reader = factory.createXMLEventReader(new StringReader("<Person><!--hello--><phoneNumber><number>8881112222</number></phoneNumber></Person>"));
XMLType value = new XMLType(new StAXSQLXML(new StAXSource(reader)));
value.setType(Type.DOCUMENT);
Command command = helpParse(sql);
CommandContext context = createCommandContext();
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
context.setMetadata(metadata);
CapabilitiesFinder capFinder = new DefaultCapabilitiesFinder();
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
setParameterValues(Arrays.asList(value), command, context);
doProcess(plan, dataManager, expected, context);
}
代码示例来源:origin: teiid/teiid
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
if (value == null) {
return null;
}
try {
if (!xs.isDocument()) {
return XMLSystemFunctions.serialize(xs, value);
}
if (value.getType() == Type.UNKNOWN) {
Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream());
value.setType(type);
}
if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) {
return XMLSystemFunctions.serialize(xs, value);
}
} catch (SQLException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e);
} catch (TransformationException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e);
}
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336));
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
if (value == null) {
return null;
}
try {
if (!xs.isDocument()) {
return XMLSystemFunctions.serialize(xs, value);
}
if (value.getType() == Type.UNKNOWN) {
Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream());
value.setType(type);
}
if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) {
return XMLSystemFunctions.serialize(xs, value);
}
} catch (SQLException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e);
} catch (TransformationException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e);
}
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336));
}
代码示例来源:origin: org.teiid/teiid-engine
private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
if (value == null) {
return null;
}
try {
if (!xs.isDocument()) {
return XMLSystemFunctions.serialize(xs, value);
}
if (value.getType() == Type.UNKNOWN) {
Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream());
value.setType(type);
}
if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) {
return XMLSystemFunctions.serialize(xs, value);
}
} catch (SQLException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30334, e);
} catch (TransformationException e) {
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30335, e);
}
throw new FunctionExecutionException(QueryPlugin.Event.TEIID30336, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30336));
}
内容来源于网络,如有侵权,请联系作者删除!