rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
tree.setRootVisible(true); | public void installUI(JComponent c) { tree = (JTree) c; configureLayoutCache(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); tree.setFont(defaults.getFont("Tree.font")); tree.setForeground(defaults.getColor("Tree.foreground")); tree.setBackground(defaults.getColor("Tree.background")); tree.setOpaque(true); tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); rightChildIndent = defaults.getInt("Tree.rightChildIndent"); leftChildIndent = defaults.getInt("Tree.leftChildIndent"); setRowHeight(defaults.getInt("Tree.rowHeight")); tree.requestFocusInWindow(false); setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon")); currentCellRenderer = createDefaultCellRenderer(); rendererPane = createCellRendererPane(); createdRenderer = true; setCellEditor(createDefaultCellEditor()); createdCellEditor = true; TreeModel mod = tree.getModel(); setModel(mod); tree.setRootVisible(true); if (mod != null) tree.expandPath(new TreePath(mod.getRoot())); treeSelectionModel = tree.getSelectionModel(); drawingCache = new Hashtable(); nodeDimensions = createNodeDimensions(); propertyChangeListener = createPropertyChangeListener(); focusListener = createFocusListener(); treeSelectionListener = createTreeSelectionListener(); mouseInputListener = new MouseInputHandler(null, null, null); keyListener = createKeyListener(); selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener(); componentListener = createComponentListener(); cellEditorListener = createCellEditorListener(); treeExpansionListener = createTreeExpansionListener(); treeModelListener = createTreeModelListener(); editingRow = -1; lastSelectedRow = -1; installKeyboardActions(); tree.addPropertyChangeListener(propertyChangeListener); tree.addFocusListener(focusListener); tree.addTreeSelectionListener(treeSelectionListener); tree.addMouseListener(mouseInputListener); tree.addKeyListener(keyListener); tree.addPropertyChangeListener(selectionModelPropertyChangeListener); tree.addComponentListener(componentListener); tree.addTreeExpansionListener(treeExpansionListener); if (treeModel != null) treeModel.addTreeModelListener(treeModelListener); completeUIInstall(); } |
|
public TreePath(Object element) { | public TreePath(Object[] path) { | public TreePath(Object element) { // Create Path path = new Object[1]; path[0] = element; } // TreePath() |
path = new Object[1]; path[0] = element; } | this.path = new Object[path.length]; System.arraycopy(path, 0, this.path, 0, path.length); } | public TreePath(Object element) { // Create Path path = new Object[1]; path[0] = element; } // TreePath() |
public void removeCellEditorListener(CellEditorListener listener); | void removeCellEditorListener(CellEditorListener listener); | public void removeCellEditorListener(CellEditorListener listener); |
{ | void convertCdataSectionElements(Document doc, Node node, List list) { if (node.getNodeType() == Node.ELEMENT_NODE) { boolean match = false; for (Iterator i = list.iterator(); i.hasNext(); ) { QName qname = (QName) i.next(); if (match(qname, node)) { match = true; break; } } if (match) { Node ctx = node.getFirstChild(); while (ctx != null) { if (ctx.getNodeType() == Node.TEXT_NODE) { Node cdata = doc.createCDATASection(ctx.getNodeValue()); node.replaceChild(cdata, ctx); ctx = cdata; } ctx = ctx.getNextSibling(); } } } Node ctx = node.getFirstChild(); while (ctx != null) { if (ctx.hasChildNodes()) { convertCdataSectionElements(doc, ctx, list); } ctx = ctx.getNextSibling(); } } |
|
} | void convertCdataSectionElements(Document doc, Node node, List list) { if (node.getNodeType() == Node.ELEMENT_NODE) { boolean match = false; for (Iterator i = list.iterator(); i.hasNext(); ) { QName qname = (QName) i.next(); if (match(qname, node)) { match = true; break; } } if (match) { Node ctx = node.getFirstChild(); while (ctx != null) { if (ctx.getNodeType() == Node.TEXT_NODE) { Node cdata = doc.createCDATASection(ctx.getNodeValue()); node.replaceChild(cdata, ctx); ctx = cdata; } ctx = ctx.getNextSibling(); } } } Node ctx = node.getFirstChild(); while (ctx != null) { if (ctx.hasChildNodes()) { convertCdataSectionElements(doc, ctx, list); } ctx = ctx.getNextSibling(); } } |
|
{ | public Object getParameter(String name) { if (stylesheet != null) { return stylesheet.bindings.get(new QName(null, name), null, 1, 1); } return null; } |
|
} | public Object getParameter(String name) { if (stylesheet != null) { return stylesheet.bindings.get(new QName(null, name), null, 1, 1); } return null; } |
|
{ | boolean match(QName qname, Node node) { String ln1 = qname.getLocalPart(); String ln2 = node.getLocalName(); if (ln2 == null) { return ln1.equals(node.getNodeName()); } else { String uri1 = qname.getNamespaceURI(); String uri2 = node.getNamespaceURI(); return (uri1.equals(uri2) && ln1.equals(ln2)); } } |
|
} | boolean match(QName qname, Node node) { String ln1 = qname.getLocalPart(); String ln2 = node.getLocalName(); if (ln2 == null) { return ln1.equals(node.getNodeName()); } else { String uri1 = qname.getNamespaceURI(); String uri2 = node.getNamespaceURI(); return (uri1.equals(uri2) && ln1.equals(ln2)); } } |
|
{ | void reindent(Document doc, Node node, int offset) { if (node.hasChildNodes()) { boolean markupContent = false; boolean textContent = false; List children = new LinkedList(); Node ctx = node.getFirstChild(); while (ctx != null) { switch (ctx.getNodeType()) { case Node.ELEMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.DOCUMENT_TYPE_NODE: markupContent = true; break; case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: case Node.ENTITY_REFERENCE_NODE: case Node.COMMENT_NODE: textContent = true; break; } children.add(ctx); ctx = ctx.getNextSibling(); } if (markupContent) { if (textContent) { // XXX handle mixed content differently? } int nodeType = node.getNodeType(); if (nodeType == Node.DOCUMENT_NODE) { for (Iterator i = children.iterator(); i.hasNext(); ) { ctx = (Node) i.next(); reindent(doc, ctx, offset + 1); } } else { StringBuffer buf = new StringBuffer(); buf.append('\n'); for (int i = 0; i < offset + 1; i++) { buf.append(INDENT_WHITESPACE); } String ws = buf.toString(); for (Iterator i = children.iterator(); i.hasNext(); ) { ctx = (Node) i.next(); node.insertBefore(doc.createTextNode(ws), ctx); reindent(doc, ctx, offset + 1); } buf = new StringBuffer(); buf.append('\n'); ws = buf.toString(); for (int i = 0; i < offset; i++) { buf.append(INDENT_WHITESPACE); } node.appendChild(doc.createTextNode(ws)); } } } } |
|
} | void reindent(Document doc, Node node, int offset) { if (node.hasChildNodes()) { boolean markupContent = false; boolean textContent = false; List children = new LinkedList(); Node ctx = node.getFirstChild(); while (ctx != null) { switch (ctx.getNodeType()) { case Node.ELEMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.DOCUMENT_TYPE_NODE: markupContent = true; break; case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: case Node.ENTITY_REFERENCE_NODE: case Node.COMMENT_NODE: textContent = true; break; } children.add(ctx); ctx = ctx.getNextSibling(); } if (markupContent) { if (textContent) { // XXX handle mixed content differently? } int nodeType = node.getNodeType(); if (nodeType == Node.DOCUMENT_NODE) { for (Iterator i = children.iterator(); i.hasNext(); ) { ctx = (Node) i.next(); reindent(doc, ctx, offset + 1); } } else { StringBuffer buf = new StringBuffer(); buf.append('\n'); for (int i = 0; i < offset + 1; i++) { buf.append(INDENT_WHITESPACE); } String ws = buf.toString(); for (Iterator i = children.iterator(); i.hasNext(); ) { ctx = (Node) i.next(); node.insertBefore(doc.createTextNode(ws), ctx); reindent(doc, ctx, offset + 1); } buf = new StringBuffer(); buf.append('\n'); ws = buf.toString(); for (int i = 0; i < offset; i++) { buf.append(INDENT_WHITESPACE); } node.appendChild(doc.createTextNode(ws)); } } } } |
|
{ | public void setOutputProperties(Properties oformat) throws IllegalArgumentException { if (oformat == null) { outputProperties.clear(); } else { outputProperties.putAll(oformat); } } |
|
} | public void setOutputProperties(Properties oformat) throws IllegalArgumentException { if (oformat == null) { outputProperties.clear(); } else { outputProperties.putAll(oformat); } } |
|
{ | public void setParameter(String name, Object value) { if (stylesheet != null) { stylesheet.bindings.set(new QName(null, name), value, Bindings.PARAM); } } |
|
} | public void setParameter(String name, Object value) { if (stylesheet != null) { stylesheet.bindings.set(new QName(null, name), value, Bindings.PARAM); } } |
|
void strip(Node node) | static boolean strip(Stylesheet stylesheet, Node node) | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
if (child != null) { strip(child); } | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
|
parent.insertBefore(child, node); | if (nextSibling != null) parent.insertBefore(child, nextSibling); else parent.appendChild(child); | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
parent.removeChild(node); | return true; | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
if (!stylesheet.isPreserved((Text) node)) | String text = node.getNodeValue(); String[] tokens = tokenizeWhitespace(text); if (tokens.length > 1) | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
node.getParentNode().removeChild(node); | node.setNodeValue(tokens[0]); Node parent = node.getParentNode(); Node nextSibling = node.getNextSibling(); Document doc = node.getOwnerDocument(); for (int i = 1; i < tokens.length; i++) { Node newChild = (nt == Node.CDATA_SECTION_NODE) ? doc.createCDATASection(tokens[i]) : doc.createTextNode(tokens[i]); if (nextSibling != null) parent.insertBefore(newChild, nextSibling); else parent.appendChild(newChild); } } return !stylesheet.isPreserved((Text) node, true); | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) | Node child = node.getFirstChild(); while (child != null) | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
node.setNodeValue(stripped); | boolean remove = strip(stylesheet, child); Node next = child.getNextSibling(); if (remove) node.removeChild(child); child = next; | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } | void strip(Node node) throws TransformerConfigurationException { short nt = node.getNodeType(); if (nt == Node.ENTITY_REFERENCE_NODE) { // Replace entity reference with its content Node parent = node.getParentNode(); Node child = node.getFirstChild(); if (child != null) { strip(child); } while (child != null) { Node next = child.getNextSibling(); node.removeChild(child); parent.insertBefore(child, node); child = next; } parent.removeChild(node); } if (nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE) { if (!stylesheet.isPreserved((Text) node)) { node.getParentNode().removeChild(node); } else { String text = node.getNodeValue(); String stripped = text.trim(); if (!text.equals(stripped)) { node.setNodeValue(stripped); } } } else { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { strip(child); } } } |
|
strip(context); | strip(stylesheet, context); | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
{ | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
|
} | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
|
} else { | else | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
if ((publicId != null || systemId != null) && root != null) | if (publicId != null || systemId != null) { if (root != null) | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
resultDoc.appendChild(new DomDoctype(resultDoc, | DocumentType doctype = new DomDoctype(resultDoc, | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
systemId)); | systemId); resultDoc.insertBefore(doctype, root); } | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
impl.createDocumentType(resultDoc.getNodeName(), | impl.createDocumentType(root.getNodeName(), | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); | resultDoc.insertBefore(doctype, root); | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
strip(parent); | strip(stylesheet, parent); | public void transform(Source xmlSource, Result outputTarget) throws TransformerException { // Get the source tree DOMSource source; synchronized (factory.resolver) { factory.resolver.setUserResolver(uriResolver); factory.resolver.setUserListener(errorListener); source = factory.resolver.resolveDOM(xmlSource, null, null); } Node context = source.getNode(); Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); if (doc instanceof DomDocument) { // Suppress mutation events ((DomDocument) doc).setBuilding(true); // TODO find a better/more generic way of doing this than // casting } // Get the result tree Node parent = null, nextSibling = null; if (outputTarget instanceof DOMResult) { DOMResult dr = (DOMResult) outputTarget; parent = dr.getNode(); nextSibling = dr.getNextSibling(); Document rdoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); if (rdoc instanceof DomDocument) { // Suppress mutation events and allow multiple root elements DomDocument drdoc = (DomDocument) rdoc; drdoc.setBuilding(true); drdoc.setCheckWellformedness(false); // TODO find a better/more generic way of doing this than // casting } } boolean created = false; // Transformation if (stylesheet != null) { if (parent == null) { // Create a new document to hold the result DomDocument resultDoc = new DomDocument(); resultDoc.setBuilding(true); resultDoc.setCheckWellformedness(false); parent = resultDoc; created = true; } // Make a copy of the source node, and strip it context = context.cloneNode(true); strip(context); // XSLT transformation try { // Set output properties in the underlying stylesheet ((TransformerOutputProperties) outputProperties).apply(); stylesheet.initTopLevelVariables(context); TemplateNode t = stylesheet.getTemplate(null, context, false); if (t != null) { stylesheet.current = context; t.apply(stylesheet, null, context, 1, 1, parent, nextSibling); } } catch (TransformerException e) { // Done transforming, reset document if (doc instanceof DomDocument) { ((DomDocument) doc).setBuilding(false); } throw e; } } else { // Identity transform Node clone = context.cloneNode(true); if (context.getNodeType() != Node.DOCUMENT_NODE) { Document resultDoc; if (parent == null) { // Create a new document to hold the result DomDocument rd = new DomDocument(); rd.setBuilding(true); rd.setCheckWellformedness(false); parent = resultDoc = rd; created = true; } else { resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); } Document sourceDoc = context.getOwnerDocument(); if (sourceDoc != resultDoc) { clone = resultDoc.adoptNode(clone); } if (nextSibling != null) { parent.insertBefore(clone, nextSibling); } else { parent.appendChild(clone); } } else { // Cannot append document to another tree parent = clone; created = true; } } String method = outputProperties.getProperty(OutputKeys.METHOD); int outputMethod = "html".equals(method) ? Stylesheet.OUTPUT_HTML : "text".equals(method) ? Stylesheet.OUTPUT_TEXT : Stylesheet.OUTPUT_XML; String encoding = outputProperties.getProperty(OutputKeys.ENCODING); String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); String version = outputProperties.getProperty(OutputKeys.VERSION); boolean omitXmlDeclaration = "yes".equals(outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION)); boolean standalone = "yes".equals(outputProperties.getProperty(OutputKeys.STANDALONE)); String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); String cdataSectionElements = outputProperties.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); boolean indent = "yes".equals(outputProperties.getProperty(OutputKeys.INDENT)); if (created) { // Discover document element DomDocument resultDoc = (DomDocument) parent; Node root = resultDoc.getDocumentElement(); // Add doctype if specified if ((publicId != null || systemId != null) && root != null) { // We must know the name of the root element to // create the document type resultDoc.appendChild(new DomDoctype(resultDoc, root.getNodeName(), publicId, systemId)); } resultDoc.setBuilding(false); resultDoc.setCheckWellformedness(true); } else if (publicId != null || systemId != null) { switch (parent.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); DOMImplementation impl = resultDoc.getImplementation(); DocumentType doctype = impl.createDocumentType(resultDoc.getNodeName(), publicId, systemId); // Try to insert doctype before first element Node ctx = parent.getFirstChild(); for (; ctx != null && ctx.getNodeType() != Node.ELEMENT_NODE; ctx = ctx.getNextSibling()) { } if (ctx != null) { parent.insertBefore(doctype, ctx); } else { parent.appendChild(doctype); } } } if (version != null) { parent.setUserData("version", version, stylesheet); } if (omitXmlDeclaration) { parent.setUserData("omit-xml-declaration", "yes", stylesheet); } if (standalone) { parent.setUserData("standalone", "yes", stylesheet); } if (mediaType != null) { parent.setUserData("media-type", mediaType, stylesheet); } if (cdataSectionElements != null) { List list = new LinkedList(); StringTokenizer st = new StringTokenizer(cdataSectionElements); while (st.hasMoreTokens()) { String name = st.nextToken(); String localName = name; String uri = null; String prefix = null; int ci = name.indexOf(':'); if (ci != -1) { // Use namespaces defined on xsl:output node to resolve // namespaces for QName prefix = name.substring(0, ci); localName = name.substring(ci + 1); uri = stylesheet.output.lookupNamespaceURI(prefix); } list.add(new QName(uri, localName, prefix)); } if (!list.isEmpty()) { Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); convertCdataSectionElements(resultDoc, parent, list); } } if (indent) { parent.normalize(); strip(parent); Document resultDoc = (parent instanceof Document) ? (Document) parent : parent.getOwnerDocument(); reindent(resultDoc, parent, 0); } // Render result to the target device if (outputTarget instanceof DOMResult) { if (created) { DOMResult dr = (DOMResult) outputTarget; dr.setNode(parent); dr.setNextSibling(null); } } else if (outputTarget instanceof StreamResult) { StreamResult sr = (StreamResult) outputTarget; IOException ex = null; try { writeStreamResult(parent, sr, outputMethod, encoding); } catch (UnsupportedEncodingException e) { try { writeStreamResult(parent, sr, outputMethod, "UTF-8"); } catch (IOException e2) { ex = e2; } } catch (IOException e) { ex = e; } if (ex != null) { if (errorListener != null) { errorListener.error(new TransformerException(ex)); } else { ex.printStackTrace(System.err); } } } else if (outputTarget instanceof SAXResult) { SAXResult sr = (SAXResult) outputTarget; try { ContentHandler ch = sr.getHandler(); LexicalHandler lh = sr.getLexicalHandler(); if (lh == null && ch instanceof LexicalHandler) { lh = (LexicalHandler) ch; } SAXSerializer serializer = new SAXSerializer(); serializer.serialize(parent, ch, lh); } catch (SAXException e) { if (errorListener != null) { errorListener.error(new TransformerException(e)); } else { e.printStackTrace(System.err); } } } } |
{ | void writeStreamResult(Node node, StreamResult sr, int outputMethod, String encoding) throws IOException { OutputStream out = null; boolean created = false; try { out = sr.getOutputStream(); if (out == null) { Writer writer = sr.getWriter(); if (writer != null) { out = new WriterOutputStream(writer); } } if (out == null) { String systemId = sr.getSystemId(); try { URL url = new URL(systemId); URLConnection connection = url.openConnection(); // We need to call setDoInput(false), because our // implementation of the file protocol allows writing // (unlike Sun), but it will fail with a FileNotFoundException // if we also open the connection for input and the output // file doesn't yet exist. connection.setDoInput(false); connection.setDoOutput(true); out = connection.getOutputStream(); } catch (MalformedURLException e) { out = new FileOutputStream(systemId); } catch (UnknownServiceException e) { URL url = new URL(systemId); out = new FileOutputStream(url.getPath()); } created = true; } out = new BufferedOutputStream(out); StreamSerializer serializer = new StreamSerializer(outputMethod, encoding, null); if (stylesheet != null) { Collection celem = stylesheet.outputCdataSectionElements; serializer.setCdataSectionElements(celem); } serializer.serialize(node, out); out.flush(); } finally { try { if (out != null && created) { out.close(); } } catch (IOException e) { } } } |
|
} | void writeStreamResult(Node node, StreamResult sr, int outputMethod, String encoding) throws IOException { OutputStream out = null; boolean created = false; try { out = sr.getOutputStream(); if (out == null) { Writer writer = sr.getWriter(); if (writer != null) { out = new WriterOutputStream(writer); } } if (out == null) { String systemId = sr.getSystemId(); try { URL url = new URL(systemId); URLConnection connection = url.openConnection(); // We need to call setDoInput(false), because our // implementation of the file protocol allows writing // (unlike Sun), but it will fail with a FileNotFoundException // if we also open the connection for input and the output // file doesn't yet exist. connection.setDoInput(false); connection.setDoOutput(true); out = connection.getOutputStream(); } catch (MalformedURLException e) { out = new FileOutputStream(systemId); } catch (UnknownServiceException e) { URL url = new URL(systemId); out = new FileOutputStream(url.getPath()); } created = true; } out = new BufferedOutputStream(out); StreamSerializer serializer = new StreamSerializer(outputMethod, encoding, null); if (stylesheet != null) { Collection celem = stylesheet.outputCdataSectionElements; serializer.setCdataSectionElements(celem); } serializer.serialize(node, out); out.flush(); } finally { try { if (out != null && created) { out.close(); } } catch (IOException e) { } } } |
|
public abstract void setOutputProperties(Properties outputformat) | public abstract void setOutputProperties(Properties oformat) | public abstract void setOutputProperties(Properties outputformat) throws IllegalArgumentException; |
public abstract void transform(Source source, Result result) throws TransformerException; | public abstract void transform(Source xmlSource, Result outputTarget) throws TransformerException; | public abstract void transform(Source source, Result result) throws TransformerException; |
public LexicalHandler getLexicalHandler() { return lexhandler; | public LexicalHandler getLexicalHandler() { return lexicalHandler; | public LexicalHandler getLexicalHandler() { return lexhandler; } |
public URLConnection openConnection() throws IOException { return handler.openConnection(this); | public URLConnection openConnection() throws IOException { return ph.openConnection(this); | public URLConnection openConnection() throws IOException { return handler.openConnection(this); } |
public String getPath() { int quest = (file == null) ? -1 : file.indexOf('?'); | public String getPath() { if (file == null) return null; int quest = file.indexOf('?'); | public String getPath() { int quest = (file == null) ? -1 : file.indexOf('?'); return quest < 0 ? getFile() : file.substring(0, quest); } |
public static final String toString(byte[] ba, int offset, int length) | public static String toString(byte[] ba) | public static final String toString(byte[] ba, int offset, int length) { char[] buf = new char[length * 2]; for (int i = 0, j = 0, k; i < length;) { k = ba[offset + i++]; buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F]; buf[j++] = HEX_DIGITS[k & 0x0F]; } return new String(buf); } |
char[] buf = new char[length * 2]; for (int i = 0, j = 0, k; i < length;) { k = ba[offset + i++]; buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F]; buf[j++] = HEX_DIGITS[k & 0x0F]; } return new String(buf); | return toString(ba, 0, ba.length); | public static final String toString(byte[] ba, int offset, int length) { char[] buf = new char[length * 2]; for (int i = 0, j = 0, k; i < length;) { k = ba[offset + i++]; buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F]; buf[j++] = HEX_DIGITS[k & 0x0F]; } return new String(buf); } |
public DERValue read() throws IOException | public static DERValue read(byte[] encoded) throws IOException | public DERValue read() throws IOException { int tag = in.read(); if (tag == -1) throw new EOFException(); encBuf.write(tag); int len = readLength(); DERValue value = null; if ((tag & CONSTRUCTED) == CONSTRUCTED) { in.mark(2048); byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray()); in.reset(); encBuf.reset(); return value; } switch (tag & 0xC0) { case UNIVERSAL: value = new DERValue(tag, len, readUniversal(tag, len), encBuf.toByteArray()); encBuf.reset(); break; case CONTEXT: byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, encoded, encBuf.toByteArray()); encBuf.reset(); break; case APPLICATION: // This should not be reached, since (I think) APPLICATION is // always constructed. throw new DEREncodingException("non-constructed APPLICATION data"); default: throw new DEREncodingException("PRIVATE class not supported"); } return value; } |
int tag = in.read(); if (tag == -1) throw new EOFException(); encBuf.write(tag); int len = readLength(); DERValue value = null; if ((tag & CONSTRUCTED) == CONSTRUCTED) { in.mark(2048); byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray()); in.reset(); encBuf.reset(); return value; } switch (tag & 0xC0) { case UNIVERSAL: value = new DERValue(tag, len, readUniversal(tag, len), encBuf.toByteArray()); encBuf.reset(); break; case CONTEXT: byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, encoded, encBuf.toByteArray()); encBuf.reset(); break; case APPLICATION: throw new DEREncodingException("non-constructed APPLICATION data"); default: throw new DEREncodingException("PRIVATE class not supported"); } return value; | return new DERReader(encoded).read(); | public DERValue read() throws IOException { int tag = in.read(); if (tag == -1) throw new EOFException(); encBuf.write(tag); int len = readLength(); DERValue value = null; if ((tag & CONSTRUCTED) == CONSTRUCTED) { in.mark(2048); byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray()); in.reset(); encBuf.reset(); return value; } switch (tag & 0xC0) { case UNIVERSAL: value = new DERValue(tag, len, readUniversal(tag, len), encBuf.toByteArray()); encBuf.reset(); break; case CONTEXT: byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, encoded, encBuf.toByteArray()); encBuf.reset(); break; case APPLICATION: // This should not be reached, since (I think) APPLICATION is // always constructed. throw new DEREncodingException("non-constructed APPLICATION data"); default: throw new DEREncodingException("PRIVATE class not supported"); } return value; } |
catch (NoSuchAlgorithmException ignored) {} | catch (NoSuchAlgorithmException e) { } | public static KeyPairGenerator getInstance(String algorithm) throws NoSuchAlgorithmException { Provider[] p = Security.getProviders(); for (int i = 0; i < p.length; i++) { try { return getInstance(algorithm, p[i]); } catch (NoSuchAlgorithmException ignored) {} } throw new NoSuchAlgorithmException(algorithm); } |
catch (NoSuchAlgorithmException ignored) {} | catch (NoSuchAlgorithmException e) { } | public static Signature getInstance(String algorithm) throws NoSuchAlgorithmException { Provider[] p = Security.getProviders(); for (int i = 0; i < p.length; i++) { try { return getInstance(algorithm, p[i]); } catch (NoSuchAlgorithmException ignored) {} } throw new NoSuchAlgorithmException(algorithm); } |
public FileInputStream(File file) throws FileNotFoundException | public FileInputStream(String name) throws FileNotFoundException | public FileInputStream(File file) throws FileNotFoundException { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkRead(file.getPath()); ch = FileChannelImpl.create(file, FileChannelImpl.READ); } |
SecurityManager s = System.getSecurityManager(); if (s != null) s.checkRead(file.getPath()); ch = FileChannelImpl.create(file, FileChannelImpl.READ); | this(new File(name)); | public FileInputStream(File file) throws FileNotFoundException { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkRead(file.getPath()); ch = FileChannelImpl.create(file, FileChannelImpl.READ); } |
catch (KeyStoreException ignore) | catch (KeyStoreException e) | public static KeyStore getInstance(String type) throws KeyStoreException { Provider[] p = Security.getProviders(); for (int i = 0; i < p.length; i++) { try { return getInstance(type, p[i]); } catch (KeyStoreException ignore) { } } throw new KeyStoreException(type); } |
NumberNode(TemplateNode children, TemplateNode next, Expr value, TemplateNode format, String lang, | NumberNode(Expr value, TemplateNode format, String lang, | NumberNode(TemplateNode children, TemplateNode next, Expr value, TemplateNode format, String lang, int letterValue, String groupingSeparator, int groupingSize) { super(children, next, format, lang, letterValue, groupingSeparator, groupingSize); this.value = value; } |
super(children, next, format, lang, letterValue, groupingSeparator, groupingSize); | super(format, lang, letterValue, groupingSeparator, groupingSize); | NumberNode(TemplateNode children, TemplateNode next, Expr value, TemplateNode format, String lang, int letterValue, String groupingSeparator, int groupingSize) { super(children, next, format, lang, letterValue, groupingSeparator, groupingSize); this.value = value; } |
return new NumberNode((children == null) ? null : children.clone(stylesheet), (next == null) ? null : next.clone(stylesheet), value.clone(stylesheet), | TemplateNode ret = new NumberNode(value.clone(stylesheet), | TemplateNode clone(Stylesheet stylesheet) { return new NumberNode((children == null) ? null : children.clone(stylesheet), (next == null) ? null : next.clone(stylesheet), value.clone(stylesheet), format, lang, letterValue, groupingSeparator, groupingSize); } |
if (children != null) { ret.children = children.clone(stylesheet); } if (next != null) { ret.next = next.clone(stylesheet); } return ret; | TemplateNode clone(Stylesheet stylesheet) { return new NumberNode((children == null) ? null : children.clone(stylesheet), (next == null) ? null : next.clone(stylesheet), value.clone(stylesheet), format, lang, letterValue, groupingSeparator, groupingSize); } |
|
public Iterator iterator() { | public Iterator<IndexEntry> iterator() { | public Iterator iterator() { final int headerOffset = getAttributeOffset() + IndexRoot.SIZE; return new IndexEntryIterator(getFileRecord(), this, headerOffset + getHeader() .getFirstEntryOffset()); } |
boolean modified = false; | protected void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color) { final byte[] buf = new byte[width]; final int[] pixels = new int[width]; final int c1 = color & 0xFF; final int c2 = (color >> 8) & 0xFF; final int c3 = (color >> 16) & 0xFF; for (int row = 0; row < height; row++) { final int ofs = offset + ((dstY + row) * bytesPerLine) + (dstX << 2); raster.getDataElements(srcX, srcY + row, width, 1, buf); mem.getInts(ofs, pixels, 0, width);// System.out.print(" w" + width + " "); for (int i = 0; i < width; i++) { final int dst = pixels[i]; final int alpha = (buf[i] & 0xFF);// System.out.print(NumberUtils.hex(alpha, 2)); final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); // pixels[i] = (alpha & 0xFF) + ((alpha & 0xFF) << 8) + ((alpha & 0xFF) << 16);// pixels[i] = (alpha > 128) ? color : dst; }// System.out.println(); mem.setInts(pixels, 0, ofs, width); } } |
|
final int dst = pixels[i]; | protected void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color) { final byte[] buf = new byte[width]; final int[] pixels = new int[width]; final int c1 = color & 0xFF; final int c2 = (color >> 8) & 0xFF; final int c3 = (color >> 16) & 0xFF; for (int row = 0; row < height; row++) { final int ofs = offset + ((dstY + row) * bytesPerLine) + (dstX << 2); raster.getDataElements(srcX, srcY + row, width, 1, buf); mem.getInts(ofs, pixels, 0, width);// System.out.print(" w" + width + " "); for (int i = 0; i < width; i++) { final int dst = pixels[i]; final int alpha = (buf[i] & 0xFF);// System.out.print(NumberUtils.hex(alpha, 2)); final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); // pixels[i] = (alpha & 0xFF) + ((alpha & 0xFF) << 8) + ((alpha & 0xFF) << 16);// pixels[i] = (alpha > 128) ? color : dst; }// System.out.println(); mem.setInts(pixels, 0, ofs, width); } } |
|
final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; | protected void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color) { final byte[] buf = new byte[width]; final int[] pixels = new int[width]; final int c1 = color & 0xFF; final int c2 = (color >> 8) & 0xFF; final int c3 = (color >> 16) & 0xFF; for (int row = 0; row < height; row++) { final int ofs = offset + ((dstY + row) * bytesPerLine) + (dstX << 2); raster.getDataElements(srcX, srcY + row, width, 1, buf); mem.getInts(ofs, pixels, 0, width);// System.out.print(" w" + width + " "); for (int i = 0; i < width; i++) { final int dst = pixels[i]; final int alpha = (buf[i] & 0xFF);// System.out.print(NumberUtils.hex(alpha, 2)); final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); // pixels[i] = (alpha & 0xFF) + ((alpha & 0xFF) << 8) + ((alpha & 0xFF) << 16);// pixels[i] = (alpha > 128) ? color : dst; }// System.out.println(); mem.setInts(pixels, 0, ofs, width); } } |
|
final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); | if (alpha != 0) { final int dst = pixels[i]; final int d1 = dst & 0xFF; final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = (((alpha * (c1 - d1)) >> 8) + d1) & 0xFF; final int r2 = (((alpha * (c2 - d2)) >> 8) + d2) & 0xFF; final int r3 = (((alpha * (c3 - d3)) >> 8) + d3) & 0xFF; pixels[i] = r1 | (r2 << 8) | (r3 << 16); modified = true; } | protected void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color) { final byte[] buf = new byte[width]; final int[] pixels = new int[width]; final int c1 = color & 0xFF; final int c2 = (color >> 8) & 0xFF; final int c3 = (color >> 16) & 0xFF; for (int row = 0; row < height; row++) { final int ofs = offset + ((dstY + row) * bytesPerLine) + (dstX << 2); raster.getDataElements(srcX, srcY + row, width, 1, buf); mem.getInts(ofs, pixels, 0, width);// System.out.print(" w" + width + " "); for (int i = 0; i < width; i++) { final int dst = pixels[i]; final int alpha = (buf[i] & 0xFF);// System.out.print(NumberUtils.hex(alpha, 2)); final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); // pixels[i] = (alpha & 0xFF) + ((alpha & 0xFF) << 8) + ((alpha & 0xFF) << 16);// pixels[i] = (alpha > 128) ? color : dst; }// System.out.println(); mem.setInts(pixels, 0, ofs, width); } } |
mem.setInts(pixels, 0, ofs, width); | if (modified) { mem.setInts(pixels, 0, ofs, width); } | protected void doDrawAlphaRaster(Raster raster, int srcX, int srcY, int dstX, int dstY, int width, int height, int color) { final byte[] buf = new byte[width]; final int[] pixels = new int[width]; final int c1 = color & 0xFF; final int c2 = (color >> 8) & 0xFF; final int c3 = (color >> 16) & 0xFF; for (int row = 0; row < height; row++) { final int ofs = offset + ((dstY + row) * bytesPerLine) + (dstX << 2); raster.getDataElements(srcX, srcY + row, width, 1, buf); mem.getInts(ofs, pixels, 0, width);// System.out.print(" w" + width + " "); for (int i = 0; i < width; i++) { final int dst = pixels[i]; final int alpha = (buf[i] & 0xFF);// System.out.print(NumberUtils.hex(alpha, 2)); final int d1 = (dst & 0xFF); final int d2 = (dst >> 8) & 0xFF; final int d3 = (dst >> 16) & 0xFF; final int r1 = ((alpha * (c1 - d1)) >> 8) + d1; final int r2 = ((alpha * (c2 - d2)) >> 8) + d2; final int r3 = ((alpha * (c3 - d3)) >> 8) + d3; pixels[i] = (r1 & 0xFF) + ((r2 & 0xFF) << 8) + ((r3 & 0xFF) << 16); // pixels[i] = (alpha & 0xFF) + ((alpha & 0xFF) << 8) + ((alpha & 0xFF) << 16);// pixels[i] = (alpha > 128) ? color : dst; }// System.out.println(); mem.setInts(pixels, 0, ofs, width); } } |
public Object getDataElements(int x, int y, int w, int h, Object outData) | public Object getDataElements(int x, int y, Object outData) | public Object getDataElements(int x, int y, int w, int h, Object outData) { return sampleModel.getDataElements(x-sampleModelTranslateX, y-sampleModelTranslateY, w, h, outData, dataBuffer); } |
w, h, outData, dataBuffer); } | outData, dataBuffer); } | public Object getDataElements(int x, int y, int w, int h, Object outData) { return sampleModel.getDataElements(x-sampleModelTranslateX, y-sampleModelTranslateY, w, h, outData, dataBuffer); } |
public abstract void setInt(int memPtr, int value, int count); | public abstract void setInt(int memPtr, int value); | public abstract void setInt(int memPtr, int value, int count); |
public JCheckBoxMenuItem() { } | public JCheckBoxMenuItem() { this(null, null); } | public JCheckBoxMenuItem() { // TODO } // JCheckBoxMenuItem() |
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJCheckBoxMenuItem(this); } return accessibleContext; } | public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJCheckBoxMenuItem(this); return accessibleContext; } | public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJCheckBoxMenuItem(this); } // if return accessibleContext; } // getAccessibleContext() |
public Object[] getSelectedObjects() { return null; } | public Object[] getSelectedObjects() { return selectedObjects; } | public Object[] getSelectedObjects() { return null; // TODO } // getSelectedObjects() |
public boolean getState() { return false; } | public boolean getState() { return state; } | public boolean getState() { return false; // TODO } // getState() |
protected String paramString() { return null; } | protected String paramString() { return "JCheckBoxMenuItem"; } | protected String paramString() { return null; // TODO } // paramString() |
public synchronized void setState(boolean state) { } | public synchronized void setState(boolean state) { this.state = state; } | public synchronized void setState(boolean state) { // TODO } // setState() |
public Object[] getSelectedObjects() { return null; } | public Object[] getSelectedObjects() { if (isSelected()) { Object[] objs = new Object[1]; objs[0] = getText(); return objs; } else { return null; } } | public Object[] getSelectedObjects() { //Returns an array (length 1) containing the label or null if the button is not selected. return null; } |
String classname = p[i].getProperty ("CertificateFactory." + type); if (classname != null) return getInstance (classname, type, p[i]); | try { return getInstance(type, p[i]); } catch (CertificateException ignored) { } | public static final CertificateFactory getInstance(String type) throws CertificateException { Provider[] p = Security.getProviders (); for (int i = 0; i < p.length; i++) { String classname = p[i].getProperty ("CertificateFactory." + type); if (classname != null) return getInstance (classname, type, p[i]); } throw new CertificateException(type); } |
SwingUtilities.invokeLater(new Runnable() { public void run() { drainEvents(); } }); | SwingUtilities.invokeLater(drainer); | private void queueEvent() { synchronized (queueLock) { queue++; if (queue == 1) SwingUtilities.invokeLater(new Runnable() { public void run() { drainEvents(); } }); } } |
public XMLReader getXMLReader() { return reader; } | public XMLReader getXMLReader() { return xmlReader; } | public XMLReader getXMLReader() { return reader; } // getXMLReader() |
public void setInputSource(InputSource source) { this.inputSource = source; } | public void setInputSource(InputSource inputSource) { this.inputSource = inputSource; } | public void setInputSource(InputSource source) { this.inputSource = source; } // setInputSource() |
public void setSystemId(String systemID) { if (inputSource != null) { inputSource.setSystemId(systemID); | public void setSystemId(String systemId) { if (inputSource != null) { inputSource.setSystemId(systemId); } | public void setSystemId(String systemID) { if (inputSource != null) { inputSource.setSystemId(systemID); } } // setSystemId() |
} | public void setSystemId(String systemID) { if (inputSource != null) { inputSource.setSystemId(systemID); } } // setSystemId() |
|
public void setXMLReader(XMLReader reader) { this.reader = reader; } | public void setXMLReader(XMLReader reader) { xmlReader = reader; } | public void setXMLReader(XMLReader reader) { this.reader = reader; } // setXMLReader() |
public static InputSource sourceToInputSource (Source in) | public static InputSource sourceToInputSource(Source source) | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; | InputSource in = null; if (source instanceof SAXSource) { in = ((SAXSource) source).getInputSource(); | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; | else if (source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; InputStream inputStream = streamSource.getInputStream(); if (inputStream != null) { in = new InputSource(inputStream); | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); | else { Reader reader = streamSource.getReader(); if (reader != null) { in = new InputSource(reader); | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
return ok ? retval : null; | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
|
String publicId = streamSource.getPublicId(); if (publicId != null && in != null) { in.setPublicId(publicId); } } String systemId = source.getSystemId(); if (systemId != null) { if (in == null) { in = new InputSource(systemId); } else { in.setSystemId(systemId); } } return in; } | public static InputSource sourceToInputSource (Source in) { InputSource retval; boolean ok = false; if (in instanceof SAXSource) { return ((SAXSource) in).inputSource; } if (in.getSystemId () != null) { retval = new InputSource (in.getSystemId ()); ok = true; } else retval = new InputSource (); if (in instanceof StreamSource) { StreamSource ss = (StreamSource) in; if (ss.getReader () != null) { retval.setCharacterStream (ss.getReader ()); ok = true; } else if (ss.getInputStream () != null) { retval.setByteStream (ss.getInputStream ()); ok = true; } if (ss.getPublicId () != null) retval.setPublicId (ss.getPublicId ()); } return ok ? retval : null; } |
|
public StructMember(String a_name, TypeCode a_type, IDLType a_type_def) | public StructMember() | public StructMember(String a_name, TypeCode a_type, IDLType a_type_def) { name = a_name; type = a_type; type_def = a_type_def; } |
name = a_name; type = a_type; type_def = a_type_def; | public StructMember(String a_name, TypeCode a_type, IDLType a_type_def) { name = a_name; type = a_type; type_def = a_type_def; } |
|
public AlreadyBoundException(String s) | public AlreadyBoundException() | public AlreadyBoundException(String s) { super(s); } |
super(s); | public AlreadyBoundException(String s) { super(s); } |
|
public final void deviceStarted(Device device) { | public final void deviceStarted(final Device device) { | public final void deviceStarted(Device device) { if (device.implementsAPI(FSBlockDeviceAPI.class)) { // add it to the queue of devices to be mounted only if the action // is not already pending devicesAdded++; devicesWaitingToBeMounted.add(device); //log.info("Started " + device.getId()); } } |
devicesAdded++; devicesWaitingToBeMounted.add(device); | WorkUtils.add(new Work("Mounting " + device.getId()) { public void execute() { asyncDeviceStarted(device); } }); | public final void deviceStarted(Device device) { if (device.implementsAPI(FSBlockDeviceAPI.class)) { // add it to the queue of devices to be mounted only if the action // is not already pending devicesAdded++; devicesWaitingToBeMounted.add(device); //log.info("Started " + device.getId()); } } |
asynchronousMounterThread = new QueueProcessorThread( "Asynchronous-FS-Mounter", devicesWaitingToBeMounted, this); asynchronousMounterThread.start(); | public void start() throws PluginException { try { devMan = (DeviceManager) InitialNaming.lookup(DeviceManager.NAME); devMan.addListener(this); fileSystemService = (FileSystemService) InitialNaming .lookup(FileSystemService.NAME); asynchronousMounterThread = new QueueProcessorThread( "Asynchronous-FS-Mounter", devicesWaitingToBeMounted, this); asynchronousMounterThread.start(); } catch (NameNotFoundException ex) { throw new PluginException("Cannot find DeviceManager", ex); } } |
|
asynchronousMounterThread.stopProcessor(); asynchronousMounterThread = null; | public void stop() { devMan.removeListener(this); asynchronousMounterThread.stopProcessor(); asynchronousMounterThread = null; } |
|
write8(REX_W_PREFIX); | public void writeCDQE() throws InvalidOpcodeException { if (!code64) { throw new InvalidOpcodeException(); } write8(0x98); } |
|
public ColorUIResource(Color c) | public ColorUIResource(int r, int g, int b) | public ColorUIResource(Color c) { super(c.getRGB()); } |
super(c.getRGB()); | super(r, g, b); | public ColorUIResource(Color c) { super(c.getRGB()); } |
public synchronized <S> S[] toArray(S[] a) | public synchronized Object[] toArray() | public synchronized <S> S[] toArray(S[] a) { if (a.length < elementCount) a = (S[]) Array.newInstance(a.getClass().getComponentType(), elementCount); else if (a.length > elementCount) a[elementCount] = null; System.arraycopy(elementData, 0, a, 0, elementCount); return a; } |
if (a.length < elementCount) a = (S[]) Array.newInstance(a.getClass().getComponentType(), elementCount); else if (a.length > elementCount) a[elementCount] = null; System.arraycopy(elementData, 0, a, 0, elementCount); return a; | Object[] newArray = new Object[elementCount]; copyInto(newArray); return newArray; | public synchronized <S> S[] toArray(S[] a) { if (a.length < elementCount) a = (S[]) Array.newInstance(a.getClass().getComponentType(), elementCount); else if (a.length > elementCount) a[elementCount] = null; System.arraycopy(elementData, 0, a, 0, elementCount); return a; } |
public ObjID(int num) { objNum = (long)num; space = new UID((short)0); | public ObjID() { synchronized (lock) { objNum = next++; } space = new UID(); | public ObjID(int num) { objNum = (long)num; space = new UID((short)0);} |
public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) throws RemoteException { super(id); manager = UnicastConnectionManager.getInstance(port, ssf); | UnicastServerRef() { | public UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf) throws RemoteException { super(id); manager = UnicastConnectionManager.getInstance(port, ssf);} |
protected UnicastRemoteObject(RemoteRef ref) throws RemoteException { super((UnicastServerRef)ref); exportObject(this); | protected UnicastRemoteObject() throws RemoteException { this(0); | protected UnicastRemoteObject(RemoteRef ref) throws RemoteException { super((UnicastServerRef)ref); exportObject(this);} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.