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; }
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; }
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; }
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; }
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; }
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; }
@Override protected void readReference(ObjectInput in) throws IOException { byte[] bytes = new byte[(int)getLength()]; in.readFully(bytes); this.reference = new SQLXMLImpl(bytes); }
@Override protected void readReference(ObjectInput in) throws IOException { byte[] bytes = new byte[(int)getLength()]; in.readFully(bytes); this.reference = new SQLXMLImpl(bytes); }
@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; }
@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; }
@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; }
public SQLXMLImpl getVDBResourceAsSQLXML(String resourcePath) { final VDBResources.Resource f = getFile(resourcePath); if (f == null) { return null; } return new SQLXMLImpl(new VirtualFileInputStreamFactory(f)); }
public SQLXMLImpl getVDBResourceAsSQLXML(String resourcePath) { final VDBResources.Resource f = getFile(resourcePath); if (f == null) { return null; } return new SQLXMLImpl(new VirtualFileInputStreamFactory(f)); }
public SQLXMLImpl getVDBResourceAsSQLXML(String resourcePath) { final VDBResources.Resource f = getFile(resourcePath); if (f == null) { return null; } return new SQLXMLImpl(new VirtualFileInputStreamFactory(f)); }
@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); }
@Test public void testGetBinaryStream() throws Exception { SQLXMLImpl xml = new SQLXMLImpl(testStr); assertEquals(testStr, new String(ObjectConverterUtil.convertToByteArray(xml.getBinaryStream()), Streamable.ENCODING)); }
@Test public void testGetSource() throws Exception { SQLXMLImpl xml = new SQLXMLImpl(testStr); assertTrue(xml.getSource(null) instanceof StreamSource); StreamSource ss = (StreamSource)xml.getSource(null); assertEquals(testStr, new String(ObjectConverterUtil.convertToByteArray(ss.getInputStream()), Streamable.ENCODING)); }
@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()); }
@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()); }
@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()); }