org.w3c.dom.DOMImplementation Java Examples
The following examples show how to use
org.w3c.dom.DOMImplementation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PIDEF0painter.java From ramus with GNU General Public License v3.0 | 6 votes |
private void writeSVG(OutputStream stream) throws IOException { DOMImplementation impl = GenericDOMImplementation .getDOMImplementation(); String svgNS = "http://www.w3.org/2000/svg"; Document myFactory = impl.createDocument(svgNS, "svg", null); SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(myFactory); ctx.setEmbeddedFontsOn(Options.getBoolean("EMBEDDED_SVG_FONTS", true)); SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, Options.getBoolean( "EMBEDDED_SVG_FONTS", true)); svgGenerator.setSVGCanvasSize(size); paint(svgGenerator, 0, 0); boolean useCSS = true; Writer out = new OutputStreamWriter(stream, "UTF-8"); svgGenerator.stream(out, useCSS); }
Example #2
Source File: ShollAnalysisDialog.java From SNT with GNU General Public License v3.0 | 6 votes |
/** * Exports a JFreeChart to a SVG file. * * @param chart * JFreeChart to export * @param bounds * the dimensions of the viewport * @param svgFile * the output file. * @throws IOException * if writing the svgFile fails. * * This method is taken from: * http://dolf.trieschnigg.nl/jfreechart/ */ void exportChartAsSVG(final JFreeChart chart, final Rectangle bounds, final File svgFile) throws IOException { // Get a DOMImplementation and create an XML document final DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); final Document document = domImpl.createDocument(null, "svg", null); // Create an instance of the SVG Generator final SVGGraphics2D svgGenerator = new SVGGraphics2D(document); // draw the chart in the SVG generator chart.draw(svgGenerator, bounds); // Write svg file final OutputStream outputStream = new FileOutputStream(svgFile); final Writer out = new OutputStreamWriter(outputStream, "UTF-8"); svgGenerator.stream(out, true /* use css */); outputStream.flush(); outputStream.close(); }
Example #3
Source File: SVGExporter.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 6 votes |
@Override public void fullExportToStream(ERDesignerGraph aGraph, OutputStream aStream) throws IOException { Object[] cells = aGraph.getRoots(); Rectangle2D bounds = aGraph.toScreen(aGraph.getCellBounds(cells)); if (bounds != null) { DOMImplementation theDomImpl = SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; Document theDocument = theDomImpl.createDocument(svgNS, "svg", null); SVGGraphics2D theSvgGenerator = new SVGGraphics2D(theDocument); theSvgGenerator.translate(-bounds.getX() + 10, -bounds.getY() + 0); RepaintManager theRepaintManager = RepaintManager.currentManager(aGraph); theRepaintManager.setDoubleBufferingEnabled(false); boolean theDoubleBuffered = aGraph.isDoubleBuffered(); // Disable double buffering to allow Batik to render svg elements // instead of images aGraph.setDoubleBuffered(false); aGraph.paint(theSvgGenerator); aGraph.setDoubleBuffered(theDoubleBuffered); Writer theWriter = new OutputStreamWriter(aStream, PlatformConfig.getXMLEncoding()); theSvgGenerator.stream(theWriter, false); theRepaintManager.setDoubleBufferingEnabled(true); theWriter.flush(); theWriter.close(); } }
Example #4
Source File: DOMXSImplementationSourceImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * A method to request a DOM implementation. * @param features A string that specifies which features are required. * This is a space separated list in which each feature is specified * by its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal Events 2.0" * @return An implementation that has the desired features, or * <code>null</code> if this source has none. */ public DOMImplementation getDOMImplementation(String features) { DOMImplementation impl = super.getDOMImplementation(features); if (impl != null){ return impl; } // if not try the PSVIDOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } // if not try the XSImplementation impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } return null; }
Example #5
Source File: DOMXSImplementationSourceImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions * are required. This is a space separated list in which each feature * is specified by its name optionally followed by a space and a * version number. This is something like: "XML 3.0 Traversal +Events * 2.0" * @return A list of DOM implementations that support the desired * features. */ public DOMImplementationList getDOMImplementationList(String features) { final Vector implementations = new Vector(); // first check whether the CoreDOMImplementation would do DOMImplementationList list = super.getDOMImplementationList(features); //Add core DOMImplementations for (int i=0; i < list.getLength(); i++ ) { implementations.addElement(list.item(i)); } DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } return new DOMImplementationListImpl(implementations); }
Example #6
Source File: DOMXSImplementationSourceImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions * are required. This is a space separated list in which each feature * is specified by its name optionally followed by a space and a * version number. This is something like: "XML 3.0 Traversal +Events * 2.0" * @return A list of DOM implementations that support the desired * features. */ public DOMImplementationList getDOMImplementationList(String features) { final Vector implementations = new Vector(); // first check whether the CoreDOMImplementation would do DOMImplementationList list = super.getDOMImplementationList(features); //Add core DOMImplementations for (int i=0; i < list.getLength(); i++ ) { implementations.addElement(list.item(i)); } DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } return new DOMImplementationListImpl(implementations); }
Example #7
Source File: DOMXSImplementationSourceImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * A method to request a DOM implementation. * @param features A string that specifies which features are required. * This is a space separated list in which each feature is specified * by its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal Events 2.0" * @return An implementation that has the desired features, or * <code>null</code> if this source has none. */ public DOMImplementation getDOMImplementation(String features) { DOMImplementation impl = super.getDOMImplementation(features); if (impl != null){ return impl; } // if not try the PSVIDOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } // if not try the XSImplementation impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } return null; }
Example #8
Source File: DOMImplementationSourceImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * A method to request a DOM implementation. * @param features A string that specifies which features are required. * This is a space separated list in which each feature is specified * by its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal Events 2.0" * @return An implementation that has the desired features, or * <code>null</code> if this source has none. */ public DOMImplementation getDOMImplementation(String features) { // first check whether the CoreDOMImplementation would do DOMImplementation impl = CoreDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } // if not try the DOMImplementation impl = DOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } return null; }
Example #9
Source File: MergeStdCommentTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String format = "javax_imageio_1.0"; BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB); ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next(); IIOMetadata meta = iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null); DOMImplementationRegistry registry; registry = DOMImplementationRegistry.newInstance(); DOMImplementation impl = registry.getDOMImplementation("XML 3.0"); Document doc = impl.createDocument(null, format, null); Element root, text, entry; root = doc.getDocumentElement(); root.appendChild(text = doc.createElement("Text")); text.appendChild(entry = doc.createElement("TextEntry")); // keyword isn't #REQUIRED by the standard metadata format. // However, it is required by the PNG format, so we include it here. entry.setAttribute("keyword", "Comment"); entry.setAttribute("value", "Some demo comment"); meta.mergeTree(format, root); }
Example #10
Source File: GetWorkflowImageServlet.java From hop with Apache License 2.0 | 6 votes |
private String generateWorkflowSvgImage( WorkflowMeta workflowMeta ) throws Exception { float magnification = ZOOM_FACTOR; Point maximum = workflowMeta.getMaximum(); maximum.multiply( magnification ); DOMImplementation domImplementation = GenericDOMImplementation.getDOMImplementation(); // Create an instance of org.w3c.dom.Document. String svgNamespace = "http://www.w3.org/2000/svg"; Document document = domImplementation.createDocument(svgNamespace, "svg", null); HopSvgGraphics2D graphics2D = new HopSvgGraphics2D( document ); SvgGc gc = new SvgGc( graphics2D, new Point(maximum.x,maximum.y), 32, 0, 0 ); WorkflowPainter workflowPainter = new WorkflowPainter( gc, workflowMeta, maximum, null, null, null, null, null, new ArrayList<AreaOwner>(), 32, 1, 0, "Arial", 10, 1.0d ); workflowPainter.setMagnification( magnification ); workflowPainter.drawWorkflow(); // convert to SVG // StringWriter stringWriter = new StringWriter(); graphics2D.stream( stringWriter, true ); return stringWriter.toString(); }
Example #11
Source File: DoctypeMaker.java From caja with Apache License 2.0 | 6 votes |
public static Function<DOMImplementation, DocumentType> parse(String text) { // We recognize a subset of the XML DOCTYPE grammar. Specifically, we // do not recognize embedded entity declarations to avoid XXE, or // annotations. // As noted above, we do not recognize the intSubset portion. Matcher m = DOCTYPE_PATTERN.matcher(text); if (!m.matches()) { return null; } String name = m.group(1), system2 = dequote(m.group(2)), pubid = dequote(m.group(3)), system4 = dequote(m.group(4)); final String system = system2 == null ? system4 : system2; boolean isHtml = isHtml(name, pubid, system); if (isHtml && name.indexOf(':') < 0) { name = Strings.lower(name); } final String qname = name; final String publicId = pubid; final String systemId = system; return new Function<DOMImplementation, DocumentType>() { public DocumentType apply(DOMImplementation impl) { return impl.createDocumentType(qname, publicId, systemId); } }; }
Example #12
Source File: Helper.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/*** * Helper method which converts XML Document into pretty formatted string * * @param doc to convert * @return converted XML as String */ public static String documentToString(Document doc) { String strMsg = ""; try { DOMImplementation domImpl = doc.getImplementation(); DOMImplementationLS domImplLS = (DOMImplementationLS) domImpl.getFeature("LS", "3.0"); LSSerializer lsSerializer = domImplLS.createLSSerializer(); lsSerializer.getDomConfig().setParameter("format-pretty-print", true); Writer stringWriter = new StringWriter(); LSOutput lsOutput = domImplLS.createLSOutput(); lsOutput.setEncoding("UTF-8"); lsOutput.setCharacterStream(stringWriter); lsSerializer.write(doc, lsOutput); strMsg = stringWriter.toString(); } catch (Exception e) { logger.warn("Error occurred when converting document to string", e); } return strMsg; }
Example #13
Source File: DOMXSImplementationSourceImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * A method to request a DOM implementation. * @param features A string that specifies which features are required. * This is a space separated list in which each feature is specified * by its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal Events 2.0" * @return An implementation that has the desired features, or * <code>null</code> if this source has none. */ public DOMImplementation getDOMImplementation(String features) { DOMImplementation impl = super.getDOMImplementation(features); if (impl != null){ return impl; } // if not try the PSVIDOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } // if not try the XSImplementation impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } return null; }
Example #14
Source File: SVGExporter.java From jpexs-decompiler with GNU General Public License v3.0 | 6 votes |
public SVGExporter(ExportRectangle bounds, double zoom) { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation impl = docBuilder.getDOMImplementation(); DocumentType svgDocType = impl.createDocumentType("svg", "-//W3C//DTD SVG 1.0//EN", "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"); _svg = impl.createDocument(sNamespace, "svg", svgDocType); Element svgRoot = _svg.getDocumentElement(); svgRoot.setAttribute("xmlns:xlink", xlinkNamespace); if (bounds != null) { svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px"); svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px"); createDefGroup(bounds, null, zoom); } } catch (ParserConfigurationException ex) { Logger.getLogger(SVGExporter.class.getName()).log(Level.SEVERE, null, ex); } gradients = new ArrayList<>(); }
Example #15
Source File: DOMXSImplementationSourceImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions * are required. This is a space separated list in which each feature * is specified by its name optionally followed by a space and a * version number. This is something like: "XML 3.0 Traversal +Events * 2.0" * @return A list of DOM implementations that support the desired * features. */ public DOMImplementationList getDOMImplementationList(String features) { final Vector implementations = new Vector(); // first check whether the CoreDOMImplementation would do DOMImplementationList list = super.getDOMImplementationList(features); //Add core DOMImplementations for (int i=0; i < list.getLength(); i++ ) { implementations.addElement(list.item(i)); } DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } return new DOMImplementationListImpl(implementations); }
Example #16
Source File: XMLUtil.java From netbeans with Apache License 2.0 | 6 votes |
/** * Obtains DOMImpementaton interface providing a number of methods for performing * operations that are independent of any particular DOM instance. * * @throw DOMException <code>NOT_SUPPORTED_ERR</code> if cannot get DOMImplementation * @throw FactoryConfigurationError Application developers should never need to directly catch errors of this type. * * @return DOMImplementation implementation */ private static DOMImplementation getDOMImplementation() throws DOMException { //can be made public DocumentBuilderFactory factory = getFactory(false, false); try { return factory.newDocumentBuilder().getDOMImplementation(); } catch (ParserConfigurationException ex) { throw new DOMException( DOMException.NOT_SUPPORTED_ERR, "Cannot create parser satisfying configuration parameters" ); //NOI18N } catch (RuntimeException e) { // E.g. #36578, IllegalArgumentException. Try to recover gracefully. throw (DOMException) new DOMException(DOMException.NOT_SUPPORTED_ERR, e.toString()).initCause(e); } }
Example #17
Source File: DOMXSImplementationSourceImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * A method to request a DOM implementation. * @param features A string that specifies which features are required. * This is a space separated list in which each feature is specified * by its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal Events 2.0" * @return An implementation that has the desired features, or * <code>null</code> if this source has none. */ public DOMImplementation getDOMImplementation(String features) { DOMImplementation impl = super.getDOMImplementation(features); if (impl != null){ return impl; } // if not try the PSVIDOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } // if not try the XSImplementation impl = XSImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { return impl; } return null; }
Example #18
Source File: DOMImplementationSourceImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * A method to request a list of DOM implementations that support the * specified features and versions, as specified in . * @param features A string that specifies which features and versions * are required. This is a space separated list in which each feature * is specified by its name optionally followed by a space and a * version number. This is something like: "XML 3.0 Traversal +Events * 2.0" * @return A list of DOM implementations that support the desired * features. */ public DOMImplementationList getDOMImplementationList(String features) { // first check whether the CoreDOMImplementation would do DOMImplementation impl = CoreDOMImplementationImpl.getDOMImplementation(); final Vector implementations = new Vector(); if (testImpl(impl, features)) { implementations.addElement(impl); } impl = DOMImplementationImpl.getDOMImplementation(); if (testImpl(impl, features)) { implementations.addElement(impl); } return new DOMImplementationListImpl(implementations); }
Example #19
Source File: UnImplNode.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Unimplemented. See org.w3c.dom.Document * * @return null */ public DOMImplementation getImplementation() { error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); return null; }
Example #20
Source File: XmlSupport.java From java-ocr-api with GNU Affero General Public License v3.0 | 5 votes |
private static Document createPrefsDoc( String qname ) { try { DOMImplementation di = DocumentBuilderFactory.newInstance(). newDocumentBuilder().getDOMImplementation(); DocumentType dt = di.createDocumentType(qname, null, PREFS_DTD_URI); return di.createDocument(null, qname, dt); } catch(ParserConfigurationException e) { throw new AssertionError(e); } }
Example #21
Source File: XMLFileWriter.java From JuiceboxLegacy with MIT License | 5 votes |
private static Element initXML() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation impl = builder.getDOMImplementation(); xmlDoc = impl.createDocument(null, "SavedMaps", null); return xmlDoc.getDocumentElement(); }
Example #22
Source File: DomImplementationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testCreateDocumentType01() throws ParserConfigurationException { final String name = "document:localName"; final String publicId = "pubid"; final String systemId = "sysid"; DOMImplementation domImpl = getDOMImplementation(); DocumentType documentType = domImpl.createDocumentType(name, publicId, systemId); verifyDocumentType(documentType, name, publicId, systemId); }
Example #23
Source File: UnImplNode.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Unimplemented. See org.w3c.dom.Document * * @return null */ public DOMImplementation getImplementation() { error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); return null; }
Example #24
Source File: DOMConfigurationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Equivalence class partitioning with state and input values orientation * for public void setParameter(String name, Object value) throws * DOMException, <br> * <b>pre-conditions</b>: the root element has two Comment nodes, <br> * <b>name</b>: comments <br> * <b>value</b>: true. <br> * <b>Expected results</b>: the Comment nodes belong to the root element */ @Test public void testComments001() { DOMImplementation domImpl = null; try { domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation(); } catch (ParserConfigurationException pce) { Assert.fail(pce.toString()); } catch (FactoryConfigurationError fce) { Assert.fail(fce.toString()); } Document doc = domImpl.createDocument("namespaceURI", "ns:root", null); Comment comment1 = doc.createComment("comment1"); Comment comment2 = doc.createComment("comment2"); DOMConfiguration config = doc.getDomConfig(); config.setParameter("comments", Boolean.TRUE); Element root = doc.getDocumentElement(); root.appendChild(comment1); root.appendChild(comment2); setHandler(doc); doc.normalizeDocument(); if (comment1.getParentNode() != root) { Assert.fail("comment1 is attached to " + comment1.getParentNode() + ", but expected to be a child of root"); } if (comment2.getParentNode() != root) { Assert.fail("comment1 is attached to " + comment2.getParentNode() + ", but expected to be a child of root"); } return; // Status.passed("OK"); }
Example #25
Source File: DOMImplementationRegistry.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Return a list of implementations that support the * desired features. * * @param features * A string that specifies which features are required. This is * a space separated list in which each feature is specified by * its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal +Events 2.0" * @return A list of DOMImplementations that support the desired features. */ public DOMImplementationList getDOMImplementationList(final String features) { final Vector implementations = new Vector(); int size = sources.size(); for (int i = 0; i < size; i++) { DOMImplementationSource source = (DOMImplementationSource) sources.elementAt(i); DOMImplementationList impls = source.getDOMImplementationList(features); for (int j = 0; j < impls.getLength(); j++) { DOMImplementation impl = impls.item(j); implementations.addElement(impl); } } return new DOMImplementationList() { public DOMImplementation item(final int index) { if (index >= 0 && index < implementations.size()) { try { return (DOMImplementation) implementations.elementAt(index); } catch (ArrayIndexOutOfBoundsException e) { return null; } } return null; } public int getLength() { return implementations.size(); } }; }
Example #26
Source File: DOMImplementationRegistry.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Return the first implementation that has the desired * features, or <code>null</code> if none is found. * * @param features * A string that specifies which features are required. This is * a space separated list in which each feature is specified by * its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal +Events 2.0" * @return An implementation that has the desired features, * or <code>null</code> if none found. */ public DOMImplementation getDOMImplementation(final String features) { int size = sources.size(); String name = null; for (int i = 0; i < size; i++) { DOMImplementationSource source = (DOMImplementationSource) sources.elementAt(i); DOMImplementation impl = source.getDOMImplementation(features); if (impl != null) { return impl; } } return null; }
Example #27
Source File: HtmlDocumentBuilder.java From caja with Apache License 2.0 | 5 votes |
/** * Returns the JAXP DOM implementation. * * @return the JAXP DOM implementation */ private static DOMImplementation jaxpDOMImplementation() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } return builder.getDOMImplementation(); }
Example #28
Source File: DOMImplementationRegistry.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Return the first implementation that has the desired * features, or <code>null</code> if none is found. * * @param features * A string that specifies which features are required. This is * a space separated list in which each feature is specified by * its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal +Events 2.0" * @return An implementation that has the desired features, * or <code>null</code> if none found. */ public DOMImplementation getDOMImplementation(final String features) { int size = sources.size(); String name = null; for (int i = 0; i < size; i++) { DOMImplementationSource source = (DOMImplementationSource) sources.elementAt(i); DOMImplementation impl = source.getDOMImplementation(features); if (impl != null) { return impl; } } return null; }
Example #29
Source File: DOMImplementationListImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns the indexth item in the collection. * * @param index The index of the DOMImplemetation from the list to return. */ public DOMImplementation item(int index) { try { return (DOMImplementation) fImplementations.elementAt(index); } catch (ArrayIndexOutOfBoundsException e) { return null; } }
Example #30
Source File: DOMImplementationRegistry.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Return a list of implementations that support the * desired features. * * @param features * A string that specifies which features are required. This is * a space separated list in which each feature is specified by * its name optionally followed by a space and a version number. * This is something like: "XML 1.0 Traversal +Events 2.0" * @return A list of DOMImplementations that support the desired features. */ public DOMImplementationList getDOMImplementationList(final String features) { final Vector implementations = new Vector(); int size = sources.size(); for (int i = 0; i < size; i++) { DOMImplementationSource source = (DOMImplementationSource) sources.elementAt(i); DOMImplementationList impls = source.getDOMImplementationList(features); for (int j = 0; j < impls.getLength(); j++) { DOMImplementation impl = impls.item(j); implementations.addElement(impl); } } return new DOMImplementationList() { public DOMImplementation item(final int index) { if (index >= 0 && index < implementations.size()) { try { return (DOMImplementation) implementations.elementAt(index); } catch (ArrayIndexOutOfBoundsException e) { return null; } } return null; } public int getLength() { return implementations.size(); } }; }