nokogiri-backport 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1682 -0
- data/LICENSE.md +9 -0
- data/README.md +272 -0
- data/bin/nokogiri +118 -0
- data/dependencies.yml +74 -0
- data/ext/java/nokogiri/EncodingHandler.java +124 -0
- data/ext/java/nokogiri/HtmlDocument.java +178 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +148 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +79 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +282 -0
- data/ext/java/nokogiri/HtmlSaxPushParser.java +222 -0
- data/ext/java/nokogiri/NokogiriService.java +597 -0
- data/ext/java/nokogiri/XmlAttr.java +162 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +129 -0
- data/ext/java/nokogiri/XmlCdata.java +82 -0
- data/ext/java/nokogiri/XmlComment.java +97 -0
- data/ext/java/nokogiri/XmlDocument.java +633 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +185 -0
- data/ext/java/nokogiri/XmlDtd.java +481 -0
- data/ext/java/nokogiri/XmlElement.java +68 -0
- data/ext/java/nokogiri/XmlElementContent.java +382 -0
- data/ext/java/nokogiri/XmlElementDecl.java +147 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +157 -0
- data/ext/java/nokogiri/XmlEntityReference.java +101 -0
- data/ext/java/nokogiri/XmlNamespace.java +199 -0
- data/ext/java/nokogiri/XmlNode.java +1684 -0
- data/ext/java/nokogiri/XmlNodeSet.java +434 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +100 -0
- data/ext/java/nokogiri/XmlReader.java +531 -0
- data/ext/java/nokogiri/XmlRelaxng.java +151 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +374 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +286 -0
- data/ext/java/nokogiri/XmlSchema.java +388 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +138 -0
- data/ext/java/nokogiri/XmlText.java +110 -0
- data/ext/java/nokogiri/XmlXpathContext.java +301 -0
- data/ext/java/nokogiri/XsltStylesheet.java +347 -0
- data/ext/java/nokogiri/internals/ClosedStreamException.java +10 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +252 -0
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +151 -0
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +116 -0
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +69 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +327 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +734 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +217 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +127 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +100 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +78 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +180 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +72 -0
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +60 -0
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +87 -0
- data/ext/java/nokogiri/internals/ParserContext.java +259 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +488 -0
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +778 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +73 -0
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +168 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +42 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +274 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +65 -0
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +367 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
- data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +166 -0
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1745 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +685 -0
- data/ext/nokogiri/depend +477 -0
- data/ext/nokogiri/extconf.rb +836 -0
- data/ext/nokogiri/html_document.c +171 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/nokogiri.c +135 -0
- data/ext/nokogiri/nokogiri.h +130 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +62 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +69 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +622 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +63 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +111 -0
- data/ext/nokogiri/xml_namespace.h +14 -0
- data/ext/nokogiri/xml_node.c +1773 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +486 -0
- data/ext/nokogiri/xml_node_set.h +12 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +657 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +179 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +305 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +159 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +276 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +64 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +374 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +263 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -0
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri/css/node.rb +53 -0
- data/lib/nokogiri/css/parser.rb +751 -0
- data/lib/nokogiri/css/parser.y +272 -0
- data/lib/nokogiri/css/parser_extras.rb +94 -0
- data/lib/nokogiri/css/syntax_error.rb +8 -0
- data/lib/nokogiri/css/tokenizer.rb +154 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +260 -0
- data/lib/nokogiri/css.rb +28 -0
- data/lib/nokogiri/decorators/slop.rb +43 -0
- data/lib/nokogiri/html/builder.rb +36 -0
- data/lib/nokogiri/html/document.rb +322 -0
- data/lib/nokogiri/html/document_fragment.rb +50 -0
- data/lib/nokogiri/html/element_description.rb +24 -0
- data/lib/nokogiri/html/element_description_defaults.rb +672 -0
- data/lib/nokogiri/html/entity_lookup.rb +14 -0
- data/lib/nokogiri/html/sax/parser.rb +63 -0
- data/lib/nokogiri/html/sax/parser_context.rb +17 -0
- data/lib/nokogiri/html/sax/push_parser.rb +37 -0
- data/lib/nokogiri/html.rb +38 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml/attr.rb +15 -0
- data/lib/nokogiri/xml/attribute_decl.rb +19 -0
- data/lib/nokogiri/xml/builder.rb +447 -0
- data/lib/nokogiri/xml/cdata.rb +12 -0
- data/lib/nokogiri/xml/character_data.rb +8 -0
- data/lib/nokogiri/xml/document.rb +290 -0
- data/lib/nokogiri/xml/document_fragment.rb +159 -0
- data/lib/nokogiri/xml/dtd.rb +33 -0
- data/lib/nokogiri/xml/element_content.rb +37 -0
- data/lib/nokogiri/xml/element_decl.rb +14 -0
- data/lib/nokogiri/xml/entity_decl.rb +20 -0
- data/lib/nokogiri/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +14 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -0
- data/lib/nokogiri/xml/node.rb +1240 -0
- data/lib/nokogiri/xml/node_set.rb +372 -0
- data/lib/nokogiri/xml/notation.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +127 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/pp.rb +3 -0
- data/lib/nokogiri/xml/processing_instruction.rb +9 -0
- data/lib/nokogiri/xml/reader.rb +116 -0
- data/lib/nokogiri/xml/relax_ng.rb +37 -0
- data/lib/nokogiri/xml/sax/document.rb +172 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/sax.rb +5 -0
- data/lib/nokogiri/xml/schema.rb +72 -0
- data/lib/nokogiri/xml/searchable.rb +239 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -0
- data/lib/nokogiri/xml/text.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath.rb +11 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri.rb +144 -0
- data/lib/serializer.jar +0 -0
- data/lib/xalan.jar +0 -0
- data/lib/xercesImpl.jar +0 -0
- data/lib/xml-apis.jar +0 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +531 -0
@@ -0,0 +1,597 @@
|
|
1
|
+
/**
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008 - 2011:
|
5
|
+
*
|
6
|
+
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
+
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
+
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
+
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
+
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
+
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
* a copy of this software and associated documentation files (the
|
15
|
+
* 'Software'), to deal in the Software without restriction, including
|
16
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
* the following conditions:
|
20
|
+
*
|
21
|
+
* The above copyright notice and this permission notice shall be
|
22
|
+
* included in all copies or substantial portions of the Software.
|
23
|
+
*
|
24
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
*/
|
32
|
+
|
33
|
+
package nokogiri;
|
34
|
+
|
35
|
+
import java.util.Collections;
|
36
|
+
import java.util.HashMap;
|
37
|
+
import java.util.Map;
|
38
|
+
|
39
|
+
import org.jruby.Ruby;
|
40
|
+
import org.jruby.RubyArray;
|
41
|
+
import org.jruby.RubyClass;
|
42
|
+
import org.jruby.RubyFixnum;
|
43
|
+
import org.jruby.RubyModule;
|
44
|
+
import org.jruby.runtime.ObjectAllocator;
|
45
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
46
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Class to provide Nokogiri. This class is used to make "require 'nokogiri'" work
|
50
|
+
* in JRuby. Also, this class holds a Ruby type cache and allocators of Ruby types.
|
51
|
+
*
|
52
|
+
* @author headius
|
53
|
+
* @author Yoko Harada <yokolet@gmail.com>
|
54
|
+
*/
|
55
|
+
public class NokogiriService implements BasicLibraryService {
|
56
|
+
public boolean basicLoad(Ruby ruby) {
|
57
|
+
init(ruby);
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
|
61
|
+
public static Map<String, RubyClass> getNokogiriClassCache(Ruby ruby) {
|
62
|
+
return (Map<String, RubyClass>) ruby.getModule("Nokogiri").getInternalVariable("cache");
|
63
|
+
}
|
64
|
+
|
65
|
+
private static Map<String, RubyClass> populateNokogiriClassCahce(Ruby ruby) {
|
66
|
+
Map<String, RubyClass> nokogiriClassCache = new HashMap<String, RubyClass>();
|
67
|
+
nokogiriClassCache.put("Nokogiri::EncodingHandler", (RubyClass)ruby.getClassFromPath("Nokogiri::EncodingHandler"));
|
68
|
+
nokogiriClassCache.put("Nokogiri::HTML::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::HTML::Document"));
|
69
|
+
nokogiriClassCache.put("Nokogiri::HTML::ElementDescription", (RubyClass)ruby.getClassFromPath("Nokogiri::HTML::ElementDescription"));
|
70
|
+
nokogiriClassCache.put("Nokogiri::XML::Attr", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Attr"));
|
71
|
+
nokogiriClassCache.put("Nokogiri::XML::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Document"));
|
72
|
+
nokogiriClassCache.put("Nokogiri::XML::DocumentFragment", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::DocumentFragment"));
|
73
|
+
nokogiriClassCache.put("Nokogiri::XML::DTD", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::DTD"));
|
74
|
+
nokogiriClassCache.put("Nokogiri::XML::Text", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Text"));
|
75
|
+
nokogiriClassCache.put("Nokogiri::XML::Comment", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Comment"));
|
76
|
+
nokogiriClassCache.put("Nokogiri::XML::Element", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Element"));
|
77
|
+
nokogiriClassCache.put("Nokogiri::XML::ElementContent", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::ElementContent"));
|
78
|
+
nokogiriClassCache.put("Nokogiri::XML::ElementDecl", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::ElementDecl"));
|
79
|
+
nokogiriClassCache.put("Nokogiri::XML::EntityDecl", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::EntityDecl"));
|
80
|
+
nokogiriClassCache.put("Nokogiri::XML::EntityReference", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::EntityReference"));
|
81
|
+
nokogiriClassCache.put("Nokogiri::XML::ProcessingInstruction", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::ProcessingInstruction"));
|
82
|
+
nokogiriClassCache.put("Nokogiri::XML::CDATA", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::CDATA"));
|
83
|
+
nokogiriClassCache.put("Nokogiri::XML::Node", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Node"));
|
84
|
+
nokogiriClassCache.put("Nokogiri::XML::NodeSet", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::NodeSet"));
|
85
|
+
nokogiriClassCache.put("Nokogiri::XML::Namespace", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Namespace"));
|
86
|
+
nokogiriClassCache.put("Nokogiri::XML::SyntaxError", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::SyntaxError"));
|
87
|
+
nokogiriClassCache.put("Nokogiri::XML::Reader", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Reader"));
|
88
|
+
nokogiriClassCache.put("Nokogiri::XML::RelaxNG", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::RelaxNG"));
|
89
|
+
nokogiriClassCache.put("Nokogiri::XML::Schema", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Schema"));
|
90
|
+
nokogiriClassCache.put("Nokogiri::XML::XPathContext", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::XPathContext"));
|
91
|
+
nokogiriClassCache.put("Nokogiri::XML::AttributeDecl", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::AttributeDecl"));
|
92
|
+
nokogiriClassCache.put("Nokogiri::XML::SAX::ParserContext", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::SAX::ParserContext"));
|
93
|
+
return Collections.unmodifiableMap(nokogiriClassCache);
|
94
|
+
}
|
95
|
+
|
96
|
+
private void init(Ruby ruby) {
|
97
|
+
RubyModule nokogiri = ruby.defineModule("Nokogiri");
|
98
|
+
RubyModule xmlModule = nokogiri.defineModuleUnder("XML");
|
99
|
+
RubyModule xmlSaxModule = xmlModule.defineModuleUnder("SAX");
|
100
|
+
RubyModule htmlModule = nokogiri.defineModuleUnder("HTML");
|
101
|
+
RubyModule htmlSaxModule = htmlModule.defineModuleUnder("SAX");
|
102
|
+
RubyModule xsltModule = nokogiri.defineModuleUnder("XSLT");
|
103
|
+
|
104
|
+
createJavaLibraryVersionConstants(ruby, nokogiri);
|
105
|
+
createNokogiriModule(ruby, nokogiri);
|
106
|
+
createSyntaxErrors(ruby, nokogiri, xmlModule);
|
107
|
+
RubyClass xmlNode = createXmlModule(ruby, xmlModule);
|
108
|
+
createHtmlModule(ruby, htmlModule);
|
109
|
+
createDocuments(ruby, xmlModule, htmlModule, xmlNode);
|
110
|
+
createSaxModule(ruby, xmlSaxModule, htmlSaxModule);
|
111
|
+
createXsltModule(ruby, xsltModule);
|
112
|
+
nokogiri.setInternalVariable("cache", populateNokogiriClassCahce(ruby));
|
113
|
+
}
|
114
|
+
|
115
|
+
private void createJavaLibraryVersionConstants(Ruby ruby, RubyModule nokogiri) {
|
116
|
+
nokogiri.defineConstant("XERCES_VERSION", ruby.newString(org.apache.xerces.impl.Version.getVersion()));
|
117
|
+
nokogiri.defineConstant("NEKO_VERSION", ruby.newString(org.cyberneko.html.Version.getVersion()));
|
118
|
+
}
|
119
|
+
|
120
|
+
private void createNokogiriModule(Ruby ruby, RubyModule nokogiri) {
|
121
|
+
RubyClass encHandler = nokogiri.defineClassUnder("EncodingHandler", ruby.getObject(), ENCODING_HANDLER_ALLOCATOR);
|
122
|
+
encHandler.defineAnnotatedMethods(EncodingHandler.class);
|
123
|
+
}
|
124
|
+
|
125
|
+
private void createSyntaxErrors(Ruby ruby, RubyModule nokogiri, RubyModule xmlModule) {
|
126
|
+
RubyClass syntaxError = nokogiri.defineClassUnder("SyntaxError", ruby.getStandardError(), ruby.getStandardError().getAllocator());
|
127
|
+
RubyClass xmlSyntaxError = xmlModule.defineClassUnder("SyntaxError", syntaxError, XML_SYNTAXERROR_ALLOCATOR);
|
128
|
+
xmlSyntaxError.defineAnnotatedMethods(XmlSyntaxError.class);
|
129
|
+
}
|
130
|
+
|
131
|
+
private RubyClass createXmlModule(Ruby ruby, RubyModule xmlModule) {
|
132
|
+
RubyClass node = xmlModule.defineClassUnder("Node", ruby.getObject(), XML_NODE_ALLOCATOR);
|
133
|
+
node.defineAnnotatedMethods(XmlNode.class);
|
134
|
+
|
135
|
+
RubyClass attr = xmlModule.defineClassUnder("Attr", node, XML_ATTR_ALLOCATOR);
|
136
|
+
attr.defineAnnotatedMethods(XmlAttr.class);
|
137
|
+
|
138
|
+
RubyClass attrDecl = xmlModule.defineClassUnder("AttributeDecl", node, XML_ATTRIBUTE_DECL_ALLOCATOR);
|
139
|
+
attrDecl.defineAnnotatedMethods(XmlAttributeDecl.class);
|
140
|
+
|
141
|
+
RubyClass characterData = xmlModule.defineClassUnder("CharacterData", node, null);
|
142
|
+
|
143
|
+
RubyClass comment = xmlModule.defineClassUnder("Comment", characterData, XML_COMMENT_ALLOCATOR);
|
144
|
+
comment.defineAnnotatedMethods(XmlComment.class);
|
145
|
+
|
146
|
+
RubyClass text = xmlModule.defineClassUnder("Text", characterData, XML_TEXT_ALLOCATOR);
|
147
|
+
text.defineAnnotatedMethods(XmlText.class);
|
148
|
+
|
149
|
+
RubyModule cdata = xmlModule.defineClassUnder("CDATA", text, XML_CDATA_ALLOCATOR);
|
150
|
+
cdata.defineAnnotatedMethods(XmlCdata.class);
|
151
|
+
|
152
|
+
RubyClass dtd = xmlModule.defineClassUnder("DTD", node, XML_DTD_ALLOCATOR);
|
153
|
+
dtd.defineAnnotatedMethods(XmlDtd.class);
|
154
|
+
|
155
|
+
RubyClass documentFragment = xmlModule.defineClassUnder("DocumentFragment", node, XML_DOCUMENT_FRAGMENT_ALLOCATOR);
|
156
|
+
documentFragment.defineAnnotatedMethods(XmlDocumentFragment.class);
|
157
|
+
|
158
|
+
RubyClass element = xmlModule.defineClassUnder("Element", node, XML_ELEMENT_ALLOCATOR);
|
159
|
+
element.defineAnnotatedMethods(XmlElement.class);
|
160
|
+
|
161
|
+
RubyClass elementContent = xmlModule.defineClassUnder("ElementContent", ruby.getObject(), XML_ELEMENT_CONTENT_ALLOCATOR);
|
162
|
+
elementContent.defineAnnotatedMethods(XmlElementContent.class);
|
163
|
+
|
164
|
+
RubyClass elementDecl = xmlModule.defineClassUnder("ElementDecl", node, XML_ELEMENT_DECL_ALLOCATOR);
|
165
|
+
elementDecl.defineAnnotatedMethods(XmlElementDecl.class);
|
166
|
+
|
167
|
+
RubyClass entityDecl = xmlModule.defineClassUnder("EntityDecl", node, XML_ENTITY_DECL_ALLOCATOR);
|
168
|
+
entityDecl.defineAnnotatedMethods(XmlEntityDecl.class);
|
169
|
+
|
170
|
+
entityDecl.defineConstant("INTERNAL_GENERAL", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_GENERAL));
|
171
|
+
entityDecl.defineConstant("EXTERNAL_GENERAL_PARSED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_GENERAL_PARSED));
|
172
|
+
entityDecl.defineConstant("EXTERNAL_GENERAL_UNPARSED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_GENERAL_UNPARSED));
|
173
|
+
entityDecl.defineConstant("INTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PARAMETER));
|
174
|
+
entityDecl.defineConstant("EXTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_PARAMETER));
|
175
|
+
entityDecl.defineConstant("INTERNAL_PREDEFINED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PREDEFINED));
|
176
|
+
|
177
|
+
RubyClass entref = xmlModule.defineClassUnder("EntityReference", node, XML_ENTITY_REFERENCE_ALLOCATOR);
|
178
|
+
entref.defineAnnotatedMethods(XmlEntityReference.class);
|
179
|
+
|
180
|
+
RubyClass namespace = xmlModule.defineClassUnder("Namespace", ruby.getObject(), XML_NAMESPACE_ALLOCATOR);
|
181
|
+
namespace.defineAnnotatedMethods(XmlNamespace.class);
|
182
|
+
|
183
|
+
RubyClass nodeSet = xmlModule.defineClassUnder("NodeSet", ruby.getObject(), XML_NODESET_ALLOCATOR);
|
184
|
+
nodeSet.defineAnnotatedMethods(XmlNodeSet.class);
|
185
|
+
|
186
|
+
RubyClass pi = xmlModule.defineClassUnder("ProcessingInstruction", node, XML_PROCESSING_INSTRUCTION_ALLOCATOR);
|
187
|
+
pi.defineAnnotatedMethods(XmlProcessingInstruction.class);
|
188
|
+
|
189
|
+
RubyClass reader = xmlModule.defineClassUnder("Reader", ruby.getObject(), XML_READER_ALLOCATOR);
|
190
|
+
reader.defineAnnotatedMethods(XmlReader.class);
|
191
|
+
|
192
|
+
RubyClass schema = xmlModule.defineClassUnder("Schema", ruby.getObject(), XML_SCHEMA_ALLOCATOR);
|
193
|
+
schema.defineAnnotatedMethods(XmlSchema.class);
|
194
|
+
|
195
|
+
RubyClass relaxng = xmlModule.defineClassUnder("RelaxNG", schema, XML_RELAXNG_ALLOCATOR);
|
196
|
+
relaxng.defineAnnotatedMethods(XmlRelaxng.class);
|
197
|
+
|
198
|
+
RubyClass xpathContext = xmlModule.defineClassUnder("XPathContext", ruby.getObject(), XML_XPATHCONTEXT_ALLOCATOR);
|
199
|
+
xpathContext.defineAnnotatedMethods(XmlXpathContext.class);
|
200
|
+
|
201
|
+
return node;
|
202
|
+
}
|
203
|
+
|
204
|
+
private void createHtmlModule(Ruby ruby, RubyModule htmlModule) {
|
205
|
+
RubyClass htmlElemDesc = htmlModule.defineClassUnder("ElementDescription", ruby.getObject(), HTML_ELEMENT_DESCRIPTION_ALLOCATOR);
|
206
|
+
htmlElemDesc.defineAnnotatedMethods(HtmlElementDescription.class);
|
207
|
+
|
208
|
+
RubyClass htmlEntityLookup = htmlModule.defineClassUnder("EntityLookup", ruby.getObject(), HTML_ENTITY_LOOKUP_ALLOCATOR);
|
209
|
+
htmlEntityLookup.defineAnnotatedMethods(HtmlEntityLookup.class);
|
210
|
+
}
|
211
|
+
|
212
|
+
private void createDocuments(Ruby ruby, RubyModule xmlModule, RubyModule htmlModule, RubyClass node) {
|
213
|
+
RubyClass xmlDocument = xmlModule.defineClassUnder("Document", node, XML_DOCUMENT_ALLOCATOR);
|
214
|
+
xmlDocument.defineAnnotatedMethods(XmlDocument.class);
|
215
|
+
|
216
|
+
//RubyModule htmlDoc = html.defineOrGetClassUnder("Document", document);
|
217
|
+
RubyModule htmlDocument = htmlModule.defineClassUnder("Document", xmlDocument, HTML_DOCUMENT_ALLOCATOR);
|
218
|
+
htmlDocument.defineAnnotatedMethods(HtmlDocument.class);
|
219
|
+
}
|
220
|
+
|
221
|
+
private void createSaxModule(Ruby ruby, RubyModule xmlSaxModule, RubyModule htmlSaxModule) {
|
222
|
+
RubyClass xmlSaxParserContext = xmlSaxModule.defineClassUnder("ParserContext", ruby.getObject(), XML_SAXPARSER_CONTEXT_ALLOCATOR);
|
223
|
+
xmlSaxParserContext.defineAnnotatedMethods(XmlSaxParserContext.class);
|
224
|
+
|
225
|
+
RubyClass xmlSaxPushParser = xmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), XML_SAXPUSHPARSER_ALLOCATOR);
|
226
|
+
xmlSaxPushParser.defineAnnotatedMethods(XmlSaxPushParser.class);
|
227
|
+
|
228
|
+
RubyClass htmlSaxPushParser = htmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), HTML_SAXPUSHPARSER_ALLOCATOR);
|
229
|
+
htmlSaxPushParser.defineAnnotatedMethods(HtmlSaxPushParser.class);
|
230
|
+
|
231
|
+
RubyClass htmlSaxParserContext = htmlSaxModule.defineClassUnder("ParserContext", xmlSaxParserContext, HTML_SAXPARSER_CONTEXT_ALLOCATOR);
|
232
|
+
htmlSaxParserContext.defineAnnotatedMethods(HtmlSaxParserContext.class);
|
233
|
+
}
|
234
|
+
|
235
|
+
private void createXsltModule(Ruby ruby, RubyModule xsltModule) {
|
236
|
+
RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
|
237
|
+
stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
|
238
|
+
xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
|
239
|
+
}
|
240
|
+
|
241
|
+
private static ObjectAllocator ENCODING_HANDLER_ALLOCATOR = new ObjectAllocator() {
|
242
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
243
|
+
return new EncodingHandler(runtime, klazz, "");
|
244
|
+
}
|
245
|
+
};
|
246
|
+
|
247
|
+
public static final ObjectAllocator HTML_DOCUMENT_ALLOCATOR = new ObjectAllocator() {
|
248
|
+
private HtmlDocument htmlDocument = null;
|
249
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
250
|
+
if (htmlDocument == null) htmlDocument = new HtmlDocument(runtime, klazz);
|
251
|
+
try {
|
252
|
+
HtmlDocument clone = (HtmlDocument) htmlDocument.clone();
|
253
|
+
clone.setMetaClass(klazz);
|
254
|
+
return clone;
|
255
|
+
} catch (CloneNotSupportedException e) {
|
256
|
+
return new HtmlDocument(runtime, klazz);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
};
|
260
|
+
|
261
|
+
private static final ObjectAllocator HTML_SAXPARSER_CONTEXT_ALLOCATOR = new ObjectAllocator() {
|
262
|
+
private HtmlSaxParserContext htmlSaxParserContext = null;
|
263
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
264
|
+
if (htmlSaxParserContext == null) htmlSaxParserContext = new HtmlSaxParserContext(runtime, klazz);
|
265
|
+
try {
|
266
|
+
HtmlSaxParserContext clone = (HtmlSaxParserContext) htmlSaxParserContext.clone();
|
267
|
+
clone.setMetaClass(klazz);
|
268
|
+
return clone;
|
269
|
+
} catch (CloneNotSupportedException e) {
|
270
|
+
return new HtmlSaxParserContext(runtime, klazz);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
};
|
274
|
+
|
275
|
+
private static ObjectAllocator HTML_ELEMENT_DESCRIPTION_ALLOCATOR =
|
276
|
+
new ObjectAllocator() {
|
277
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
278
|
+
return new HtmlElementDescription(runtime, klazz);
|
279
|
+
}
|
280
|
+
};
|
281
|
+
|
282
|
+
private static ObjectAllocator HTML_ENTITY_LOOKUP_ALLOCATOR =
|
283
|
+
new ObjectAllocator() {
|
284
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
285
|
+
return new HtmlEntityLookup(runtime, klazz);
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
public static final ObjectAllocator XML_ATTR_ALLOCATOR = new ObjectAllocator() {
|
290
|
+
private XmlAttr xmlAttr = null;
|
291
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
292
|
+
if (xmlAttr == null) xmlAttr = new XmlAttr(runtime, klazz);
|
293
|
+
try {
|
294
|
+
XmlAttr clone = (XmlAttr) xmlAttr.clone();
|
295
|
+
clone.setMetaClass(klazz);
|
296
|
+
return clone;
|
297
|
+
} catch (CloneNotSupportedException e) {
|
298
|
+
return new XmlAttr(runtime, klazz);
|
299
|
+
}
|
300
|
+
}
|
301
|
+
};
|
302
|
+
|
303
|
+
public static final ObjectAllocator XML_CDATA_ALLOCATOR = new ObjectAllocator() {
|
304
|
+
private XmlCdata xmlCdata = null;
|
305
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
306
|
+
if (xmlCdata == null) xmlCdata = new XmlCdata(runtime, klazz);
|
307
|
+
try {
|
308
|
+
XmlCdata clone = (XmlCdata) xmlCdata.clone();
|
309
|
+
clone.setMetaClass(klazz);
|
310
|
+
return clone;
|
311
|
+
} catch (CloneNotSupportedException e) {
|
312
|
+
return new XmlCdata(runtime, klazz);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
};
|
316
|
+
|
317
|
+
public static final ObjectAllocator XML_COMMENT_ALLOCATOR = new ObjectAllocator() {
|
318
|
+
private XmlComment xmlComment = null;
|
319
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
320
|
+
if (xmlComment == null) xmlComment = new XmlComment(runtime, klazz);
|
321
|
+
try {
|
322
|
+
XmlComment clone = (XmlComment) xmlComment.clone();
|
323
|
+
clone.setMetaClass(klazz);
|
324
|
+
return clone;
|
325
|
+
} catch (CloneNotSupportedException e) {
|
326
|
+
return new XmlComment(runtime, klazz);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
};
|
330
|
+
|
331
|
+
public static final ObjectAllocator XML_DOCUMENT_ALLOCATOR = new ObjectAllocator() {
|
332
|
+
private XmlDocument xmlDocument = null;
|
333
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
334
|
+
if (xmlDocument == null) xmlDocument = new XmlDocument(runtime, klazz);
|
335
|
+
try {
|
336
|
+
XmlDocument clone = (XmlDocument) xmlDocument.clone();
|
337
|
+
clone.setMetaClass(klazz);
|
338
|
+
return clone;
|
339
|
+
} catch (CloneNotSupportedException e) {
|
340
|
+
return new XmlDocument(runtime, klazz);
|
341
|
+
}
|
342
|
+
}
|
343
|
+
};
|
344
|
+
|
345
|
+
public static final ObjectAllocator XML_DOCUMENT_FRAGMENT_ALLOCATOR = new ObjectAllocator() {
|
346
|
+
private XmlDocumentFragment xmlDocumentFragment = null;
|
347
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
348
|
+
if (xmlDocumentFragment == null) xmlDocumentFragment = new XmlDocumentFragment(runtime, klazz);
|
349
|
+
try {
|
350
|
+
XmlDocumentFragment clone = (XmlDocumentFragment)xmlDocumentFragment.clone();
|
351
|
+
clone.setMetaClass(klazz);
|
352
|
+
return clone;
|
353
|
+
} catch (CloneNotSupportedException e) {
|
354
|
+
return new XmlDocumentFragment(runtime, klazz);
|
355
|
+
}
|
356
|
+
}
|
357
|
+
};
|
358
|
+
|
359
|
+
public static final ObjectAllocator XML_DTD_ALLOCATOR = new ObjectAllocator() {
|
360
|
+
private XmlDtd xmlDtd = null;
|
361
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
362
|
+
if (xmlDtd == null) xmlDtd = new XmlDtd(runtime, klazz);
|
363
|
+
try {
|
364
|
+
XmlDtd clone = (XmlDtd)xmlDtd.clone();
|
365
|
+
clone.setMetaClass(klazz);
|
366
|
+
return clone;
|
367
|
+
} catch (CloneNotSupportedException e) {
|
368
|
+
return new XmlDtd(runtime, klazz);
|
369
|
+
}
|
370
|
+
}
|
371
|
+
};
|
372
|
+
|
373
|
+
public static final ObjectAllocator XML_ELEMENT_ALLOCATOR = new ObjectAllocator() {
|
374
|
+
private XmlElement xmlElement = null;
|
375
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
376
|
+
if (xmlElement == null) xmlElement = new XmlElement(runtime, klazz);
|
377
|
+
try {
|
378
|
+
XmlElement clone = (XmlElement)xmlElement.clone();
|
379
|
+
clone.setMetaClass(klazz);
|
380
|
+
return clone;
|
381
|
+
} catch (CloneNotSupportedException e) {
|
382
|
+
return new XmlElement(runtime, klazz);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
};
|
386
|
+
|
387
|
+
public static ObjectAllocator XML_ELEMENT_DECL_ALLOCATOR = new ObjectAllocator() {
|
388
|
+
private XmlElementDecl xmlElementDecl = null;
|
389
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
390
|
+
if (xmlElementDecl == null) xmlElementDecl = new XmlElementDecl(runtime, klazz);
|
391
|
+
try {
|
392
|
+
XmlElementDecl clone = (XmlElementDecl)xmlElementDecl.clone();
|
393
|
+
clone.setMetaClass(klazz);
|
394
|
+
return clone;
|
395
|
+
} catch (CloneNotSupportedException e) {
|
396
|
+
return new XmlElementDecl(runtime, klazz);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
};
|
400
|
+
|
401
|
+
public static ObjectAllocator XML_ENTITY_REFERENCE_ALLOCATOR = new ObjectAllocator() {
|
402
|
+
private XmlEntityReference xmlEntityRef = null;
|
403
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
404
|
+
if (xmlEntityRef == null) xmlEntityRef = new XmlEntityReference(runtime, klazz);
|
405
|
+
try {
|
406
|
+
XmlEntityReference clone = (XmlEntityReference)xmlEntityRef.clone();
|
407
|
+
clone.setMetaClass(klazz);
|
408
|
+
return clone;
|
409
|
+
} catch (CloneNotSupportedException e) {
|
410
|
+
return new XmlEntityReference(runtime, klazz);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
|
+
public static final ObjectAllocator XML_NAMESPACE_ALLOCATOR = new ObjectAllocator() {
|
416
|
+
private XmlNamespace xmlNamespace = null;
|
417
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
418
|
+
if (xmlNamespace == null) xmlNamespace = new XmlNamespace(runtime, klazz);
|
419
|
+
try {
|
420
|
+
XmlNamespace clone = (XmlNamespace) xmlNamespace.clone();
|
421
|
+
clone.setMetaClass(klazz);
|
422
|
+
return clone;
|
423
|
+
} catch (CloneNotSupportedException e) {
|
424
|
+
return new XmlNamespace(runtime, klazz);
|
425
|
+
}
|
426
|
+
}
|
427
|
+
};
|
428
|
+
|
429
|
+
public static final ObjectAllocator XML_NODE_ALLOCATOR = new ObjectAllocator() {
|
430
|
+
private XmlNode xmlNode = null;
|
431
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
432
|
+
if (xmlNode == null) xmlNode = new XmlNode(runtime, klazz);
|
433
|
+
try {
|
434
|
+
XmlNode clone = (XmlNode) xmlNode.clone();
|
435
|
+
clone.setMetaClass(klazz);
|
436
|
+
return clone;
|
437
|
+
} catch (CloneNotSupportedException e) {
|
438
|
+
return new XmlNode(runtime, klazz);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
};
|
442
|
+
|
443
|
+
public static final ObjectAllocator XML_NODESET_ALLOCATOR = new ObjectAllocator() {
|
444
|
+
private XmlNodeSet xmlNodeSet = null;
|
445
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
446
|
+
if (xmlNodeSet == null) xmlNodeSet = new XmlNodeSet(runtime, klazz);
|
447
|
+
try {
|
448
|
+
XmlNodeSet clone = (XmlNodeSet) xmlNodeSet.clone();
|
449
|
+
clone.setMetaClass(klazz);
|
450
|
+
return clone;
|
451
|
+
} catch (CloneNotSupportedException e) {
|
452
|
+
return new XmlNodeSet(runtime, klazz);
|
453
|
+
}
|
454
|
+
}
|
455
|
+
};
|
456
|
+
|
457
|
+
public static ObjectAllocator XML_PROCESSING_INSTRUCTION_ALLOCATOR = new ObjectAllocator() {
|
458
|
+
private XmlProcessingInstruction xmlProcessingInstruction = null;
|
459
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
460
|
+
if (xmlProcessingInstruction == null) xmlProcessingInstruction = new XmlProcessingInstruction(runtime, klazz);
|
461
|
+
try {
|
462
|
+
XmlProcessingInstruction clone = (XmlProcessingInstruction)xmlProcessingInstruction.clone();
|
463
|
+
clone.setMetaClass(klazz);
|
464
|
+
return clone;
|
465
|
+
} catch (CloneNotSupportedException e) {
|
466
|
+
return new XmlProcessingInstruction(runtime, klazz);
|
467
|
+
}
|
468
|
+
}
|
469
|
+
};
|
470
|
+
|
471
|
+
public static ObjectAllocator XML_READER_ALLOCATOR = new ObjectAllocator() {
|
472
|
+
private XmlReader xmlReader = null;
|
473
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
474
|
+
if (xmlReader == null) xmlReader = new XmlReader(runtime, klazz);
|
475
|
+
try {
|
476
|
+
XmlReader clone = (XmlReader) xmlReader.clone();
|
477
|
+
clone.setMetaClass(klazz);
|
478
|
+
return clone;
|
479
|
+
} catch (CloneNotSupportedException e) {
|
480
|
+
xmlReader = new XmlReader(runtime, klazz);
|
481
|
+
return xmlReader;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
};
|
485
|
+
|
486
|
+
private static ObjectAllocator XML_ATTRIBUTE_DECL_ALLOCATOR = new ObjectAllocator() {
|
487
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
488
|
+
return new XmlAttributeDecl(runtime, klazz);
|
489
|
+
}
|
490
|
+
};
|
491
|
+
|
492
|
+
private static ObjectAllocator XML_ENTITY_DECL_ALLOCATOR = new ObjectAllocator() {
|
493
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
494
|
+
return new XmlEntityDecl(runtime, klazz);
|
495
|
+
}
|
496
|
+
};
|
497
|
+
|
498
|
+
private static ObjectAllocator XML_ELEMENT_CONTENT_ALLOCATOR = new ObjectAllocator() {
|
499
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
500
|
+
throw runtime.newNotImplementedError("not implemented");
|
501
|
+
}
|
502
|
+
};
|
503
|
+
|
504
|
+
public static final ObjectAllocator XML_RELAXNG_ALLOCATOR = new ObjectAllocator() {
|
505
|
+
private XmlRelaxng xmlRelaxng = null;
|
506
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
507
|
+
if (xmlRelaxng == null) xmlRelaxng = new XmlRelaxng(runtime, klazz);
|
508
|
+
try {
|
509
|
+
XmlRelaxng clone = (XmlRelaxng) xmlRelaxng.clone();
|
510
|
+
clone.setMetaClass(klazz);
|
511
|
+
return clone;
|
512
|
+
} catch (CloneNotSupportedException e) {
|
513
|
+
return new XmlRelaxng(runtime, klazz);
|
514
|
+
}
|
515
|
+
}
|
516
|
+
};
|
517
|
+
|
518
|
+
public static final ObjectAllocator XML_SAXPARSER_CONTEXT_ALLOCATOR = new ObjectAllocator() {
|
519
|
+
private XmlSaxParserContext xmlSaxParserContext = null;
|
520
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
521
|
+
if (xmlSaxParserContext == null) xmlSaxParserContext = new XmlSaxParserContext(runtime, klazz);
|
522
|
+
try {
|
523
|
+
XmlSaxParserContext clone = (XmlSaxParserContext) xmlSaxParserContext.clone();
|
524
|
+
clone.setMetaClass(klazz);
|
525
|
+
return clone;
|
526
|
+
} catch (CloneNotSupportedException e) {
|
527
|
+
return new XmlSaxParserContext(runtime, klazz);
|
528
|
+
}
|
529
|
+
}
|
530
|
+
};
|
531
|
+
|
532
|
+
private static final ObjectAllocator XML_SAXPUSHPARSER_ALLOCATOR = new ObjectAllocator() {
|
533
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
534
|
+
return new XmlSaxPushParser(runtime, klazz);
|
535
|
+
}
|
536
|
+
};
|
537
|
+
|
538
|
+
private static final ObjectAllocator HTML_SAXPUSHPARSER_ALLOCATOR = new ObjectAllocator() {
|
539
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
540
|
+
return new HtmlSaxPushParser(runtime, klazz);
|
541
|
+
}
|
542
|
+
};
|
543
|
+
|
544
|
+
public static final ObjectAllocator XML_SCHEMA_ALLOCATOR = new ObjectAllocator() {
|
545
|
+
private XmlSchema xmlSchema = null;
|
546
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
547
|
+
if (xmlSchema == null) xmlSchema = new XmlSchema(runtime, klazz);
|
548
|
+
try {
|
549
|
+
XmlSchema clone = (XmlSchema) xmlSchema.clone();
|
550
|
+
clone.setMetaClass(klazz);
|
551
|
+
return clone;
|
552
|
+
} catch (CloneNotSupportedException e) {
|
553
|
+
return new XmlSchema(runtime, klazz);
|
554
|
+
}
|
555
|
+
}
|
556
|
+
};
|
557
|
+
|
558
|
+
public static final ObjectAllocator XML_SYNTAXERROR_ALLOCATOR = new ObjectAllocator() {
|
559
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
560
|
+
return new XmlSyntaxError(runtime, klazz);
|
561
|
+
}
|
562
|
+
};
|
563
|
+
|
564
|
+
public static final ObjectAllocator XML_TEXT_ALLOCATOR = new ObjectAllocator() {
|
565
|
+
private XmlText xmlText = null;
|
566
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
567
|
+
if (xmlText == null) xmlText = new XmlText(runtime, klazz);
|
568
|
+
try {
|
569
|
+
XmlText clone = (XmlText) xmlText.clone();
|
570
|
+
clone.setMetaClass(klazz);
|
571
|
+
return clone;
|
572
|
+
} catch (CloneNotSupportedException e) {
|
573
|
+
return new XmlText(runtime, klazz);
|
574
|
+
}
|
575
|
+
}
|
576
|
+
};
|
577
|
+
|
578
|
+
public static final ObjectAllocator XML_XPATHCONTEXT_ALLOCATOR = new ObjectAllocator() {
|
579
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
580
|
+
return new XmlXpathContext(runtime, klazz);
|
581
|
+
}
|
582
|
+
};
|
583
|
+
|
584
|
+
public static ObjectAllocator XSLT_STYLESHEET_ALLOCATOR = new ObjectAllocator() {
|
585
|
+
private XsltStylesheet xsltStylesheet = null;
|
586
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
587
|
+
if (xsltStylesheet == null) xsltStylesheet = new XsltStylesheet(runtime, klazz);
|
588
|
+
try {
|
589
|
+
XsltStylesheet clone = (XsltStylesheet) xsltStylesheet.clone();
|
590
|
+
clone.setMetaClass(klazz);
|
591
|
+
return clone;
|
592
|
+
} catch (CloneNotSupportedException e) {
|
593
|
+
return new XmlText(runtime, klazz);
|
594
|
+
}
|
595
|
+
}
|
596
|
+
};
|
597
|
+
}
|