incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1811308 - in /incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa: DOMRDFaParser.java RDFaParser.java
Date Fri, 06 Oct 2017 09:26:54 GMT
Author: svanteschubert
Date: Fri Oct  6 09:26:54 2017
New Revision: 1811308

URL: http://svn.apache.org/viewvc?rev=1811308&view=rev
Log:
#ODFTOOLKIT-424# Patch by Nimarukan - PERFORMANCE: Reuse XMLFactories, currently created too
frequently during insertNode and setTextContent

Modified:
    incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/DOMRDFaParser.java
    incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/RDFaParser.java

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/DOMRDFaParser.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/DOMRDFaParser.java?rev=1811308&r1=1811307&r2=1811308&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/DOMRDFaParser.java
(original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/DOMRDFaParser.java
Fri Oct  6 09:26:54 2017
@@ -1,20 +1,20 @@
 /************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- * 
+ *
  * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- * 
+ *
  * Use is subject to license terms.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy
  * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
  * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * 
+ *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
@@ -23,20 +23,21 @@ package org.odftoolkit.odfdom.pkg.rdfa;
 
 import javax.xml.stream.XMLEventFactory;
 import javax.xml.stream.XMLOutputFactory;
-
 import org.odftoolkit.odfdom.dom.element.text.TextBookmarkStartElement;
 import org.w3c.dom.Node;
 
 /**
  * A RDFa parser for DOM
- * 
+ *
  */
 public class DOMRDFaParser extends RDFaParser {
 
+	private static final XMLOutputFactory DEFAULT_XML_OUTPUT_FACTORY = XMLOutputFactory.newFactory();
+	private static final XMLEventFactory DEFAULT_XML_EVENT_FACTORY = XMLEventFactory.newFactory();
+
 	public static DOMRDFaParser createInstance(JenaSink sink) {
 		sink.getExtractor().setForSAX(false);
-		return new DOMRDFaParser(sink, XMLOutputFactory.newInstance(),
-				XMLEventFactory.newInstance(), sink.getExtractor());
+		return new DOMRDFaParser(sink, sink.getExtractor());
 	}
 
 	public DOMRDFaParser(JenaSink sink, XMLOutputFactory outputFactory,
@@ -45,9 +46,13 @@ public class DOMRDFaParser extends RDFaP
 
 	}
 
+    public DOMRDFaParser(JenaSink sink, URIExtractor extractor) {
+ 		this(sink, DEFAULT_XML_OUTPUT_FACTORY, DEFAULT_XML_EVENT_FACTORY, extractor);
+ 	}
+
 	/**
 	 * Parse the RDFa in-content metadata of the node.
-	 * 
+	 *
 	 * @param node
 	 */
 	public void parse(Node node) {

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/RDFaParser.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/RDFaParser.java?rev=1811308&r1=1811307&r2=1811308&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/RDFaParser.java
(original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/rdfa/RDFaParser.java
Fri Oct  6 09:26:54 2017
@@ -1,20 +1,20 @@
 /************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- * 
+ *
  * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- * 
+ *
  * Use is subject to license terms.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy
  * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
  * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * 
+ *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
@@ -26,7 +26,6 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLEventFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -34,11 +33,12 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.events.Attribute;
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
-
 import net.rootdev.javardfa.Constants;
+import net.rootdev.javardfa.ProfileCollector;
 import net.rootdev.javardfa.Setting;
 import net.rootdev.javardfa.literal.LiteralCollector;
-
+import net.rootdev.javardfa.uri.IRIResolver;
+import net.rootdev.javardfa.uri.URIExtractor10;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 
@@ -47,7 +47,7 @@ import org.xml.sax.Locator;
  *
  */
 class RDFaParser extends net.rootdev.javardfa.Parser {
-	
+
 	boolean ignore = false;
 
 	protected XMLEventFactory eventFactory;
@@ -60,7 +60,7 @@ class RDFaParser extends net.rootdev.jav
 
 	protected RDFaParser(JenaSink sink, XMLOutputFactory outputFactory,
 			XMLEventFactory eventFactory, URIExtractor extractor) {
-		super(sink);
+		super(sink, outputFactory, eventFactory, new URIExtractor10(new IRIResolver()), ProfileCollector.EMPTY_COLLECTOR);
 		this.sink = sink;
 		this.eventFactory = eventFactory;
 		this.settings = EnumSet.noneOf(Setting.class);
@@ -116,7 +116,7 @@ class RDFaParser extends net.rootdev.jav
 			throw new RuntimeException("Streaming issue", ex);
 		}
 	}
-	
+
 	protected void endRDFaElement(String arg0, String localname, String qname) {
 		if (localname.equals("bookmark-start")) {
 			ignore = false;
@@ -132,7 +132,7 @@ class RDFaParser extends net.rootdev.jav
 		if (!literalCollector.isCollectingXML())
 			context = context.parent;
 	}
-	
+
 	protected void writeCharacters(String value) {
 		if (!ignore) {
 			if (literalCollector.isCollecting()) {
@@ -141,11 +141,11 @@ class RDFaParser extends net.rootdev.jav
 			}
 		}
 	}
-	
-	/** 
+
+	/**
 	 * Set the base uri of the DOM.
 	 */
-	public void setBase(String base) {	
+	public void setBase(String base) {
 		this.context = new EvalContext(base);
 		sink.setBase(context.getBase());
 	}
@@ -202,7 +202,7 @@ class RDFaParser extends net.rootdev.jav
 		}
 		if (getAttributeByName(element, Constants.rev) == null
 				&& getAttributeByName(element, Constants.rel) == null) {
-			Attribute nSubj = findAttribute(element, Constants.about);	
+			Attribute nSubj = findAttribute(element, Constants.about);
 			if (nSubj != null) {
 				newSubject = extractor.getURI(element, nSubj, context);
 			}



Mime
View raw message