Commit 9416ebfb authored by Claus Nagel's avatar Claus Nagel
Browse files

switched to Gradle

parent e248ab95
......@@ -5,7 +5,7 @@
*
* ade-xjc is part of the citygml4j project
*
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
* Copyright 2013-2018 Claus Nagel <claus.nagel@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,8 +19,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<xs:schema xmlns="http://www.igg.tu-berlin.de/citygml4j/ade_hooks" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.igg.tu-berlin.de/citygml4j/ade_hooks"
<xs:schema xmlns="http://www.citygml4j.org/ade_hooks" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.citygml4j.org/ade_hooks"
xmlns:core1="http://www.opengis.net/citygml/1.0" xmlns:app1="http://www.opengis.net/citygml/appearance/1.0"
xmlns:bldg1="http://www.opengis.net/citygml/building/1.0" xmlns:frn1="http://www.opengis.net/citygml/cityfurniture/1.0"
xmlns:grp1="http://www.opengis.net/citygml/cityobjectgroup/1.0" xmlns:luse1="http://www.opengis.net/citygml/landuse/1.0"
......
......@@ -46,5 +46,5 @@
<xs:import namespace="http://www.opengis.net/citygml/waterbody/2.0" schemaLocation="2.0.0/waterBody.xsd"/>
<xs:import namespace="http://www.opengis.net/citygml/texturedsurface/2.0" schemaLocation="2.0.0/texturedSurface.xsd"/>
<!-- ade hooks -->
<xs:import namespace="http://www.igg.tu-berlin.de/citygml4j/ade_hooks" schemaLocation="ade_hooks/ade_hooks.xsd"/>
<xs:import namespace="http://www.citygml4j.org/ade_hooks" schemaLocation="ade_hooks/ade_hooks.xsd"/>
</xs:schema>
rootProject.name = 'ade-xjc'
......@@ -32,17 +32,17 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
private boolean recursive;
private boolean onlyEmptyDirs;
public FileDeleter(boolean recursive) {
FileDeleter(boolean recursive) {
this(recursive, false);
}
public FileDeleter(boolean recursive, boolean onlyEmptyDirs) {
FileDeleter(boolean recursive, boolean onlyEmptyDirs) {
this.recursive = recursive;
this.onlyEmptyDirs = onlyEmptyDirs;
}
boolean deleteFile(Path file) throws IOException {
return Files.deleteIfExists(file);
private void deleteFile(Path file) throws IOException {
Files.deleteIfExists(file);
}
@Override
......@@ -54,7 +54,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
return FileVisitResult.CONTINUE;
}
......@@ -77,7 +77,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
public FileVisitResult visitFileFailed(Path file, IOException exc) {
return FileVisitResult.CONTINUE;
}
......
/*
* ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc
*
* ade-xjc is part of the citygml4j project
*
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
*
* 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
*
* 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.citygml4j.ade_xjc;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Util {
public static BigInteger dir2md5(File file, BigInteger md5) throws NoSuchAlgorithmException, FileNotFoundException {
md5 = string2md5(file.getName(), md5);
if (file.isDirectory()) {
File[] children = file.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isDirectory())
return true;
if (pathname.getName().endsWith("xsd") || pathname.getName().endsWith("xjb"))
return true;
return false;
}
});
for (File next : children)
md5 = dir2md5(next, md5);
} else
md5 = file2md5(file.getAbsolutePath(), md5);
return md5;
}
public static BigInteger file2md5(String fileName, BigInteger md5) throws NoSuchAlgorithmException, FileNotFoundException {
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(new File(fileName));
byte[] buffer = new byte[8192];
int read = 0;
try {
while( (read = is.read(buffer)) > 0)
digest.update(buffer, 0, read);
byte[] md5sum = digest.digest();
return md5.xor(new BigInteger(1, md5sum));
} catch(IOException e) {
throw new RuntimeException("Unable to process file for MD5", e);
} finally {
try {
is.close();
}
catch(IOException e) {
throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
}
}
}
private static BigInteger string2md5(String input, BigInteger md5) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] md5sum = digest.digest(input.getBytes());
return md5.xor(new BigInteger(1, md5sum));
}
public static class URLClassLoader extends java.net.URLClassLoader {
protected URLClassLoader() {
super(new URL[]{}, Util.class.getClassLoader());
}
@Override
protected void addURL(URL url) {
super.addURL(url);
}
protected void addPath(Path path) {
try {
super.addURL(path.toUri().toURL());
} catch (MalformedURLException e) {
//
}
}
}
}
/*
* ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc
*
* ade-xjc is part of the citygml4j project
*
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
*
* 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
*
* 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.citygml4j.ade_xjc;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Util {
public static BigInteger dir2md5(File file, BigInteger md5) throws NoSuchAlgorithmException {
md5 = string2md5(file.getName(), md5);
if (file.isDirectory()) {
File[] children = file.listFiles(pathname -> pathname.isDirectory()
|| pathname.getName().endsWith("xsd")
|| pathname.getName().endsWith("xjb"));
if (children != null) {
for (File next : children)
md5 = dir2md5(next, md5);
}
} else
md5 = file2md5(file.getAbsolutePath(), md5);
return md5;
}
private static BigInteger file2md5(String fileName, BigInteger md5) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[8192];
int read;
try (InputStream is = new FileInputStream(new File(fileName))) {
while( (read = is.read(buffer)) > 0)
digest.update(buffer, 0, read);
byte[] md5sum = digest.digest();
return md5.xor(new BigInteger(1, md5sum));
} catch(IOException e) {
throw new RuntimeException("Unable to process file for MD5", e);
}
}
private static BigInteger string2md5(String input, BigInteger md5) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] md5sum = digest.digest(input.getBytes());
return md5.xor(new BigInteger(1, md5sum));
}
public static class URLClassLoader extends java.net.URLClassLoader {
URLClassLoader() {
super(new URL[]{}, ADESchemaCompiler.class.getClassLoader());
}
@Override
protected void addURL(URL url) {
super.addURL(url);
}
void addPath(Path path) {
try {
super.addURL(path.toUri().toURL());
} catch (MalformedURLException e) {
//
}
}
}
}
/*
* ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc
*
* ade-xjc is part of the citygml4j project
*
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
*
* 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
*
* 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.citygml4j.ade_xjc;
import org.xml.sax.SAXParseException;
import com.sun.tools.xjc.api.ErrorListener;
public class XJCErrorListener implements ErrorListener {
public void error(SAXParseException ex) {
ex.printStackTrace();
}
public void fatalError(SAXParseException ex) {
ex.printStackTrace();
}
public void info(SAXParseException ex) {
ex.printStackTrace();
}
public void warning(SAXParseException ex) {
ex.printStackTrace();
}
}
/*
* ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc
*
* ade-xjc is part of the citygml4j project
*
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
*
* 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
*
* 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.citygml4j.ade_xjc;
import org.xml.sax.SAXParseException;
import com.sun.tools.xjc.api.ErrorListener;
public class XJCErrorListener implements ErrorListener {
public void error(SAXParseException ex) {
ex.printStackTrace();
}
public void fatalError(SAXParseException ex) {
ex.printStackTrace();
}
public void info(SAXParseException ex) {
ex.printStackTrace();
}
public void warning(SAXParseException ex) {
ex.printStackTrace();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment