本文整理了Java中org.teiid.core.types.XMLType.getXmlInputFactory()
方法的一些代码示例,展示了XMLType.getXmlInputFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLType.getXmlInputFactory()
方法的具体详情如下:
包路径:org.teiid.core.types.XMLType
类名称:XMLType
方法名:getXmlInputFactory
暂无
代码示例来源:origin: org.jboss.teiid/teiid-engine
private static XMLEventReader getXMLEventReader(StAXSource source) throws XMLStreamException {
XMLEventReader reader = source.getXMLEventReader();
if (reader == null) {
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
reader = inputFactory.createXMLEventReader(source.getXMLStreamReader());
}
return reader;
}
代码示例来源:origin: teiid/teiid
private static XMLEventReader getXMLEventReader(StAXSource source) throws XMLStreamException {
XMLEventReader reader = source.getXMLEventReader();
if (reader == null) {
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
reader = inputFactory.createXMLEventReader(source.getXMLStreamReader());
}
return reader;
}
代码示例来源:origin: org.teiid/teiid-engine
private static XMLEventReader getXMLEventReader(StAXSource source) throws XMLStreamException {
XMLEventReader reader = source.getXMLEventReader();
if (reader == null) {
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
reader = inputFactory.createXMLEventReader(source.getXMLStreamReader());
}
return reader;
}
代码示例来源:origin: teiid/teiid
public static PlanNode fromXml(String planString) throws XMLStreamException {
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(planString));
while (reader.hasNext()&& (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
String element = reader.getLocalName();
if (element.equals("node")) { //$NON-NLS-1$
Properties props = getAttributes(reader);
PlanNode planNode = new PlanNode(props.getProperty("name"));//$NON-NLS-1$
planNode.setParent(null);
buildNode(reader, planNode);
return planNode;
}
throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "node"),reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
}
return null;
}
代码示例来源:origin: teiid/teiid
public static Type isXml(Reader reader) throws TransformationException {
Type type = Type.ELEMENT;
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
try{
XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
int event = xmlReader.getEventType();
if (event == XMLEvent.START_DOCUMENT && xmlReader.getLocation().getColumnNumber() != 1) {
type = Type.DOCUMENT;
}
while (xmlReader.hasNext()) {
xmlReader.next();
}
} catch (Exception e){
throw new TransformationException(CorePlugin.Event.TEIID10070, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10070));
} finally {
try {
reader.close();
} catch (IOException e) {
}
}
return type;
}
代码示例来源:origin: org.teiid/teiid-client
public static PlanNode fromXml(String planString) throws XMLStreamException {
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(planString));
while (reader.hasNext()&& (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
String element = reader.getLocalName();
if (element.equals("node")) { //$NON-NLS-1$
Properties props = getAttributes(reader);
PlanNode planNode = new PlanNode(props.getProperty("name"));//$NON-NLS-1$
planNode.setParent(null);
buildNode(reader, planNode);
return planNode;
}
throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element", reader.getName(), "node"),reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
}
return null;
}
代码示例来源:origin: teiid/teiid
@Override
public StAXSource getStaxSource() throws SQLException {
try {
XMLEventReader eventReader = getXMLEventReader(v.getSource(StAXSource.class));
eventReader = XMLType.getXmlInputFactory().createFilteredReader(eventReader, declarationOmittingFilter);
return new StAXSource(eventReader);
} catch (XMLStreamException e) {
throw new SQLException(e);
}
}
};
代码示例来源:origin: org.teiid/teiid-common-core
public static Type isXml(Reader reader) throws TransformationException {
Type type = Type.ELEMENT;
XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
try{
XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
int event = xmlReader.getEventType();
if (event == XMLEvent.START_DOCUMENT && xmlReader.getLocation().getColumnNumber() != 1) {
type = Type.DOCUMENT;
}
while (xmlReader.hasNext()) {
xmlReader.next();
}
} catch (Exception e){
throw new TransformationException(CorePlugin.Event.TEIID10070, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10070));
} finally {
try {
reader.close();
} catch (IOException e) {
}
}
return type;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
@Override
public StAXSource getStaxSource() throws SQLException {
try {
XMLEventReader eventReader = getXMLEventReader(v.getSource(StAXSource.class));
eventReader = XMLType.getXmlInputFactory().createFilteredReader(eventReader, declarationOmittingFilter);
return new StAXSource(eventReader);
} catch (XMLStreamException e) {
throw new SQLException(e);
}
}
};
代码示例来源:origin: org.teiid/teiid-engine
@Override
public StAXSource getStaxSource() throws SQLException {
try {
XMLEventReader eventReader = getXMLEventReader(v.getSource(StAXSource.class));
eventReader = XMLType.getXmlInputFactory().createFilteredReader(eventReader, declarationOmittingFilter);
return new StAXSource(eventReader);
} catch (XMLStreamException e) {
throw new SQLException(e);
}
}
};
代码示例来源:origin: teiid/teiid
public XMLInputStream(StAXSource source, XMLOutputFactory outFactory, String encoding) throws XMLStreamException {
reader = source.getXMLEventReader();
if (reader == null) {
this.reader = XMLType.getXmlInputFactory().createXMLEventReader(source.getXMLStreamReader());
}
this.writer = outFactory.createXMLEventWriter(baos, encoding);
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
public static FunctionMetadataReader parseFunctions(InputStream content) throws XMLStreamException {
XMLInputFactory inputFactory=XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
FunctionMetadataReader fmr = new FunctionMetadataReader();
while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
switch (Namespace.forUri(reader.getNamespaceURI())) {
case XMI: {
Element element = Element.forName(reader.getLocalName());
switch (element) {
case XMI:
parseFunctions(reader, fmr);
while(reader.hasNext() && reader.next() != XMLStreamConstants.END_DOCUMENT);
break;
}
break;
}
}
}
return fmr;
}
代码示例来源:origin: teiid/teiid
public XMLReader(StAXSource source, XMLOutputFactory outFactory) throws XMLStreamException {
reader = source.getXMLEventReader();
if (reader == null) {
this.reader = XMLType.getXmlInputFactory().createXMLEventReader(source.getXMLStreamReader());
}
this.writer = outFactory.createXMLEventWriter(new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
builder.append(cbuf, off, len);
}
@Override
public void flush() throws IOException {
}
@Override
public void write(String str, int off, int len) throws IOException {
builder.append(str, off, len);
}
@Override
public void close() throws IOException {
}
});
}
代码示例来源:origin: teiid/teiid
public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
XMLInputFactory inputFactory=XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
try {
代码示例来源:origin: org.teiid/teiid-admin
public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
XMLInputFactory inputFactory=XMLType.getXmlInputFactory();
XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
try {
代码示例来源:origin: teiid/teiid
@Test public void testStreaming() throws Exception {
StringBuilder xmlBuilder = new StringBuilder();
xmlBuilder.append("<root>");
for (int i = 0; i < 1000; i++) {
xmlBuilder.append("<a></a>");
xmlBuilder.append("<b></b>");
}
xmlBuilder.append("</root>");
String xml = xmlBuilder.toString();
StAXSource source = new StAXSource(XMLType.getXmlInputFactory().createXMLEventReader(new StringReader(xml)));
XMLInputStream is = new XMLInputStream(source, XMLOutputFactory.newFactory());
byte[] bytes = ObjectConverterUtil.convertToByteArray(is);
String string = new String(bytes, "UTF-8");
assertTrue(string, string.startsWith("<?xml version=\"1.0\""));
//omit document declaration
assertEquals(xml, string.substring(string.indexOf("><") + 1));
}
代码示例来源:origin: teiid/teiid
@Test public void testStreaming() throws Exception {
StringBuilder xmlBuilder = new StringBuilder();
xmlBuilder.append("<root>");
for (int i = 0; i < 1000; i++) {
xmlBuilder.append("<a></a>");
xmlBuilder.append("<b></b>");
}
xmlBuilder.append("</root>");
String xml = xmlBuilder.toString();
StAXSource source = new StAXSource(XMLType.getXmlInputFactory().createXMLEventReader(new StringReader(xml)));
XMLReader is = new XMLReader(source, XMLOutputFactory.newFactory());
String str = ObjectConverterUtil.convertToString(is);
assertTrue(str, str.startsWith("<?xml version=\"1.0\""));
//omit document declaration
assertEquals(xml, str.substring(str.indexOf("><") + 1));
}
代码示例来源:origin: teiid/teiid
@Test public void testUTF16Streaming() throws Exception {
StringBuilder xmlBuilder = new StringBuilder();
xmlBuilder.append("<root>");
for (int i = 0; i < 1000; i++) {
xmlBuilder.append("<a></a>");
xmlBuilder.append("<b></b>");
}
xmlBuilder.append("</root>");
String xml = xmlBuilder.toString();
StAXSource source = new StAXSource(XMLType.getXmlInputFactory().createXMLEventReader(new StringReader(xml)));
XMLInputStream is = new XMLInputStream(source, XMLOutputFactory.newFactory(), "UTF-16");
byte[] bytes = ObjectConverterUtil.convertToByteArray(is);
String string = new String(bytes, "UTF-16");
assertTrue(string, string.startsWith("<?xml version=\"1.0\""));
//omit document declaration
assertEquals(xml, string.substring(string.indexOf("><") + 1));
}
代码示例来源:origin: teiid/teiid
@Test public void testRepairingNamespaces() throws Exception {
XMLOutputFactory factory = XMLSystemFunctions.getOutputFactory(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLEventWriter writer = factory.createXMLEventWriter(baos);
XMLEventReader reader = XMLType.getXmlInputFactory().createXMLEventReader(new StringReader("<a xmlns:x=\"http://foo\"><b x:y=\"1\"/></a>"));
reader.nextTag();
reader = XMLType.getXmlInputFactory().createFilteredReader(reader, new EventFilter() {
@Override
public boolean accept(XMLEvent arg0) {
if (arg0.isStartDocument() || arg0.isEndDocument()) {
return false;
}
if (arg0.isEndElement() && ((EndElement)arg0).getName().getLocalPart().equals("a")) {
return false;
}
return true;
}
});
writer.add(reader);
writer.close();
assertEquals("<b xmlns=\"\" xmlns:x=\"http://foo\" x:y=\"1\"></b>", new String(baos.toByteArray(), "UTF-8"));
}
代码示例来源:origin: teiid/teiid
@Test public void testTypeConversion() throws Exception {
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
String str = "hello world";
Object source = new StreamSource(new StringReader(str));
XMLType xml = (XMLType) ConnectorWorkItem.convertToRuntimeType(bm, source, DataTypeManager.DefaultDataClasses.XML, null);
assertEquals(str, xml.getString());
source = new StAXSource(XMLType.getXmlInputFactory().createXMLEventReader(new StringReader("<a/>")));
xml = (XMLType) ConnectorWorkItem.convertToRuntimeType(bm, source, DataTypeManager.DefaultDataClasses.XML, null);
XMLInputFactory in = XMLType.getXmlInputFactory();
XMLStreamReader reader = in.createXMLStreamReader(new StringReader(xml.getString()));
assertEquals(XMLEvent.START_DOCUMENT, reader.getEventType());
assertEquals(XMLEvent.START_ELEMENT, reader.next());
assertEquals("a", reader.getLocalName());
assertEquals(XMLEvent.END_ELEMENT, reader.next());
byte[] bytes = str.getBytes(Streamable.ENCODING);
source = new InputStreamFactory.BlobInputStreamFactory(BlobType.createBlob(bytes));
BlobType blob = (BlobType) ConnectorWorkItem.convertToRuntimeType(bm, source, DataTypeManager.DefaultDataClasses.BLOB, null);
assertArrayEquals(bytes, ObjectConverterUtil.convertToByteArray(blob.getBinaryStream()));
}
内容来源于网络,如有侵权,请联系作者删除!