-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #josm17152 - fix JAXB initialization
git-svn-id: https://josm.openstreetmap.de/osmsvn/applications/editors/josm/plugins@35012 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
- Loading branch information
Showing
3 changed files
with
14 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.JAXBElement; | ||
import javax.xml.bind.JAXBException; | ||
import javax.xml.bind.Unmarshaller; | ||
import javax.xml.datatype.XMLGregorianCalendar; | ||
|
||
import org.openstreetmap.josm.actions.ExtensionFileFilter; | ||
|
@@ -34,9 +33,8 @@ | |
import org.openstreetmap.josm.plugins.dataimport.io.tcx.TrainingCenterDatabaseT; | ||
import org.openstreetmap.josm.spi.preferences.Config; | ||
|
||
|
||
/** | ||
* TCX Reader. This class is based on code genarated by the Java Architecture | ||
* TCX Reader. This class is based on code generated by the Java Architecture | ||
* for XML Binding (JAXB). For this class to work you will need the API und IMPL | ||
* Jars from the RI. JAXB can be downloaded at <a | ||
* href="https://jaxb.dev.java.net/">https://jaxb.dev.java.net/</a>. This class | ||
|
@@ -50,9 +48,6 @@ | |
* The command used to generate the code is: | ||
* {@code xjc.bat -p org.openstreetmap.josm.io.tcx TrainingCenterDatabasev2.xsd -d <path to the src folder of JOSM>} | ||
* <p> | ||
* Note: if you get an exception that JAXB 2.1 is not supported on your system, you will have to add the jaxb-api.jar | ||
* to the endorsed directory (create it if necessary) of your JRE. Usually it is something like this: | ||
* {@code \<program files>\Java\jre<java version>\lib\endorsed} | ||
* | ||
* @author adrian <[email protected]> | ||
* | ||
|
@@ -62,9 +57,12 @@ public class Tcx extends FileImporter { | |
//private File tcxFile; | ||
|
||
private GpxData gpxData; | ||
private final JAXBContext jc; | ||
|
||
public Tcx() { | ||
public Tcx() throws JAXBException { | ||
super(new ExtensionFileFilter("tcx", "tcx", tr("TCX Files (*.tcx)"))); | ||
// JAXB must be initialized at plugin construction to get access to JAXB plugin from JOSM plugin classloader | ||
jc = JAXBContext.newInstance(TrainingCenterDatabaseT.class); | ||
} | ||
|
||
@Override | ||
|
@@ -83,18 +81,11 @@ public void importData(File tcxFile, ProgressMonitor progressMonitor) throws IOE | |
} | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
@SuppressWarnings("unchecked") private void parseFile(File tcxFile) { | ||
@SuppressWarnings("unchecked") | ||
private void parseFile(File tcxFile) { | ||
try { | ||
JAXBContext jc = JAXBContext | ||
.newInstance(TrainingCenterDatabaseT.class); | ||
Unmarshaller unmarshaller = jc.createUnmarshaller(); | ||
JAXBElement<TrainingCenterDatabaseT> element = (JAXBElement<TrainingCenterDatabaseT>) unmarshaller | ||
.unmarshal(tcxFile); | ||
|
||
TrainingCenterDatabaseT tcd = element.getValue(); | ||
TrainingCenterDatabaseT tcd = ((JAXBElement<TrainingCenterDatabaseT>) | ||
jc.createUnmarshaller().unmarshal(tcxFile)).getValue(); | ||
|
||
gpxData = new GpxData(); | ||
|
||
|