nokogiri 1.11.0.rc3-java → 1.11.4-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1015 -947
- data/LICENSE.md +1 -1
- data/README.md +168 -91
- data/dependencies.yml +12 -12
- data/ext/java/nokogiri/EncodingHandler.java +76 -89
- data/ext/java/nokogiri/HtmlDocument.java +135 -144
- data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
- data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
- data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
- data/ext/java/nokogiri/NokogiriService.java +595 -556
- data/ext/java/nokogiri/XmlAttr.java +118 -126
- data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
- data/ext/java/nokogiri/XmlCdata.java +35 -58
- data/ext/java/nokogiri/XmlComment.java +46 -67
- data/ext/java/nokogiri/XmlDocument.java +645 -572
- data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
- data/ext/java/nokogiri/XmlDtd.java +448 -414
- data/ext/java/nokogiri/XmlElement.java +23 -48
- data/ext/java/nokogiri/XmlElementContent.java +343 -316
- data/ext/java/nokogiri/XmlElementDecl.java +124 -125
- data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
- data/ext/java/nokogiri/XmlEntityReference.java +49 -72
- data/ext/java/nokogiri/XmlNamespace.java +175 -175
- data/ext/java/nokogiri/XmlNode.java +1843 -1622
- data/ext/java/nokogiri/XmlNodeSet.java +361 -331
- data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
- data/ext/java/nokogiri/XmlReader.java +513 -450
- data/ext/java/nokogiri/XmlRelaxng.java +89 -101
- data/ext/java/nokogiri/XmlSaxParserContext.java +328 -310
- data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
- data/ext/java/nokogiri/XmlSchema.java +335 -242
- data/ext/java/nokogiri/XmlSyntaxError.java +113 -119
- data/ext/java/nokogiri/XmlText.java +55 -76
- data/ext/java/nokogiri/XmlXpathContext.java +242 -210
- data/ext/java/nokogiri/XsltStylesheet.java +280 -269
- data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -190
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
- data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +79 -89
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +119 -78
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -54
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
- data/ext/java/nokogiri/internals/ParserContext.java +206 -211
- data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
- data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
- data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
- data/ext/nokogiri/depend +37 -358
- data/ext/nokogiri/extconf.rb +581 -374
- data/ext/nokogiri/html_document.c +78 -82
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +69 -66
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +192 -93
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +371 -320
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +52 -28
- data/ext/nokogiri/xml_sax_parser.c +118 -118
- data/ext/nokogiri/xml_sax_parser_context.c +103 -86
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +95 -47
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +206 -123
- data/ext/nokogiri/xslt_stylesheet.c +158 -161
- data/lib/nokogiri.rb +3 -7
- data/lib/nokogiri/css/parser.rb +3 -3
- data/lib/nokogiri/css/parser.y +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +70 -42
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document.rb +12 -26
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +2 -149
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +205 -0
- data/lib/nokogiri/xml/document.rb +91 -35
- data/lib/nokogiri/xml/document_fragment.rb +4 -6
- data/lib/nokogiri/xml/node.rb +89 -69
- data/lib/nokogiri/xml/parse_options.rb +6 -0
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/relax_ng.rb +6 -2
- data/lib/nokogiri/xml/schema.rb +12 -4
- data/lib/nokogiri/xml/searchable.rb +3 -1
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +86 -177
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- data/ext/nokogiri/html_sax_parser_context.h +0 -11
- data/ext/nokogiri/html_sax_push_parser.h +0 -9
- data/ext/nokogiri/nokogiri.h +0 -134
- data/ext/nokogiri/xml_attr.h +0 -9
- data/ext/nokogiri/xml_attribute_decl.h +0 -9
- data/ext/nokogiri/xml_cdata.h +0 -9
- data/ext/nokogiri/xml_comment.h +0 -9
- data/ext/nokogiri/xml_document.h +0 -23
- data/ext/nokogiri/xml_document_fragment.h +0 -10
- data/ext/nokogiri/xml_dtd.h +0 -10
- data/ext/nokogiri/xml_element_content.h +0 -10
- data/ext/nokogiri/xml_element_decl.h +0 -9
- data/ext/nokogiri/xml_encoding_handler.h +0 -8
- data/ext/nokogiri/xml_entity_decl.h +0 -10
- data/ext/nokogiri/xml_entity_reference.h +0 -9
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_io.h +0 -11
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/xml_namespace.h +0 -14
- data/ext/nokogiri/xml_node.h +0 -13
- data/ext/nokogiri/xml_node_set.h +0 -12
- data/ext/nokogiri/xml_processing_instruction.h +0 -9
- data/ext/nokogiri/xml_reader.h +0 -10
- data/ext/nokogiri/xml_relax_ng.h +0 -9
- data/ext/nokogiri/xml_sax_parser.h +0 -39
- data/ext/nokogiri/xml_sax_parser_context.h +0 -10
- data/ext/nokogiri/xml_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_schema.h +0 -9
- data/ext/nokogiri/xml_syntax_error.h +0 -13
- data/ext/nokogiri/xml_text.h +0 -9
- data/ext/nokogiri/xml_xpath_context.h +0 -10
- data/ext/nokogiri/xslt_stylesheet.h +0 -14
@@ -1,35 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2012:
|
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
1
|
package nokogiri;
|
34
2
|
|
35
3
|
import static nokogiri.XmlSaxPushParser.terminateExecution;
|
@@ -61,162 +29,187 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
61
29
|
/**
|
62
30
|
* Class for Nokogiri::HTML::SAX::PushParser
|
63
31
|
*
|
64
|
-
* @author
|
32
|
+
* @author
|
65
33
|
* @author Piotr Szmielew <p.szmielew@ava.waw.pl> - based on Nokogiri::XML::SAX::PushParser
|
66
34
|
*/
|
67
|
-
@JRubyClass(name="Nokogiri::HTML::SAX::PushParser")
|
68
|
-
public class HtmlSaxPushParser extends RubyObject
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
35
|
+
@JRubyClass(name = "Nokogiri::HTML::SAX::PushParser")
|
36
|
+
public class HtmlSaxPushParser extends RubyObject
|
37
|
+
{
|
38
|
+
ParserContext.Options options;
|
39
|
+
IRubyObject saxParser;
|
40
|
+
|
41
|
+
NokogiriBlockingQueueInputStream stream;
|
42
|
+
|
43
|
+
private ParserTask parserTask = null;
|
44
|
+
private FutureTask<HtmlSaxParserContext> futureTask = null;
|
45
|
+
private ExecutorService executor = null;
|
46
|
+
|
47
|
+
public
|
48
|
+
HtmlSaxPushParser(Ruby ruby, RubyClass rubyClass)
|
49
|
+
{
|
50
|
+
super(ruby, rubyClass);
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
public void
|
55
|
+
finalize()
|
56
|
+
{
|
57
|
+
try {
|
58
|
+
terminateImpl();
|
59
|
+
} catch (Exception e) { /* ignored */ }
|
60
|
+
}
|
61
|
+
|
62
|
+
@JRubyMethod
|
63
|
+
public IRubyObject
|
64
|
+
initialize_native(final ThreadContext context,
|
65
|
+
IRubyObject saxParser,
|
66
|
+
IRubyObject fileName,
|
67
|
+
IRubyObject encoding)
|
68
|
+
{
|
69
|
+
// NOTE: Silently skips provided encoding
|
70
|
+
options = new ParserContext.Options(0);
|
71
|
+
this.saxParser = saxParser;
|
72
|
+
return this;
|
73
|
+
}
|
74
|
+
|
75
|
+
private transient IRubyObject parse_options;
|
76
|
+
|
77
|
+
private IRubyObject
|
78
|
+
parse_options(final ThreadContext context)
|
79
|
+
{
|
80
|
+
if (parse_options == null) {
|
81
|
+
parse_options = invoke(context, context.runtime.getClassFromPath("Nokogiri::XML::ParseOptions"), "new");
|
80
82
|
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
return parse_options;
|
84
|
+
}
|
85
|
+
|
86
|
+
@JRubyMethod(name = "options")
|
87
|
+
public IRubyObject
|
88
|
+
getOptions(ThreadContext context)
|
89
|
+
{
|
90
|
+
return invoke(context, parse_options(context), "options");
|
91
|
+
}
|
92
|
+
|
93
|
+
@JRubyMethod(name = "options=")
|
94
|
+
public IRubyObject
|
95
|
+
setOptions(ThreadContext context, IRubyObject opts)
|
96
|
+
{
|
97
|
+
invoke(context, parse_options(context), "options=", opts);
|
98
|
+
options = new ParserContext.Options(opts.convertToInteger().getLongValue());
|
99
|
+
return getOptions(context);
|
100
|
+
}
|
101
|
+
|
102
|
+
@JRubyMethod
|
103
|
+
public IRubyObject
|
104
|
+
native_write(ThreadContext context, IRubyObject chunk, IRubyObject isLast)
|
105
|
+
{
|
106
|
+
try {
|
107
|
+
initialize_task(context);
|
108
|
+
} catch (IOException e) {
|
109
|
+
throw context.getRuntime().newRuntimeError(e.getMessage());
|
88
110
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
IRubyObject fileName,
|
94
|
-
IRubyObject encoding) {
|
95
|
-
// NOTE: Silently skips provided encoding
|
96
|
-
options = new ParserContext.Options(0);
|
97
|
-
this.saxParser = saxParser;
|
98
|
-
return this;
|
111
|
+
final ByteArrayInputStream data = NokogiriHelpers.stringBytesToStream(chunk);
|
112
|
+
if (data == null) {
|
113
|
+
terminateTask(context.runtime);
|
114
|
+
throw XmlSyntaxError.createHTMLSyntaxError(context.runtime).toThrowable(); // Nokogiri::HTML::SyntaxError
|
99
115
|
}
|
100
116
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
117
|
+
int errorCount0 = parserTask.getErrorCount();
|
118
|
+
|
119
|
+
if (isLast.isTrue()) {
|
120
|
+
IRubyObject document = invoke(context, this, "document");
|
121
|
+
invoke(context, document, "end_document");
|
122
|
+
terminateTask(context.runtime);
|
123
|
+
} else {
|
124
|
+
try {
|
125
|
+
Future<Void> task = stream.addChunk(data);
|
126
|
+
task.get();
|
127
|
+
} catch (ClosedStreamException ex) {
|
128
|
+
// this means the stream is closed, ignore this exception
|
129
|
+
} catch (Exception e) {
|
130
|
+
throw context.runtime.newRuntimeError(e.getMessage());
|
131
|
+
}
|
109
132
|
|
110
|
-
@JRubyMethod(name="options")
|
111
|
-
public IRubyObject getOptions(ThreadContext context) {
|
112
|
-
return invoke(context, parse_options(context), "options");
|
113
133
|
}
|
114
134
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
options = new ParserContext.Options(opts.convertToInteger().getLongValue());
|
119
|
-
return getOptions(context);
|
135
|
+
if (!options.recover && parserTask.getErrorCount() > errorCount0) {
|
136
|
+
terminateTask(context.runtime);
|
137
|
+
throw parserTask.getLastError();
|
120
138
|
}
|
121
139
|
|
122
|
-
|
123
|
-
|
124
|
-
try {
|
125
|
-
initialize_task(context);
|
126
|
-
} catch (IOException e) {
|
127
|
-
throw context.getRuntime().newRuntimeError(e.getMessage());
|
128
|
-
}
|
129
|
-
final ByteArrayInputStream data = NokogiriHelpers.stringBytesToStream(chunk);
|
130
|
-
if (data == null) {
|
131
|
-
terminateTask(context.runtime);
|
132
|
-
throw new RaiseException(XmlSyntaxError.createHTMLSyntaxError(context.runtime)); // Nokogiri::HTML::SyntaxError
|
133
|
-
}
|
134
|
-
|
135
|
-
int errorCount0 = parserTask.getErrorCount();
|
136
|
-
|
137
|
-
if (isLast.isTrue()) {
|
138
|
-
IRubyObject document = invoke(context, this, "document");
|
139
|
-
invoke(context, document, "end_document");
|
140
|
-
terminateTask(context.runtime);
|
141
|
-
} else {
|
142
|
-
try {
|
143
|
-
Future<Void> task = stream.addChunk(data);
|
144
|
-
task.get();
|
145
|
-
}
|
146
|
-
catch (ClosedStreamException ex) {
|
147
|
-
// this means the stream is closed, ignore this exception
|
148
|
-
}
|
149
|
-
catch (Exception e) {
|
150
|
-
throw context.runtime.newRuntimeError(e.getMessage());
|
151
|
-
}
|
152
|
-
|
153
|
-
}
|
140
|
+
return this;
|
141
|
+
}
|
154
142
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
143
|
+
@SuppressWarnings("unchecked")
|
144
|
+
private void
|
145
|
+
initialize_task(ThreadContext context) throws IOException
|
146
|
+
{
|
147
|
+
if (futureTask == null || stream == null) {
|
148
|
+
stream = new NokogiriBlockingQueueInputStream();
|
159
149
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
futureTask = new FutureTask<HtmlSaxParserContext>((Callable) parserTask);
|
171
|
-
executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
172
|
-
@Override
|
173
|
-
public Thread newThread(Runnable r) {
|
174
|
-
Thread t = new Thread(r);
|
175
|
-
t.setName("HtmlSaxPushParser");
|
176
|
-
t.setDaemon(true);
|
177
|
-
return t;
|
178
|
-
}
|
179
|
-
});
|
180
|
-
executor.submit(futureTask);
|
150
|
+
assert saxParser != null : "saxParser null";
|
151
|
+
parserTask = new ParserTask(context, saxParser, stream);
|
152
|
+
futureTask = new FutureTask<HtmlSaxParserContext>((Callable) parserTask);
|
153
|
+
executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
154
|
+
@Override
|
155
|
+
public Thread newThread(Runnable r) {
|
156
|
+
Thread t = new Thread(r);
|
157
|
+
t.setName("HtmlSaxPushParser");
|
158
|
+
t.setDaemon(true);
|
159
|
+
return t;
|
181
160
|
}
|
161
|
+
});
|
162
|
+
executor.submit(futureTask);
|
182
163
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
164
|
+
}
|
165
|
+
|
166
|
+
private void
|
167
|
+
terminateTask(final Ruby runtime)
|
168
|
+
{
|
169
|
+
if (executor == null) { return; }
|
170
|
+
|
171
|
+
try {
|
172
|
+
terminateImpl();
|
173
|
+
} catch (InterruptedException e) {
|
174
|
+
throw runtime.newRuntimeError(e.toString());
|
175
|
+
} catch (Exception e) {
|
176
|
+
throw runtime.newRuntimeError(e.toString());
|
196
177
|
}
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
178
|
+
}
|
179
|
+
|
180
|
+
private synchronized void
|
181
|
+
terminateImpl() throws InterruptedException, ExecutionException
|
182
|
+
{
|
183
|
+
terminateExecution(executor, stream, futureTask);
|
184
|
+
|
185
|
+
executor = null;
|
186
|
+
stream = null;
|
187
|
+
futureTask = null;
|
188
|
+
}
|
189
|
+
|
190
|
+
private static HtmlSaxParserContext
|
191
|
+
parse(final Ruby runtime, final InputStream stream)
|
192
|
+
{
|
193
|
+
RubyClass klazz = getNokogiriClass(runtime, "Nokogiri::HTML::SAX::ParserContext");
|
194
|
+
return HtmlSaxParserContext.parse_stream(runtime, klazz, stream);
|
195
|
+
}
|
196
|
+
|
197
|
+
static class ParserTask extends XmlSaxPushParser.ParserTask /* <HtmlSaxPushParser> */
|
198
|
+
{
|
199
|
+
|
200
|
+
private
|
201
|
+
ParserTask(ThreadContext context, IRubyObject handler, InputStream stream)
|
202
|
+
{
|
203
|
+
super(context, handler, parse(context.runtime, stream), stream);
|
202
204
|
}
|
203
205
|
|
204
|
-
|
205
|
-
|
206
|
-
|
206
|
+
@Override
|
207
|
+
public HtmlSaxParserContext
|
208
|
+
call() throws Exception
|
209
|
+
{
|
210
|
+
return (HtmlSaxParserContext) super.call();
|
207
211
|
}
|
208
212
|
|
209
|
-
|
210
|
-
|
211
|
-
private ParserTask(ThreadContext context, IRubyObject handler, InputStream stream) {
|
212
|
-
super(context, handler, parse(context.runtime, stream), stream);
|
213
|
-
}
|
214
|
-
|
215
|
-
@Override
|
216
|
-
public HtmlSaxParserContext call() throws Exception {
|
217
|
-
return (HtmlSaxParserContext) super.call();
|
218
|
-
}
|
219
|
-
|
220
|
-
}
|
213
|
+
}
|
221
214
|
|
222
215
|
}
|
@@ -1,35 +1,3 @@
|
|
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
1
|
package nokogiri;
|
34
2
|
|
35
3
|
import java.util.Collections;
|
@@ -48,550 +16,621 @@ import org.jruby.runtime.load.BasicLibraryService;
|
|
48
16
|
/**
|
49
17
|
* Class to provide Nokogiri. This class is used to make "require 'nokogiri'" work
|
50
18
|
* in JRuby. Also, this class holds a Ruby type cache and allocators of Ruby types.
|
51
|
-
*
|
19
|
+
*
|
52
20
|
* @author headius
|
53
21
|
* @author Yoko Harada <yokolet@gmail.com>
|
54
22
|
*/
|
55
|
-
public class NokogiriService implements BasicLibraryService
|
56
|
-
|
57
|
-
|
58
|
-
|
23
|
+
public class NokogiriService implements BasicLibraryService
|
24
|
+
{
|
25
|
+
public boolean
|
26
|
+
basicLoad(Ruby ruby)
|
27
|
+
{
|
28
|
+
init(ruby);
|
29
|
+
return true;
|
30
|
+
}
|
31
|
+
|
32
|
+
public static Map<String, RubyClass>
|
33
|
+
getNokogiriClassCache(Ruby ruby)
|
34
|
+
{
|
35
|
+
return (Map<String, RubyClass>) ruby.getModule("Nokogiri").getInternalVariable("cache");
|
36
|
+
}
|
37
|
+
|
38
|
+
private static Map<String, RubyClass>
|
39
|
+
populateNokogiriClassCahce(Ruby ruby)
|
40
|
+
{
|
41
|
+
Map<String, RubyClass> nokogiriClassCache = new HashMap<String, RubyClass>();
|
42
|
+
nokogiriClassCache.put("Nokogiri::EncodingHandler", (RubyClass)ruby.getClassFromPath("Nokogiri::EncodingHandler"));
|
43
|
+
nokogiriClassCache.put("Nokogiri::HTML::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::HTML::Document"));
|
44
|
+
nokogiriClassCache.put("Nokogiri::HTML::ElementDescription",
|
45
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::HTML::ElementDescription"));
|
46
|
+
nokogiriClassCache.put("Nokogiri::XML::Attr", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Attr"));
|
47
|
+
nokogiriClassCache.put("Nokogiri::XML::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Document"));
|
48
|
+
nokogiriClassCache.put("Nokogiri::XML::DocumentFragment",
|
49
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::DocumentFragment"));
|
50
|
+
nokogiriClassCache.put("Nokogiri::XML::DTD", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::DTD"));
|
51
|
+
nokogiriClassCache.put("Nokogiri::XML::Text", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Text"));
|
52
|
+
nokogiriClassCache.put("Nokogiri::XML::Comment", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Comment"));
|
53
|
+
nokogiriClassCache.put("Nokogiri::XML::Element", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Element"));
|
54
|
+
nokogiriClassCache.put("Nokogiri::XML::ElementContent",
|
55
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::ElementContent"));
|
56
|
+
nokogiriClassCache.put("Nokogiri::XML::ElementDecl", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::ElementDecl"));
|
57
|
+
nokogiriClassCache.put("Nokogiri::XML::EntityDecl", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::EntityDecl"));
|
58
|
+
nokogiriClassCache.put("Nokogiri::XML::EntityReference",
|
59
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::EntityReference"));
|
60
|
+
nokogiriClassCache.put("Nokogiri::XML::ProcessingInstruction",
|
61
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::ProcessingInstruction"));
|
62
|
+
nokogiriClassCache.put("Nokogiri::XML::CDATA", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::CDATA"));
|
63
|
+
nokogiriClassCache.put("Nokogiri::XML::Node", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Node"));
|
64
|
+
nokogiriClassCache.put("Nokogiri::XML::NodeSet", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::NodeSet"));
|
65
|
+
nokogiriClassCache.put("Nokogiri::XML::Namespace", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Namespace"));
|
66
|
+
nokogiriClassCache.put("Nokogiri::XML::SyntaxError", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::SyntaxError"));
|
67
|
+
nokogiriClassCache.put("Nokogiri::XML::Reader", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Reader"));
|
68
|
+
nokogiriClassCache.put("Nokogiri::XML::RelaxNG", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::RelaxNG"));
|
69
|
+
nokogiriClassCache.put("Nokogiri::XML::Schema", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::Schema"));
|
70
|
+
nokogiriClassCache.put("Nokogiri::XML::XPathContext", (RubyClass)ruby.getClassFromPath("Nokogiri::XML::XPathContext"));
|
71
|
+
nokogiriClassCache.put("Nokogiri::XML::AttributeDecl",
|
72
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::AttributeDecl"));
|
73
|
+
nokogiriClassCache.put("Nokogiri::XML::SAX::ParserContext",
|
74
|
+
(RubyClass)ruby.getClassFromPath("Nokogiri::XML::SAX::ParserContext"));
|
75
|
+
return Collections.unmodifiableMap(nokogiriClassCache);
|
76
|
+
}
|
77
|
+
|
78
|
+
private void
|
79
|
+
init(Ruby ruby)
|
80
|
+
{
|
81
|
+
RubyModule nokogiri = ruby.defineModule("Nokogiri");
|
82
|
+
RubyModule xmlModule = nokogiri.defineModuleUnder("XML");
|
83
|
+
RubyModule xmlSaxModule = xmlModule.defineModuleUnder("SAX");
|
84
|
+
RubyModule htmlModule = nokogiri.defineModuleUnder("HTML");
|
85
|
+
RubyModule htmlSaxModule = htmlModule.defineModuleUnder("SAX");
|
86
|
+
RubyModule xsltModule = nokogiri.defineModuleUnder("XSLT");
|
87
|
+
|
88
|
+
createJavaLibraryVersionConstants(ruby, nokogiri);
|
89
|
+
createNokogiriModule(ruby, nokogiri);
|
90
|
+
createSyntaxErrors(ruby, nokogiri, xmlModule);
|
91
|
+
RubyClass xmlNode = createXmlModule(ruby, xmlModule);
|
92
|
+
createHtmlModule(ruby, htmlModule);
|
93
|
+
createDocuments(ruby, xmlModule, htmlModule, xmlNode);
|
94
|
+
createSaxModule(ruby, xmlSaxModule, htmlSaxModule);
|
95
|
+
createXsltModule(ruby, xsltModule);
|
96
|
+
nokogiri.setInternalVariable("cache", populateNokogiriClassCahce(ruby));
|
97
|
+
}
|
98
|
+
|
99
|
+
private void
|
100
|
+
createJavaLibraryVersionConstants(Ruby ruby, RubyModule nokogiri)
|
101
|
+
{
|
102
|
+
nokogiri.defineConstant("XERCES_VERSION", ruby.newString(org.apache.xerces.impl.Version.getVersion()));
|
103
|
+
nokogiri.defineConstant("NEKO_VERSION", ruby.newString(org.cyberneko.html.Version.getVersion()));
|
104
|
+
}
|
105
|
+
|
106
|
+
private void
|
107
|
+
createNokogiriModule(Ruby ruby, RubyModule nokogiri)
|
108
|
+
{
|
109
|
+
RubyClass encHandler = nokogiri.defineClassUnder("EncodingHandler", ruby.getObject(), ENCODING_HANDLER_ALLOCATOR);
|
110
|
+
encHandler.defineAnnotatedMethods(EncodingHandler.class);
|
111
|
+
}
|
112
|
+
|
113
|
+
private void
|
114
|
+
createSyntaxErrors(Ruby ruby, RubyModule nokogiri, RubyModule xmlModule)
|
115
|
+
{
|
116
|
+
RubyClass syntaxError = nokogiri.defineClassUnder("SyntaxError", ruby.getStandardError(),
|
117
|
+
ruby.getStandardError().getAllocator());
|
118
|
+
RubyClass xmlSyntaxError = xmlModule.defineClassUnder("SyntaxError", syntaxError, XML_SYNTAXERROR_ALLOCATOR);
|
119
|
+
xmlSyntaxError.defineAnnotatedMethods(XmlSyntaxError.class);
|
120
|
+
}
|
121
|
+
|
122
|
+
private RubyClass
|
123
|
+
createXmlModule(Ruby ruby, RubyModule xmlModule)
|
124
|
+
{
|
125
|
+
RubyClass node = xmlModule.defineClassUnder("Node", ruby.getObject(), XML_NODE_ALLOCATOR);
|
126
|
+
node.defineAnnotatedMethods(XmlNode.class);
|
127
|
+
|
128
|
+
RubyClass attr = xmlModule.defineClassUnder("Attr", node, XML_ATTR_ALLOCATOR);
|
129
|
+
attr.defineAnnotatedMethods(XmlAttr.class);
|
130
|
+
|
131
|
+
RubyClass attrDecl = xmlModule.defineClassUnder("AttributeDecl", node, XML_ATTRIBUTE_DECL_ALLOCATOR);
|
132
|
+
attrDecl.defineAnnotatedMethods(XmlAttributeDecl.class);
|
133
|
+
|
134
|
+
RubyClass characterData = xmlModule.defineClassUnder("CharacterData", node, null);
|
135
|
+
|
136
|
+
RubyClass comment = xmlModule.defineClassUnder("Comment", characterData, XML_COMMENT_ALLOCATOR);
|
137
|
+
comment.defineAnnotatedMethods(XmlComment.class);
|
138
|
+
|
139
|
+
RubyClass text = xmlModule.defineClassUnder("Text", characterData, XML_TEXT_ALLOCATOR);
|
140
|
+
text.defineAnnotatedMethods(XmlText.class);
|
141
|
+
|
142
|
+
RubyModule cdata = xmlModule.defineClassUnder("CDATA", text, XML_CDATA_ALLOCATOR);
|
143
|
+
cdata.defineAnnotatedMethods(XmlCdata.class);
|
144
|
+
|
145
|
+
RubyClass dtd = xmlModule.defineClassUnder("DTD", node, XML_DTD_ALLOCATOR);
|
146
|
+
dtd.defineAnnotatedMethods(XmlDtd.class);
|
147
|
+
|
148
|
+
RubyClass documentFragment = xmlModule.defineClassUnder("DocumentFragment", node, XML_DOCUMENT_FRAGMENT_ALLOCATOR);
|
149
|
+
documentFragment.defineAnnotatedMethods(XmlDocumentFragment.class);
|
150
|
+
|
151
|
+
RubyClass element = xmlModule.defineClassUnder("Element", node, XML_ELEMENT_ALLOCATOR);
|
152
|
+
element.defineAnnotatedMethods(XmlElement.class);
|
153
|
+
|
154
|
+
RubyClass elementContent = xmlModule.defineClassUnder("ElementContent", ruby.getObject(),
|
155
|
+
XML_ELEMENT_CONTENT_ALLOCATOR);
|
156
|
+
elementContent.defineAnnotatedMethods(XmlElementContent.class);
|
157
|
+
|
158
|
+
RubyClass elementDecl = xmlModule.defineClassUnder("ElementDecl", node, XML_ELEMENT_DECL_ALLOCATOR);
|
159
|
+
elementDecl.defineAnnotatedMethods(XmlElementDecl.class);
|
160
|
+
|
161
|
+
RubyClass entityDecl = xmlModule.defineClassUnder("EntityDecl", node, XML_ENTITY_DECL_ALLOCATOR);
|
162
|
+
entityDecl.defineAnnotatedMethods(XmlEntityDecl.class);
|
163
|
+
|
164
|
+
entityDecl.defineConstant("INTERNAL_GENERAL", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_GENERAL));
|
165
|
+
entityDecl.defineConstant("EXTERNAL_GENERAL_PARSED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_GENERAL_PARSED));
|
166
|
+
entityDecl.defineConstant("EXTERNAL_GENERAL_UNPARSED", RubyFixnum.newFixnum(ruby,
|
167
|
+
XmlEntityDecl.EXTERNAL_GENERAL_UNPARSED));
|
168
|
+
entityDecl.defineConstant("INTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PARAMETER));
|
169
|
+
entityDecl.defineConstant("EXTERNAL_PARAMETER", RubyFixnum.newFixnum(ruby, XmlEntityDecl.EXTERNAL_PARAMETER));
|
170
|
+
entityDecl.defineConstant("INTERNAL_PREDEFINED", RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_PREDEFINED));
|
171
|
+
|
172
|
+
RubyClass entref = xmlModule.defineClassUnder("EntityReference", node, XML_ENTITY_REFERENCE_ALLOCATOR);
|
173
|
+
entref.defineAnnotatedMethods(XmlEntityReference.class);
|
174
|
+
|
175
|
+
RubyClass namespace = xmlModule.defineClassUnder("Namespace", ruby.getObject(), XML_NAMESPACE_ALLOCATOR);
|
176
|
+
namespace.defineAnnotatedMethods(XmlNamespace.class);
|
177
|
+
|
178
|
+
RubyClass nodeSet = xmlModule.defineClassUnder("NodeSet", ruby.getObject(), XML_NODESET_ALLOCATOR);
|
179
|
+
nodeSet.defineAnnotatedMethods(XmlNodeSet.class);
|
180
|
+
|
181
|
+
RubyClass pi = xmlModule.defineClassUnder("ProcessingInstruction", node, XML_PROCESSING_INSTRUCTION_ALLOCATOR);
|
182
|
+
pi.defineAnnotatedMethods(XmlProcessingInstruction.class);
|
183
|
+
|
184
|
+
RubyClass reader = xmlModule.defineClassUnder("Reader", ruby.getObject(), XML_READER_ALLOCATOR);
|
185
|
+
reader.defineAnnotatedMethods(XmlReader.class);
|
186
|
+
|
187
|
+
RubyClass schema = xmlModule.defineClassUnder("Schema", ruby.getObject(), XML_SCHEMA_ALLOCATOR);
|
188
|
+
schema.defineAnnotatedMethods(XmlSchema.class);
|
189
|
+
|
190
|
+
RubyClass relaxng = xmlModule.defineClassUnder("RelaxNG", schema, XML_RELAXNG_ALLOCATOR);
|
191
|
+
relaxng.defineAnnotatedMethods(XmlRelaxng.class);
|
192
|
+
|
193
|
+
RubyClass xpathContext = xmlModule.defineClassUnder("XPathContext", ruby.getObject(), XML_XPATHCONTEXT_ALLOCATOR);
|
194
|
+
xpathContext.defineAnnotatedMethods(XmlXpathContext.class);
|
195
|
+
|
196
|
+
return node;
|
197
|
+
}
|
198
|
+
|
199
|
+
private void
|
200
|
+
createHtmlModule(Ruby ruby, RubyModule htmlModule)
|
201
|
+
{
|
202
|
+
RubyClass htmlElemDesc = htmlModule.defineClassUnder("ElementDescription", ruby.getObject(),
|
203
|
+
HTML_ELEMENT_DESCRIPTION_ALLOCATOR);
|
204
|
+
htmlElemDesc.defineAnnotatedMethods(HtmlElementDescription.class);
|
205
|
+
|
206
|
+
RubyClass htmlEntityLookup = htmlModule.defineClassUnder("EntityLookup", ruby.getObject(),
|
207
|
+
HTML_ENTITY_LOOKUP_ALLOCATOR);
|
208
|
+
htmlEntityLookup.defineAnnotatedMethods(HtmlEntityLookup.class);
|
209
|
+
}
|
210
|
+
|
211
|
+
private void
|
212
|
+
createDocuments(Ruby ruby, RubyModule xmlModule, RubyModule htmlModule, RubyClass node)
|
213
|
+
{
|
214
|
+
RubyClass xmlDocument = xmlModule.defineClassUnder("Document", node, XML_DOCUMENT_ALLOCATOR);
|
215
|
+
xmlDocument.defineAnnotatedMethods(XmlDocument.class);
|
216
|
+
|
217
|
+
//RubyModule htmlDoc = html.defineOrGetClassUnder("Document", document);
|
218
|
+
RubyModule htmlDocument = htmlModule.defineClassUnder("Document", xmlDocument, HTML_DOCUMENT_ALLOCATOR);
|
219
|
+
htmlDocument.defineAnnotatedMethods(HtmlDocument.class);
|
220
|
+
}
|
221
|
+
|
222
|
+
private void
|
223
|
+
createSaxModule(Ruby ruby, RubyModule xmlSaxModule, RubyModule htmlSaxModule)
|
224
|
+
{
|
225
|
+
RubyClass xmlSaxParserContext = xmlSaxModule.defineClassUnder("ParserContext", ruby.getObject(),
|
226
|
+
XML_SAXPARSER_CONTEXT_ALLOCATOR);
|
227
|
+
xmlSaxParserContext.defineAnnotatedMethods(XmlSaxParserContext.class);
|
228
|
+
|
229
|
+
RubyClass xmlSaxPushParser = xmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), XML_SAXPUSHPARSER_ALLOCATOR);
|
230
|
+
xmlSaxPushParser.defineAnnotatedMethods(XmlSaxPushParser.class);
|
231
|
+
|
232
|
+
RubyClass htmlSaxPushParser = htmlSaxModule.defineClassUnder("PushParser", ruby.getObject(),
|
233
|
+
HTML_SAXPUSHPARSER_ALLOCATOR);
|
234
|
+
htmlSaxPushParser.defineAnnotatedMethods(HtmlSaxPushParser.class);
|
235
|
+
|
236
|
+
RubyClass htmlSaxParserContext = htmlSaxModule.defineClassUnder("ParserContext", xmlSaxParserContext,
|
237
|
+
HTML_SAXPARSER_CONTEXT_ALLOCATOR);
|
238
|
+
htmlSaxParserContext.defineAnnotatedMethods(HtmlSaxParserContext.class);
|
239
|
+
}
|
240
|
+
|
241
|
+
private void
|
242
|
+
createXsltModule(Ruby ruby, RubyModule xsltModule)
|
243
|
+
{
|
244
|
+
RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
|
245
|
+
stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
|
246
|
+
xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
|
247
|
+
}
|
248
|
+
|
249
|
+
private static ObjectAllocator ENCODING_HANDLER_ALLOCATOR = new ObjectAllocator()
|
250
|
+
{
|
251
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
252
|
+
return new EncodingHandler(runtime, klazz, "");
|
253
|
+
}
|
254
|
+
};
|
255
|
+
|
256
|
+
public static final ObjectAllocator HTML_DOCUMENT_ALLOCATOR = new ObjectAllocator()
|
257
|
+
{
|
258
|
+
private HtmlDocument htmlDocument = null;
|
259
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
260
|
+
if (htmlDocument == null) { htmlDocument = new HtmlDocument(runtime, klazz); }
|
261
|
+
try {
|
262
|
+
HtmlDocument clone = (HtmlDocument) htmlDocument.clone();
|
263
|
+
clone.setMetaClass(klazz);
|
264
|
+
return clone;
|
265
|
+
} catch (CloneNotSupportedException e) {
|
266
|
+
return new HtmlDocument(runtime, klazz);
|
267
|
+
}
|
59
268
|
}
|
269
|
+
};
|
270
|
+
|
271
|
+
private static final ObjectAllocator HTML_SAXPARSER_CONTEXT_ALLOCATOR = new ObjectAllocator()
|
272
|
+
{
|
273
|
+
private HtmlSaxParserContext htmlSaxParserContext = null;
|
274
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
275
|
+
if (htmlSaxParserContext == null) { htmlSaxParserContext = new HtmlSaxParserContext(runtime, klazz); }
|
276
|
+
try {
|
277
|
+
HtmlSaxParserContext clone = (HtmlSaxParserContext) htmlSaxParserContext.clone();
|
278
|
+
clone.setMetaClass(klazz);
|
279
|
+
return clone;
|
280
|
+
} catch (CloneNotSupportedException e) {
|
281
|
+
return new HtmlSaxParserContext(runtime, klazz);
|
282
|
+
}
|
283
|
+
}
|
284
|
+
};
|
60
285
|
|
61
|
-
|
62
|
-
|
286
|
+
private static ObjectAllocator HTML_ELEMENT_DESCRIPTION_ALLOCATOR =
|
287
|
+
new ObjectAllocator()
|
288
|
+
{
|
289
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
290
|
+
return new HtmlElementDescription(runtime, klazz);
|
63
291
|
}
|
292
|
+
};
|
64
293
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
294
|
+
private static ObjectAllocator HTML_ENTITY_LOOKUP_ALLOCATOR =
|
295
|
+
new ObjectAllocator()
|
296
|
+
{
|
297
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
298
|
+
return new HtmlEntityLookup(runtime, klazz);
|
299
|
+
}
|
300
|
+
};
|
301
|
+
|
302
|
+
public static final ObjectAllocator XML_ATTR_ALLOCATOR = new ObjectAllocator()
|
303
|
+
{
|
304
|
+
private XmlAttr xmlAttr = null;
|
305
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
306
|
+
if (xmlAttr == null) { xmlAttr = new XmlAttr(runtime, klazz); }
|
307
|
+
try {
|
308
|
+
XmlAttr clone = (XmlAttr) xmlAttr.clone();
|
309
|
+
clone.setMetaClass(klazz);
|
310
|
+
return clone;
|
311
|
+
} catch (CloneNotSupportedException e) {
|
312
|
+
return new XmlAttr(runtime, klazz);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
};
|
316
|
+
|
317
|
+
public static final ObjectAllocator XML_CDATA_ALLOCATOR = new ObjectAllocator()
|
318
|
+
{
|
319
|
+
private XmlCdata xmlCdata = null;
|
320
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
321
|
+
if (xmlCdata == null) { xmlCdata = new XmlCdata(runtime, klazz); }
|
322
|
+
try {
|
323
|
+
XmlCdata clone = (XmlCdata) xmlCdata.clone();
|
324
|
+
clone.setMetaClass(klazz);
|
325
|
+
return clone;
|
326
|
+
} catch (CloneNotSupportedException e) {
|
327
|
+
return new XmlCdata(runtime, klazz);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
};
|
331
|
+
|
332
|
+
public static final ObjectAllocator XML_COMMENT_ALLOCATOR = new ObjectAllocator()
|
333
|
+
{
|
334
|
+
private XmlComment xmlComment = null;
|
335
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
336
|
+
if (xmlComment == null) { xmlComment = new XmlComment(runtime, klazz); }
|
337
|
+
try {
|
338
|
+
XmlComment clone = (XmlComment) xmlComment.clone();
|
339
|
+
clone.setMetaClass(klazz);
|
340
|
+
return clone;
|
341
|
+
} catch (CloneNotSupportedException e) {
|
342
|
+
return new XmlComment(runtime, klazz);
|
343
|
+
}
|
94
344
|
}
|
345
|
+
};
|
346
|
+
|
347
|
+
public static final ObjectAllocator XML_DOCUMENT_ALLOCATOR = new ObjectAllocator()
|
348
|
+
{
|
349
|
+
private XmlDocument xmlDocument = null;
|
350
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
351
|
+
if (xmlDocument == null) { xmlDocument = new XmlDocument(runtime, klazz); }
|
352
|
+
try {
|
353
|
+
XmlDocument clone = (XmlDocument) xmlDocument.clone();
|
354
|
+
clone.setMetaClass(klazz);
|
355
|
+
return clone;
|
356
|
+
} catch (CloneNotSupportedException e) {
|
357
|
+
return new XmlDocument(runtime, klazz);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
};
|
361
|
+
|
362
|
+
public static final ObjectAllocator XML_DOCUMENT_FRAGMENT_ALLOCATOR = new ObjectAllocator()
|
363
|
+
{
|
364
|
+
private XmlDocumentFragment xmlDocumentFragment = null;
|
365
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
366
|
+
if (xmlDocumentFragment == null) { xmlDocumentFragment = new XmlDocumentFragment(runtime, klazz); }
|
367
|
+
try {
|
368
|
+
XmlDocumentFragment clone = (XmlDocumentFragment)xmlDocumentFragment.clone();
|
369
|
+
clone.setMetaClass(klazz);
|
370
|
+
return clone;
|
371
|
+
} catch (CloneNotSupportedException e) {
|
372
|
+
return new XmlDocumentFragment(runtime, klazz);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
};
|
376
|
+
|
377
|
+
public static final ObjectAllocator XML_DTD_ALLOCATOR = new ObjectAllocator()
|
378
|
+
{
|
379
|
+
private XmlDtd xmlDtd = null;
|
380
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
381
|
+
if (xmlDtd == null) { xmlDtd = new XmlDtd(runtime, klazz); }
|
382
|
+
try {
|
383
|
+
XmlDtd clone = (XmlDtd)xmlDtd.clone();
|
384
|
+
clone.setMetaClass(klazz);
|
385
|
+
return clone;
|
386
|
+
} catch (CloneNotSupportedException e) {
|
387
|
+
return new XmlDtd(runtime, klazz);
|
388
|
+
}
|
389
|
+
}
|
390
|
+
};
|
391
|
+
|
392
|
+
public static final ObjectAllocator XML_ELEMENT_ALLOCATOR = new ObjectAllocator()
|
393
|
+
{
|
394
|
+
private XmlElement xmlElement = null;
|
395
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
396
|
+
if (xmlElement == null) { xmlElement = new XmlElement(runtime, klazz); }
|
397
|
+
try {
|
398
|
+
XmlElement clone = (XmlElement)xmlElement.clone();
|
399
|
+
clone.setMetaClass(klazz);
|
400
|
+
return clone;
|
401
|
+
} catch (CloneNotSupportedException e) {
|
402
|
+
return new XmlElement(runtime, klazz);
|
403
|
+
}
|
404
|
+
}
|
405
|
+
};
|
406
|
+
|
407
|
+
public static ObjectAllocator XML_ELEMENT_DECL_ALLOCATOR = new ObjectAllocator()
|
408
|
+
{
|
409
|
+
private XmlElementDecl xmlElementDecl = null;
|
410
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
411
|
+
if (xmlElementDecl == null) { xmlElementDecl = new XmlElementDecl(runtime, klazz); }
|
412
|
+
try {
|
413
|
+
XmlElementDecl clone = (XmlElementDecl)xmlElementDecl.clone();
|
414
|
+
clone.setMetaClass(klazz);
|
415
|
+
return clone;
|
416
|
+
} catch (CloneNotSupportedException e) {
|
417
|
+
return new XmlElementDecl(runtime, klazz);
|
418
|
+
}
|
419
|
+
}
|
420
|
+
};
|
421
|
+
|
422
|
+
public static ObjectAllocator XML_ENTITY_REFERENCE_ALLOCATOR = new ObjectAllocator()
|
423
|
+
{
|
424
|
+
private XmlEntityReference xmlEntityRef = null;
|
425
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
426
|
+
if (xmlEntityRef == null) { xmlEntityRef = new XmlEntityReference(runtime, klazz); }
|
427
|
+
try {
|
428
|
+
XmlEntityReference clone = (XmlEntityReference)xmlEntityRef.clone();
|
429
|
+
clone.setMetaClass(klazz);
|
430
|
+
return clone;
|
431
|
+
} catch (CloneNotSupportedException e) {
|
432
|
+
return new XmlEntityReference(runtime, klazz);
|
433
|
+
}
|
434
|
+
}
|
435
|
+
};
|
436
|
+
|
437
|
+
public static final ObjectAllocator XML_NAMESPACE_ALLOCATOR = new ObjectAllocator()
|
438
|
+
{
|
439
|
+
private XmlNamespace xmlNamespace = null;
|
440
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
441
|
+
if (xmlNamespace == null) { xmlNamespace = new XmlNamespace(runtime, klazz); }
|
442
|
+
try {
|
443
|
+
XmlNamespace clone = (XmlNamespace) xmlNamespace.clone();
|
444
|
+
clone.setMetaClass(klazz);
|
445
|
+
return clone;
|
446
|
+
} catch (CloneNotSupportedException e) {
|
447
|
+
return new XmlNamespace(runtime, klazz);
|
448
|
+
}
|
449
|
+
}
|
450
|
+
};
|
451
|
+
|
452
|
+
public static final ObjectAllocator XML_NODE_ALLOCATOR = new ObjectAllocator()
|
453
|
+
{
|
454
|
+
private XmlNode xmlNode = null;
|
455
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
456
|
+
if (xmlNode == null) { xmlNode = new XmlNode(runtime, klazz); }
|
457
|
+
try {
|
458
|
+
XmlNode clone = (XmlNode) xmlNode.clone();
|
459
|
+
clone.setMetaClass(klazz);
|
460
|
+
return clone;
|
461
|
+
} catch (CloneNotSupportedException e) {
|
462
|
+
return new XmlNode(runtime, klazz);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
};
|
466
|
+
|
467
|
+
public static final ObjectAllocator XML_NODESET_ALLOCATOR = new ObjectAllocator()
|
468
|
+
{
|
469
|
+
private XmlNodeSet xmlNodeSet = null;
|
470
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
471
|
+
if (xmlNodeSet == null) { xmlNodeSet = new XmlNodeSet(runtime, klazz); }
|
472
|
+
try {
|
473
|
+
XmlNodeSet clone = (XmlNodeSet) xmlNodeSet.clone();
|
474
|
+
clone.setMetaClass(klazz);
|
475
|
+
return clone;
|
476
|
+
} catch (CloneNotSupportedException e) {
|
477
|
+
return new XmlNodeSet(runtime, klazz);
|
478
|
+
}
|
479
|
+
}
|
480
|
+
};
|
481
|
+
|
482
|
+
public static ObjectAllocator XML_PROCESSING_INSTRUCTION_ALLOCATOR = new ObjectAllocator()
|
483
|
+
{
|
484
|
+
private XmlProcessingInstruction xmlProcessingInstruction = null;
|
485
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
486
|
+
if (xmlProcessingInstruction == null) { xmlProcessingInstruction = new XmlProcessingInstruction(runtime, klazz); }
|
487
|
+
try {
|
488
|
+
XmlProcessingInstruction clone = (XmlProcessingInstruction)xmlProcessingInstruction.clone();
|
489
|
+
clone.setMetaClass(klazz);
|
490
|
+
return clone;
|
491
|
+
} catch (CloneNotSupportedException e) {
|
492
|
+
return new XmlProcessingInstruction(runtime, klazz);
|
493
|
+
}
|
494
|
+
}
|
495
|
+
};
|
496
|
+
|
497
|
+
public static ObjectAllocator XML_READER_ALLOCATOR = new ObjectAllocator()
|
498
|
+
{
|
499
|
+
private XmlReader xmlReader = null;
|
500
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
501
|
+
if (xmlReader == null) { xmlReader = new XmlReader(runtime, klazz); }
|
502
|
+
try {
|
503
|
+
XmlReader clone = (XmlReader) xmlReader.clone();
|
504
|
+
clone.setMetaClass(klazz);
|
505
|
+
return clone;
|
506
|
+
} catch (CloneNotSupportedException e) {
|
507
|
+
xmlReader = new XmlReader(runtime, klazz);
|
508
|
+
return xmlReader;
|
509
|
+
}
|
510
|
+
}
|
511
|
+
};
|
95
512
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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));
|
513
|
+
private static ObjectAllocator XML_ATTRIBUTE_DECL_ALLOCATOR = new ObjectAllocator()
|
514
|
+
{
|
515
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
516
|
+
return new XmlAttributeDecl(runtime, klazz);
|
113
517
|
}
|
518
|
+
};
|
114
519
|
|
115
|
-
|
116
|
-
|
117
|
-
|
520
|
+
private static ObjectAllocator XML_ENTITY_DECL_ALLOCATOR = new ObjectAllocator()
|
521
|
+
{
|
522
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
523
|
+
return new XmlEntityDecl(runtime, klazz);
|
118
524
|
}
|
525
|
+
};
|
119
526
|
|
120
|
-
|
121
|
-
|
122
|
-
|
527
|
+
private static ObjectAllocator XML_ELEMENT_CONTENT_ALLOCATOR = new ObjectAllocator()
|
528
|
+
{
|
529
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
530
|
+
throw runtime.newNotImplementedError("not implemented");
|
531
|
+
}
|
532
|
+
};
|
533
|
+
|
534
|
+
public static final ObjectAllocator XML_RELAXNG_ALLOCATOR = new ObjectAllocator()
|
535
|
+
{
|
536
|
+
private XmlRelaxng xmlRelaxng = null;
|
537
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
538
|
+
if (xmlRelaxng == null) { xmlRelaxng = new XmlRelaxng(runtime, klazz); }
|
539
|
+
try {
|
540
|
+
XmlRelaxng clone = (XmlRelaxng) xmlRelaxng.clone();
|
541
|
+
clone.setMetaClass(klazz);
|
542
|
+
return clone;
|
543
|
+
} catch (CloneNotSupportedException e) {
|
544
|
+
return new XmlRelaxng(runtime, klazz);
|
545
|
+
}
|
123
546
|
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
547
|
+
};
|
548
|
+
|
549
|
+
public static final ObjectAllocator XML_SAXPARSER_CONTEXT_ALLOCATOR = new ObjectAllocator()
|
550
|
+
{
|
551
|
+
private XmlSaxParserContext xmlSaxParserContext = null;
|
552
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
553
|
+
if (xmlSaxParserContext == null) { xmlSaxParserContext = new XmlSaxParserContext(runtime, klazz); }
|
554
|
+
try {
|
555
|
+
XmlSaxParserContext clone = (XmlSaxParserContext) xmlSaxParserContext.clone();
|
556
|
+
clone.setMetaClass(klazz);
|
557
|
+
return clone;
|
558
|
+
} catch (CloneNotSupportedException e) {
|
559
|
+
return new XmlSaxParserContext(runtime, klazz);
|
560
|
+
}
|
129
561
|
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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;
|
562
|
+
};
|
563
|
+
|
564
|
+
private static final ObjectAllocator XML_SAXPUSHPARSER_ALLOCATOR = new ObjectAllocator()
|
565
|
+
{
|
566
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
567
|
+
return new XmlSaxPushParser(runtime, klazz);
|
202
568
|
}
|
569
|
+
};
|
203
570
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
RubyClass htmlEntityLookup = htmlModule.defineClassUnder("EntityLookup", ruby.getObject(), HTML_ENTITY_LOOKUP_ALLOCATOR);
|
209
|
-
htmlEntityLookup.defineAnnotatedMethods(HtmlEntityLookup.class);
|
571
|
+
private static final ObjectAllocator HTML_SAXPUSHPARSER_ALLOCATOR = new ObjectAllocator()
|
572
|
+
{
|
573
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
574
|
+
return new HtmlSaxPushParser(runtime, klazz);
|
210
575
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
576
|
+
};
|
577
|
+
|
578
|
+
public static final ObjectAllocator XML_SCHEMA_ALLOCATOR = new ObjectAllocator()
|
579
|
+
{
|
580
|
+
private XmlSchema xmlSchema = null;
|
581
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
582
|
+
if (xmlSchema == null) { xmlSchema = new XmlSchema(runtime, klazz); }
|
583
|
+
try {
|
584
|
+
XmlSchema clone = (XmlSchema) xmlSchema.clone();
|
585
|
+
clone.setMetaClass(klazz);
|
586
|
+
return clone;
|
587
|
+
} catch (CloneNotSupportedException e) {
|
588
|
+
return new XmlSchema(runtime, klazz);
|
589
|
+
}
|
219
590
|
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
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);
|
591
|
+
};
|
592
|
+
|
593
|
+
public static final ObjectAllocator XML_SYNTAXERROR_ALLOCATOR = new ObjectAllocator()
|
594
|
+
{
|
595
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
596
|
+
return new XmlSyntaxError(runtime, klazz);
|
233
597
|
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
598
|
+
};
|
599
|
+
|
600
|
+
public static final ObjectAllocator XML_TEXT_ALLOCATOR = new ObjectAllocator()
|
601
|
+
{
|
602
|
+
private XmlText xmlText = null;
|
603
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
604
|
+
if (xmlText == null) { xmlText = new XmlText(runtime, klazz); }
|
605
|
+
try {
|
606
|
+
XmlText clone = (XmlText) xmlText.clone();
|
607
|
+
clone.setMetaClass(klazz);
|
608
|
+
return clone;
|
609
|
+
} catch (CloneNotSupportedException e) {
|
610
|
+
return new XmlText(runtime, klazz);
|
611
|
+
}
|
239
612
|
}
|
613
|
+
};
|
240
614
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
}
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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
|
-
};
|
615
|
+
public static final ObjectAllocator XML_XPATHCONTEXT_ALLOCATOR = new ObjectAllocator()
|
616
|
+
{
|
617
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
618
|
+
return new XmlXpathContext(runtime, klazz);
|
619
|
+
}
|
620
|
+
};
|
621
|
+
|
622
|
+
public static ObjectAllocator XSLT_STYLESHEET_ALLOCATOR = new ObjectAllocator()
|
623
|
+
{
|
624
|
+
private XsltStylesheet xsltStylesheet = null;
|
625
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
|
626
|
+
if (xsltStylesheet == null) { xsltStylesheet = new XsltStylesheet(runtime, klazz); }
|
627
|
+
try {
|
628
|
+
XsltStylesheet clone = (XsltStylesheet) xsltStylesheet.clone();
|
629
|
+
clone.setMetaClass(klazz);
|
630
|
+
return clone;
|
631
|
+
} catch (CloneNotSupportedException e) {
|
632
|
+
return new XmlText(runtime, klazz);
|
633
|
+
}
|
634
|
+
}
|
635
|
+
};
|
597
636
|
}
|