Skip to content
This repository was archived by the owner on Dec 30, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ bin/
target/
*~
.*sw?
\#*
\#*
.idea/
*.iml

# vscode
.project
.settings/
.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class OdfXMLFactory {
private static Map<OdfName, Class> mElementTypes = new HashMap<OdfName, Class>();
private static Map<OdfName, Class> mAttributeTypes = new HashMap<OdfName, Class>();
private static Map<String, String> mElementRenames = new HashMap<String, String>();
private static Set<OdfName> mAlienTypes = new HashSet<OdfName>();
//a set for the element which need to load class from incubator package.
private static Set<String> mIncubatorElements = new HashSet<String>();
private static final String LOCAL_NAME_DELIMITER = "-";
Expand Down Expand Up @@ -116,6 +117,10 @@ private static Class getOdfElementClass(OdfName odfName) {
}

private static Class getOdfNodeClass(OdfName odfName, String nodeType, Map<OdfName, Class> classCache, boolean isAttribute) {
if (mAlienTypes.contains(odfName)) {
return null;
}

Class c = null;
String className = "";
c = classCache.get(odfName);
Expand Down Expand Up @@ -147,8 +152,10 @@ private static Class getOdfNodeClass(OdfName odfName, String nodeType, Map<OdfNa
c = Class.forName(className);
classCache.put(odfName, c);
} catch (ClassNotFoundException ex) {
mAlienTypes.add(odfName);
// all classes are first tring to load and warning is given later
} catch (NoClassDefFoundError dex) {
mAlienTypes.add(odfName);
Logger.getLogger(OdfXMLFactory.class.getName()).log(Level.INFO, "NoClassDefFoundError: " + className, dex.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/************************************************************************
*
* 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.
*
************************************************************************/
package org.odftoolkit.odfdom.pkg;

import org.junit.Test;
import org.odftoolkit.odfdom.doc.OdfDocument;
import org.odftoolkit.odfdom.utils.ResourceUtilities;

public class AlienPerformanceTest {

private static final String ALIEN_PERFORMANCE_FILE = "testAlienPerformance.odt";

@Test
public void testAlienPerformance() throws Exception {
OdfDocument doc = OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(ALIEN_PERFORMANCE_FILE));
long startTime=System.currentTimeMillis();
doc.getContentDom();
doc.getTableList();
long endTime=System.currentTimeMillis();
float excTime = endTime-startTime;
System.out.println("Time escape:"+ excTime +"ms");
}
}
Binary file not shown.