commit
7f3a04c3c6
|
@ -0,0 +1 @@
|
|||
target/
|
25
README.md
25
README.md
|
@ -6,6 +6,31 @@ This tool is based on [RISE V2G shared library](https://github.com/V2GClarity/RI
|
|||
|
||||
A release is available with a compiled Java Runtime binary there: https://github.com/FlUxIuS/V2Gdecoder/releases
|
||||
|
||||
## How to compile or execute
|
||||
Install maven.
|
||||
|
||||
To compile:
|
||||
|
||||
```mvn compile assembly:single```
|
||||
|
||||
To execute:
|
||||
|
||||
```java -jar target/V2Gdecoder-jar-with-dependencies.jar```
|
||||
|
||||
If you wish to update risev2g version to something >1.2.6:
|
||||
|
||||
```
|
||||
git clone https://github.com/V2GClarity/RISE-V2G/
|
||||
cd RISE-V2G/RISE-V2G-PARENT
|
||||
mvn install
|
||||
```
|
||||
|
||||
Now copy RISE-V2G-Shared in our project:
|
||||
|
||||
```cp RISE-V2G/RISE-V2G-Shared/target/rise-v2g-shared-1.2.6.jar src/lib/com.v2gclarity.risev2g/```
|
||||
|
||||
Be aware that you might have to do some changes to the code.
|
||||
|
||||
## How to use
|
||||
|
||||
V2Gdecoder supports many methods to encode XML/decode EXI data as follows:
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fluxlus.V2Gdecoder</groupId>
|
||||
<artifactId>V2Gdecoder</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>V2Gdecoder</name>
|
||||
<url>https://github.com/FlUxIuS/V2Gdecoder</url>
|
||||
|
||||
<packaging>jar</packaging> <!-- new -->
|
||||
<description>V2Gdecoder description. </description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>project-local-repo</id>
|
||||
<url>file://${project.basedir}/src/lib/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.14.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.v2gclarity.risev2g</groupId>
|
||||
<artifactId>rise-v2g-shared</artifactId>
|
||||
<version>1.2.6</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.siemens.ct.exi/exificient -->
|
||||
<dependency>
|
||||
<groupId>com.siemens.ct.exi</groupId>
|
||||
<artifactId>exificient</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>V2Gdecoder</finalName> <!-- added now-->
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.fluxlus.V2Gdecoder.V2Gdecoder</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- <plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin> -->
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<!-- https://mvnrepository.com/artifact/com.siemens.ct.exi/exificient-core -->
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Archiver-Version: Plexus Archiver
|
||||
Built-By: fluxius
|
||||
Created-By: Apache Maven 3.5.0
|
||||
Build-Jdk: 1.8.0_191
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.v2gclarity.risev2g_rise-v2g-shared</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,5 +0,0 @@
|
|||
#Generated by Maven
|
||||
#Thu Jan 24 11:57:05 CET 2019
|
||||
version=1.1.4-SNAPSHOT
|
||||
groupId=com.v2gclarity.risev2g
|
||||
artifactId=rise-v2g-shared
|
|
@ -1,59 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>com.v2gclarity.risev2g</groupId>
|
||||
<artifactId>rise-v2g-parent</artifactId>
|
||||
<version>1.1.4-SNAPSHOT</version>
|
||||
<relativePath>../RISE-V2G-PARENT</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>rise-v2g-shared</artifactId>
|
||||
<name>rise-v2g-shared</name>
|
||||
|
||||
<repositories>
|
||||
<!-- OpenEXI jars deployed in the /repo folder of RISE-V2G-Shared.
|
||||
See https://devcenter.heroku.com/articles/local-maven-dependencies for how to deploy .jars locally which are not
|
||||
published in a public Maven repo. -->
|
||||
<repository>
|
||||
<id>project.local</id>
|
||||
<name>project</name>
|
||||
<url>file:${project.basedir}/repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.siemens.ct.exi</groupId>
|
||||
<artifactId>exificient</artifactId>
|
||||
<version>0.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.openexi</groupId>
|
||||
<artifactId>nagasena</artifactId>
|
||||
<version>0000.0002.0052.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.openexi</groupId>
|
||||
<artifactId>nagasena-rta</artifactId>
|
||||
<version>0000.0002.0052.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,9 +1,14 @@
|
|||
import server.MultiThreadedServer;
|
||||
package com.fluxlus.V2Gdecoder;
|
||||
|
||||
import com.fluxlus.V2Gdecoder.server.MultiThreadedServer;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.xml.sax.SAXException;
|
||||
import com.siemens.ct.exi.exceptions.EXIException;
|
||||
import dataprocess.*;
|
||||
import com.siemens.ct.exi.core.exceptions.EXIException;
|
||||
import com.siemens.ct.exi.core.grammars.Grammars;
|
||||
import com.siemens.ct.exi.grammars.GrammarFactory;
|
||||
import com.v2gclarity.risev2g.shared.enumerations.GlobalValues;
|
||||
import com.fluxlus.V2Gdecoder.dataprocess.*;
|
||||
|
||||
/*
|
||||
* Copyright (C) V2Gdecoder by FlUxIuS (Sebastien Dudek)
|
||||
|
@ -51,7 +56,27 @@ public class V2Gdecoder {
|
|||
//String outputFilePath = cmd.getOptionValue("output"); /* TODO: custom output file */
|
||||
decodeMode dmode = decodeMode.STRTOSTR;
|
||||
String result = null;
|
||||
|
||||
|
||||
/* Initialize grammars */
|
||||
Grammars[] grammars = {null, null, null};
|
||||
|
||||
/* BOTTLENECK: slow operation */
|
||||
try {
|
||||
grammars[0] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_MSG_DEF.toString());
|
||||
} catch (EXIException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
grammars[1] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_APP_PROTOCOL.toString());
|
||||
} catch (EXIException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
grammars[2] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_XMLDSIG.toString());
|
||||
} catch (EXIException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (cmd.hasOption("xml"))
|
||||
{ // We wan to encode a XML input
|
||||
if (cmd.hasOption("file"))
|
||||
|
@ -64,7 +89,7 @@ public class V2Gdecoder {
|
|||
if (cmd.hasOption("output"))
|
||||
dmode = decodeMode.STRTOSTR;
|
||||
}
|
||||
result = dataprocess.Xml2Exi(inputFilePath, dmode);
|
||||
result = dataprocess.fuzzyExiEncoder(inputFilePath, dmode, grammars);
|
||||
if (!cmd.hasOption("output"))
|
||||
System.out.println(result);
|
||||
} else if (cmd.hasOption("exi")) { // We wan to decode an EXI input
|
||||
|
@ -78,13 +103,13 @@ public class V2Gdecoder {
|
|||
if (cmd.hasOption("output"))
|
||||
dmode = decodeMode.STRTOFILE;
|
||||
}
|
||||
result = dataprocess.fuzzyExiDecoded(inputFilePath, dmode);
|
||||
result = dataprocess.fuzzyExiDecoded(inputFilePath, dmode, grammars);
|
||||
if (!cmd.hasOption("output"))
|
||||
{ // output in stdout
|
||||
System.out.println(result);
|
||||
}
|
||||
} else if (cmd.hasOption("web")) { // run a encoder/decoder service on port TCP 9000
|
||||
MultiThreadedServer server = new MultiThreadedServer(9000);
|
||||
MultiThreadedServer server = new MultiThreadedServer(9000, grammars);
|
||||
new Thread(server).start();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package binascii;
|
||||
package com.fluxlus.V2Gdecoder.binascii;
|
||||
|
||||
/*
|
||||
* code from: https://github.com/EverythingMe/inbloom/blob/master/java/src/main/java/me/everything/inbloom/BinAscii.java
|
|
@ -1,4 +1,4 @@
|
|||
package dataprocess;
|
||||
package com.fluxlus.V2Gdecoder.dataprocess;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -17,39 +17,40 @@ import javax.xml.transform.TransformerFactory;
|
|||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.eclipse.risev2g.shared.enumerations.GlobalValues;
|
||||
import org.eclipse.risev2g.shared.messageHandling.MessageHandler;
|
||||
import org.eclipse.risev2g.shared.utils.MiscUtils;
|
||||
import com.v2gclarity.risev2g.shared.enumerations.GlobalValues;
|
||||
// import com.v2gclarity.risev2g.shared.messageHandling.MessageHandler;
|
||||
// import com.v2gclarity.risev2g.shared.utils.MiscUtils;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import com.siemens.ct.exi.EXIFactory;
|
||||
import com.siemens.ct.exi.GrammarFactory;
|
||||
import com.siemens.ct.exi.api.sax.EXIResult;
|
||||
import com.siemens.ct.exi.api.sax.EXISource;
|
||||
import com.siemens.ct.exi.exceptions.EXIException;
|
||||
import com.siemens.ct.exi.helpers.DefaultEXIFactory;
|
||||
import com.siemens.ct.exi.core.EXIFactory;
|
||||
import com.siemens.ct.exi.grammars.GrammarFactory;
|
||||
import com.siemens.ct.exi.core.grammars.Grammars;
|
||||
import com.siemens.ct.exi.main.api.sax.EXIResult;
|
||||
import com.siemens.ct.exi.main.api.sax.EXISource;
|
||||
import com.siemens.ct.exi.core.exceptions.EXIException;
|
||||
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
|
||||
|
||||
import binascii.BinAscii;
|
||||
import com.fluxlus.V2Gdecoder.binascii.BinAscii;
|
||||
|
||||
/*
|
||||
* Copyright (C) V2Gdecoder by FlUxIuS (Sebastien Dudek)
|
||||
*/
|
||||
|
||||
public class dataprocess {
|
||||
public MessageHandler messageHandler;
|
||||
// public MessageHandler messageHandler;
|
||||
|
||||
public MessageHandler getMessageHandler() {
|
||||
return messageHandler;
|
||||
}
|
||||
// public MessageHandler getMessageHandler() {
|
||||
// return messageHandler;
|
||||
// }
|
||||
|
||||
public static void initConfig() {
|
||||
MiscUtils.setV2gEntityConfig("./test.properties");
|
||||
}
|
||||
// public static void initConfig() {
|
||||
// MiscUtils.loadProperties("./test.properties");
|
||||
// }
|
||||
|
||||
public static String Xml2Exi(String xmlstr, decodeMode mode) throws IOException, SAXException, EXIException {
|
||||
public static String Xml2Exi(String inputsc, String xmlstr, decodeMode mode, Grammars grammar) throws IOException, SAXException, EXIException {
|
||||
/*
|
||||
* Encode XML to EXI
|
||||
* In(1): XML string or input file path string
|
||||
|
@ -57,29 +58,13 @@ public class dataprocess {
|
|||
* Out: encoded result string
|
||||
* */
|
||||
EXIFactory exiFactory = DefaultEXIFactory.newInstance();
|
||||
String grammar = null;
|
||||
ByteArrayOutputStream bosEXI = null;
|
||||
OutputStream osEXI = null;
|
||||
String result = null;
|
||||
String inputsc = null;
|
||||
String outfile = null;
|
||||
|
||||
if (mode == decodeMode.FILETOSTR || mode == decodeMode.FILETOFILE)
|
||||
{ // In case the input is a file
|
||||
byte[] rbytes = Files.readAllBytes(Paths.get(xmlstr));
|
||||
inputsc = new String(rbytes);
|
||||
} else {
|
||||
inputsc = xmlstr;
|
||||
}
|
||||
if (inputsc.contains("supportedAppProtocol"))
|
||||
{ // select AppProtocol schema to set V2G grammar
|
||||
grammar = GlobalValues.SCHEMA_PATH_APP_PROTOCOL.toString();
|
||||
} else if (inputsc.contains("V2G_Message")) { // select XMLDSIG
|
||||
grammar = GlobalValues.SCHEMA_PATH_MSG_DEF.toString();
|
||||
} else { // MSG DEF by default
|
||||
grammar = GlobalValues.SCHEMA_PATH_XMLDSIG.toString();
|
||||
}
|
||||
exiFactory.setGrammars(GrammarFactory.newInstance().createGrammars("." + grammar));
|
||||
exiFactory.setGrammars(grammar);
|
||||
|
||||
EXIResult exiResult = new EXIResult(exiFactory);
|
||||
if (mode == decodeMode.FILETOSTR || mode == decodeMode.STRTOSTR)
|
||||
{ // stream output
|
||||
|
@ -112,7 +97,7 @@ public class dataprocess {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static String Exi2Xml(String existr, decodeMode mode, String grammar) throws IOException, SAXException, EXIException, TransformerException {
|
||||
public static String Exi2Xml(String existr, decodeMode mode, Grammars grammar) throws IOException, SAXException, EXIException, TransformerException {
|
||||
/*
|
||||
* Decode EXI data to XML
|
||||
* In(1): String to decode
|
||||
|
@ -126,7 +111,7 @@ public class dataprocess {
|
|||
Result res = null;
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
InputSource is = null;
|
||||
exiFactory.setGrammars(GrammarFactory.newInstance().createGrammars("." + grammar));
|
||||
exiFactory.setGrammars(grammar);
|
||||
|
||||
if (mode == decodeMode.FILETOSTR || mode == decodeMode.FILETOFILE)
|
||||
is = new InputSource(inputsc);
|
||||
|
@ -162,8 +147,8 @@ public class dataprocess {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String fuzzyExiDecoded(String strinput, decodeMode dmode)
|
||||
|
||||
public static String fuzzyExiEncoder(String xmlstr, decodeMode dmode, Grammars[] grammars) throws IOException, SAXException
|
||||
{
|
||||
/*
|
||||
* Enumerate V2G grammar to decode EXI data
|
||||
|
@ -171,20 +156,58 @@ public class dataprocess {
|
|||
* In(2): (decodeMode) Input/Output modes
|
||||
* Out: Decoded result string
|
||||
*/
|
||||
String grammar = null;
|
||||
|
||||
String result = null;
|
||||
String inputsc = null;
|
||||
Grammars grammar = null;
|
||||
|
||||
if (dmode == decodeMode.FILETOSTR || dmode == decodeMode.FILETOFILE)
|
||||
{ // In case the input is a file
|
||||
byte[] rbytes = Files.readAllBytes(Paths.get(xmlstr));
|
||||
inputsc = new String(rbytes);
|
||||
} else {
|
||||
inputsc = xmlstr;
|
||||
}
|
||||
|
||||
/* Selects grammar intelligenly */
|
||||
if (inputsc.contains("supportedAppProtocol"))
|
||||
{ // select AppProtocol schema to set V2G grammar
|
||||
grammar = grammars[1];
|
||||
} else if (inputsc.contains("V2G_Message")) { // select MSG DEF
|
||||
grammar = grammars[0];
|
||||
} else { // XMLDSIG by default
|
||||
grammar = grammars[2];
|
||||
}
|
||||
|
||||
try {
|
||||
result = Xml2Exi(inputsc, xmlstr, dmode, grammar);
|
||||
} catch(EXIException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String fuzzyExiDecoded(String strinput, decodeMode dmode, Grammars[] grammars)
|
||||
{
|
||||
/*
|
||||
* Enumerate V2G grammar to decode EXI data
|
||||
* In(1): Input string
|
||||
* In(2): (decodeMode) Input/Output modes
|
||||
* Out: Decoded result string
|
||||
*/
|
||||
|
||||
String result = null;
|
||||
|
||||
grammar = GlobalValues.SCHEMA_PATH_MSG_DEF.toString();
|
||||
try {
|
||||
result = Exi2Xml(strinput, dmode, grammar);
|
||||
result = Exi2Xml(strinput, dmode, grammars[0]);
|
||||
} catch (Exception e1) {
|
||||
try {
|
||||
grammar = GlobalValues.SCHEMA_PATH_APP_PROTOCOL.toString();
|
||||
result = Exi2Xml(strinput, dmode, grammar);
|
||||
result = Exi2Xml(strinput, dmode, grammars[1]);
|
||||
} catch (Exception e2) {
|
||||
grammar = GlobalValues.SCHEMA_PATH_XMLDSIG.toString();
|
||||
try {
|
||||
result = Exi2Xml(strinput, dmode, grammar);
|
||||
result = Exi2Xml(strinput, dmode, grammars[2]);
|
||||
} catch (EXIException e3) {
|
||||
// do nothing
|
||||
//e3.printStackTrace();
|
|
@ -1,4 +1,4 @@
|
|||
package dataprocess;
|
||||
package com.fluxlus.V2Gdecoder.dataprocess;
|
||||
|
||||
/*
|
||||
* Copyright (C) V2Gdecoder by FlUxIuS (Sebastien Dudek)
|
Binary file not shown.
|
@ -1,9 +1,10 @@
|
|||
package server;
|
||||
package com.fluxlus.V2Gdecoder.server;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.io.IOException;
|
||||
import com.siemens.ct.exi.core.grammars.Grammars;
|
||||
|
||||
/*
|
||||
* Copyright (C) V2Gdecoder by FlUxIuS (Sebastien Dudek)
|
||||
|
@ -15,9 +16,11 @@ public class MultiThreadedServer implements Runnable{
|
|||
protected ServerSocket serverSocket = null;
|
||||
protected boolean isStopped = false;
|
||||
protected Thread runningThread= null;
|
||||
protected Grammars[] grammars = null;
|
||||
|
||||
public MultiThreadedServer(int port){
|
||||
public MultiThreadedServer(int port, Grammars[] grammars){
|
||||
this.serverPort = port;
|
||||
this.grammars = grammars;
|
||||
}
|
||||
|
||||
public void run(){
|
||||
|
@ -39,7 +42,7 @@ public class MultiThreadedServer implements Runnable{
|
|||
}
|
||||
new Thread(
|
||||
new WorkerRunnable(
|
||||
clientSocket, "Multithreaded Server")
|
||||
clientSocket, this.grammars, "Multithreaded Server")
|
||||
).start();
|
||||
}
|
||||
System.out.println("Server Stopped.") ;
|
|
@ -1,4 +1,4 @@
|
|||
package server;
|
||||
package com.fluxlus.V2Gdecoder.server;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -11,19 +11,22 @@ import java.util.Map;
|
|||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.siemens.ct.exi.exceptions.EXIException;
|
||||
import com.siemens.ct.exi.core.exceptions.EXIException;
|
||||
import com.siemens.ct.exi.core.grammars.Grammars;
|
||||
|
||||
import dataprocess.dataprocess;
|
||||
import dataprocess.decodeMode;
|
||||
import com.fluxlus.V2Gdecoder.dataprocess.dataprocess;
|
||||
import com.fluxlus.V2Gdecoder.dataprocess.decodeMode;
|
||||
|
||||
public class WorkerRunnable implements Runnable{
|
||||
|
||||
protected Socket clientSocket = null;
|
||||
protected String serverText = null;
|
||||
protected Grammars[] grammars = null;
|
||||
|
||||
public WorkerRunnable(Socket clientSocket, String serverText) {
|
||||
public WorkerRunnable(Socket clientSocket, Grammars[] grammars, String serverText) {
|
||||
this.clientSocket = clientSocket;
|
||||
this.serverText = serverText;
|
||||
this.grammars = grammars;
|
||||
}
|
||||
|
||||
public static Map<String, String> parseHTTPHeaders(InputStream inputStream)
|
||||
|
@ -87,14 +90,11 @@ public class WorkerRunnable implements Runnable{
|
|||
|
||||
if (headers.get("Format").contains("EXI"))
|
||||
{
|
||||
result = dataprocess.fuzzyExiDecoded(body, decodeMode.STRTOSTR);
|
||||
result = dataprocess.fuzzyExiDecoded(body, decodeMode.STRTOSTR, this.grammars);
|
||||
} else {
|
||||
try {
|
||||
result = dataprocess.Xml2Exi(body, decodeMode.STRTOSTR);
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (EXIException e) {
|
||||
result = dataprocess.fuzzyExiEncoder(body, decodeMode.STRTOSTR, this.grammars);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
Loading…
Reference in New Issue