本文整理了Java中org.teiid.core.types.XMLType.<init>()
方法的一些代码示例,展示了XMLType.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLType.<init>()
方法的具体详情如下:
包路径:org.teiid.core.types.XMLType
类名称:XMLType
方法名:<init>
暂无
代码示例来源:origin: teiid/teiid
@Override
protected Object readObject(ObjectInput in, List<Object> cache, byte version) throws IOException, ClassNotFoundException {
XMLType xt = new XMLType();
xt.readExternal(in, (byte)1);
return xt;
}
}
代码示例来源:origin: org.teiid/teiid-client
@Override
protected Object readObject(ObjectInput in, List<Object> cache, byte version) throws IOException, ClassNotFoundException {
XMLType xt = new XMLType();
xt.readExternal(in, (byte)1);
return xt;
}
}
代码示例来源: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: 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
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: teiid/teiid
@Test public void testXMLValue() throws Exception {
String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$
SQLXMLImpl xml = new SQLXMLImpl(testString);
XMLType xv = new XMLType(xml);
assertEquals(testString, xv.getString());
}
代码示例来源:origin: teiid/teiid
@Test public void testLength() throws Exception {
String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$
SQLXMLImpl xml = new SQLXMLImpl(testString);
XMLType xv = new XMLType(xml);
assertEquals(36, xv.length());
xml = new SQLXMLImpl(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream("<bar/>".getBytes(Streamable.CHARSET));
}
});
xv = new XMLType(xml);
try {
xv.length();
fail();
} catch (SQLException e) {
}
}
}
代码示例来源: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
@Test public void testXMLInput() throws Exception {
XMLType doc = new XMLType(new SQLXMLImpl("<foo/>"));//$NON-NLS-1$
String xpath = "a/b/c"; //$NON-NLS-1$
String value = XMLSystemFunctions.xpathValue(doc, xpath);
assertNull(value);
}
代码示例来源:origin: teiid/teiid
@Test public void testReferencePersistence() throws Exception {
String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$
SQLXMLImpl xml = new SQLXMLImpl(testString);
XMLType xv = new XMLType(xml);
xv.setReferenceStreamId(null);
// now force to serialize
XMLType read = UnitTestUtil.helpSerialize(xv);
assertEquals(testString, read.getString());
}
代码示例来源:origin: teiid/teiid
@Test public void testXMLValuePersistence() throws Exception {
String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$
SQLXMLImpl xml = new SQLXMLImpl(testString);
XMLType xv = new XMLType(xml);
String key = xv.getReferenceStreamId();
// now force to serialize
XMLType read = UnitTestUtil.helpSerialize(xv);
// make sure we have kept the reference stream id
assertEquals(key, read.getReferenceStreamId());
// and lost the original object
assertNull(read.getReference());
}
代码示例来源:origin: teiid/teiid
@Test public void testXML() throws Exception {
StatementImpl statement = createMockStatement(ResultSet.TYPE_FORWARD_ONLY);
ResultsFuture<LobChunk> future = new ResultsFuture<LobChunk>();
future.getResultsReceiver().receiveResults(new LobChunk("<a/>".getBytes(Charset.forName("UTF-8")), true));
XMLType result = new XMLType();
Mockito.stub(statement.getDQP().requestNextLobChunk(0, 0, result.getReferenceStreamId())).toReturn(future);
ResultsMessage resultsMsg = new ResultsMessage();
result.setEncoding("UTF-8");
resultsMsg.setResults(new List<?>[] {Arrays.asList(result)});
resultsMsg.setLastRow(1);
resultsMsg.setFirstRow(1);
resultsMsg.setFinalRow(1);
resultsMsg.setColumnNames(new String[] {"x"}); //$NON-NLS-1$
resultsMsg.setDataTypes(new String[] {"xml"}); //$NON-NLS-1$
ResultSetImpl cs = new ResultSetImpl(resultsMsg, statement);
cs.next();
assertEquals("<a/>", cs.getString(1));
}
内容来源于网络,如有侵权,请联系作者删除!