Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Energy ADE
ADE Xjc
Commits
20a05bb4
Commit
20a05bb4
authored
Mar 12, 2010
by
Claus Nagel
Browse files
No commit message
No commit message
parent
0e9858d4
Changes
9
Hide whitespace changes
Inline
Side-by-side
.classpath
View file @
20a05bb4
...
...
@@ -7,7 +7,6 @@
<classpathentry
kind=
"lib"
path=
"lib/jaxb-xjc.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/jsr173_1.0_api.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/args4j-2.0.9.jar"
/>
<classpathentry
kind=
"lib"
path=
"lib/collection-setter-injector.jar"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
build.xml
View file @
20a05bb4
<?xml version="1.0" encoding="UTF-8"?>
<project
name=
"
citygml4j
"
default=
"dist"
basedir=
"."
>
<project
name=
"
ade-xjc
"
default=
"dist"
basedir=
"."
>
<!-- application specific variables -->
<property
name=
"app.name"
value=
"ade-xjc"
/>
...
...
@@ -13,11 +13,13 @@
<property
name=
"project.basedir"
location=
".."
/>
<property
name=
"src"
location=
"src"
/>
<property
name=
"lib"
location=
"lib"
/>
<property
name=
"schemas"
location=
"schemas"
/>
<property
name=
"sample"
location=
"sample"
/>
<property
name=
"resources"
location=
"resources"
/>
<property
name=
"resources.doc"
location=
"${resources}/doc"
/>
<property
name=
"resources.license"
location=
"${resources}/license"
/>
<property
name=
"resources.schemas"
location=
"${resources}/xml/schemas"
/>
<property
name=
"build"
location=
"build"
/>
<property
name=
"build.classes"
location=
"${build}/classes"
/>
...
...
@@ -25,6 +27,7 @@
<property
name=
"dist"
location=
"${app.name}-${app.version}"
/>
<property
name=
"dist.license"
location=
"${dist}/license"
/>
<property
name=
"dist.schemas"
location=
"${dist}/schemas"
/>
<property
name=
"dist.sample"
location=
"${dist}/sample"
/>
<!-- classpath -->
<path
id=
"classpath"
>
...
...
@@ -38,21 +41,23 @@
<target
name=
"clean"
description=
"clean up"
>
<!-- delete the ${build} and ${dist} directory trees -->
<delete
dir=
"${build}"
/>
<delete
dir=
"${dist.license}"
/>
<delete
dir=
"${dist.schemas}"
/>
<delete
dir=
"${dist.sample}"
/>
<delete
dir=
"${dist}"
/>
</target>
<target
name=
"
init
"
description=
"
init build environment
"
>
<
!-- create the build directory structure used by compile --
>
<target
name=
"
compile
"
description=
"
compile the source
"
>
<
delete
dir=
"${build}"
/
>
<mkdir
dir=
"${build.classes}"
/>
</target>
<target
name=
"compile"
depends=
"init"
description=
"compile the source"
>
<!-- compile the java code from ${src} and ${src-gen} into ${build} -->
<javac
classpathref=
"classpath"
srcdir=
"${src}"
destdir=
"${build.classes}"
/>
</target>
<target
name=
"dist"
depends=
"clean, compile"
description=
"generate the distribution"
>
<!-- create the distribution directory -->
<delete
dir=
"${dist}"
/>
<mkdir
dir=
"${dist}"
/>
<!-- copy LICENSE template -->
...
...
@@ -65,6 +70,11 @@
<fileset
dir=
"${resources.doc}"
includes=
"**/*"
/>
</copy>
<!-- copy sample -->
<copy
todir=
"${dist.sample}"
>
<fileset
dir=
"${sample}"
includes=
"**/*"
/>
</copy>
<!-- replace tokens in template files -->
<replace
file=
"${dist.license}/LICENSE"
token=
"!app.title!"
value=
"${app.title}"
/>
<replace
file=
"${dist.license}/LICENSE"
token=
"!app.name!"
value=
"${app.name}"
/>
...
...
@@ -72,11 +82,14 @@
<replace
file=
"${dist}/README"
token=
"!app.title!"
value=
"${app.title}"
/>
<replace
file=
"${dist}/README"
token=
"!app.jar!"
value=
"${app.jar}"
/>
<replace
file=
"${dist}/README"
token=
"!app.version!"
value=
"${app.version}"
/>
<replace
file=
"${dist.sample}/build.xml"
token=
"!app.jar!"
value=
"${app.jar}"
/>
<!-- copy schema files -->
<copy
todir=
"${dist.schemas}"
>
<fileset
dir=
"${
resources.
schemas}"
includes=
"**/*"
/>
<fileset
dir=
"${schemas}"
includes=
"**/*"
/>
</copy>
<buildnumber
file=
"build.num"
/>
<!-- put everything in ${build} into .jar file -->
<jar
jarfile=
"${dist}/${app.jar}"
basedir=
"${build.classes}"
filesetmanifest=
"mergewithoutmain"
>
...
...
lib/collection-setter-injector.jar
deleted
100644 → 0
View file @
0e9858d4
File deleted
resources/doc/README
View file @
20a05bb4
!app.name! v!app.version! - !app.title!
This
library
is free software and comes WITHOUT ANY WARRANTY.
This
program
is free software and comes WITHOUT ANY WARRANTY.
See the file LICENSE for more details.
...
...
@@ -20,7 +20,7 @@
1. Licence
----------
The !app.name!
Java class library
is free software under
The !app.name! is free software under
the GNU Lesser General Public License Version 3.0. See the file LICENSE
for more details. For a copy of the GNU Lesser General Public License see
the files COPYING and COPYING.LESSER or visit http://www.gnu.org/licenses/.
...
...
@@ -38,47 +38,43 @@ http://www.igg.tu-berlin.de/
3. About
--------
!app.name! is a Java class library and API for facilitating work with the
City Geography Markup Language (CityGML). It makes it easy to read, process,
and write CityGML datasets, and to develop CityGML-aware software
applications.
Feature list:
* Full support for CityGML version 1.0.0 and 0.4.0
* Support for CityGML specific subset of GML 3.1.1
* Support for the eXtensible Address Language (xAL)
* Support for user-defined CityGML Application Domain Extensions (ADE)
CityGML is a common information model for the representation of 3D urban
objects. It is realized as an open data model and XML-based format for the
storage and exchange of virtual 3D city models.
CityGML is implemented as an application schema for the Geography Markup
Language version 3.1.1 (GML3), the extendible international standard for
spatial data exchange issued by the Open Geospatial Consortium (OGC) and
the ISO TC211. CityGML is an official OGC standard and can be used
free of charge.
"!app.name!" is a command line tool and a wrapper for the XML Schema compiler
"xjc" shipped with JAXB. !app.name! compiles an arbitrary CityGML ADE Schema
to a set of corresponding JAXB classes. The resulting classes are automatically
derived from the JAXB classes shipped with citygml4j. Thus, the classes can
easily be used with the citygml4j library. However, this also requires the
citygml4j library on your classpath in order to use the compiled classes in
your application.
4. System requirements
----------------------
* Java JRE or JDK >= 1.5
*
Java Architecture for XML Binding (JAXB) >= 2.1.10
*
citygml4j library version !app.version!
5. How to use it
----------------
Simply modify your Java classpath to include the provided
!app.jar! file. Please make sure also to include the
required JAXB libraries on your application classpath.
!app.name! is a command line tool. In order to get a list of supported
arguments, invoke the tool in a shell environment like this:
> java -jar !app.jar! -help
The !app.name! compiler requires your ADE schema to point to the official
CityGML and GML schemas provided in the subfolder "schemas". So please
adapt all <xs:import> statements in your ADE schema accordingly before
invoking the !app.name! compiler!
Please find a sample ADE schema together with an ANT build file in the
subfolder "sample".
6. Developers
-------------
Claus Nagel <nagel@
igg.
tu-berlin.de>
Claus Nagel <
claus.
nagel@tu-berlin.de>
7. Contact
...
...
resources/license/LICENSE
View file @
20a05bb4
The !app.name!
!app.title!
is free software:
The
"
!app.name!
" program
is free software:
you can redistribute it and/or modify it under the terms of the
GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or
(at your option) any later version.
This
library
is distributed in the hope that it will be useful,
This
program
is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this
library
. If not, see
License along with this
program
. If not, see
<http://www.gnu.org/licenses/>.
\ No newline at end of file
src/org/citygml4j/ade_xjc/ADE_XJC.java
View file @
20a05bb4
...
...
@@ -5,7 +5,10 @@ import java.io.FileNotFoundException;
import
java.io.PrintStream
;
import
java.math.BigInteger
;
import
java.security.NoSuchAlgorithmException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
org.kohsuke.args4j.Argument
;
...
...
@@ -20,7 +23,7 @@ import com.sun.tools.xjc.api.SchemaCompiler;
import
com.sun.tools.xjc.api.XJC
;
public
class
ADE_XJC
{
private
static
final
Logger
LOG
=
Logger
.
getInstance
(
);
private
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
// some dirs we will need
private
File
schema_dir
=
new
File
(
"schemas"
);
...
...
@@ -63,8 +66,16 @@ public class ADE_XJC {
CmdLineParser
parser
=
new
CmdLineParser
(
this
);
parser
.
setUsageWidth
(
80
);
List
<
String
>
tmp
=
new
ArrayList
<
String
>();
for
(
String
arg
:
args
)
tmp
.
addAll
(
Arrays
.
asList
(
arg
.
split
(
" +"
)));
String
[]
newArgs
=
new
String
[
tmp
.
size
()];
for
(
int
i
=
0
;
i
<
tmp
.
size
();
i
++)
newArgs
[
i
]
=
tmp
.
get
(
i
);
try
{
parser
.
parseArgument
(
a
rgs
);
parser
.
parseArgument
(
newA
rgs
);
}
catch
(
CmdLineException
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
printUsage
(
parser
,
System
.
err
);
...
...
@@ -94,33 +105,33 @@ public class ADE_XJC {
System
.
exit
(
1
);
}
LOG
.
info
(
"Starting ade-xjc compiler"
);
log
(
LogLevel
.
INFO
,
"Starting ade-xjc compiler"
);
adeSchemaFile
=
new
File
(
adeSchemaFileList
.
get
(
0
));
int
status
=
0
;
try
{
LOG
.
info
(
"Setting up build environment"
);
log
(
LogLevel
.
INFO
,
"Setting up build environment"
);
checkBuildEnvironment
();
if
(
clean
)
{
LOG
.
info
(
"Cleaning output folder"
);
log
(
LogLevel
.
INFO
,
"Cleaning output folder"
);
Util
.
rmdir
(
outputFolder
);
}
createBuildEnvironment
();
if
(
packageName
.
startsWith
(
"org.citygml4j"
))
{
LOG
.
error
(
"The package "
+
packageName
+
" is not allowed for the ADE classes"
);
LOG
.
error
(
"Choose a package which is not a subpackage of org.citygml4j. Aborting."
);
log
(
LogLevel
.
ERROR
,
"The package "
+
packageName
+
" is not allowed for the ADE classes"
);
log
(
LogLevel
.
ERROR
,
"Choose a package which is not a subpackage of org.citygml4j. Aborting."
);
System
.
exit
(
1
);
}
LOG
.
info
(
"Using ADE schema "
+
adeSchemaFile
.
getCanonicalFile
());
log
(
LogLevel
.
INFO
,
"Using ADE schema "
+
adeSchemaFile
.
getCanonicalFile
());
if
(
adeBindingFile
!=
null
)
LOG
.
info
(
"Using JAXB binding "
+
adeBindingFile
.
getCanonicalFile
());
log
(
LogLevel
.
INFO
,
"Using JAXB binding "
+
adeBindingFile
.
getCanonicalFile
());
LOG
.
info
(
"Using Java package "
+
packageName
+
" for JAXB classes"
);
LOG
.
info
(
"Generating JAXB classes. This may take some time..."
);
log
(
LogLevel
.
INFO
,
"Using Java package "
+
packageName
+
" for JAXB classes"
);
log
(
LogLevel
.
INFO
,
"Generating JAXB classes. This may take some time..."
);
SchemaCompiler
sc
=
XJC
.
createSchemaCompiler
();
sc
.
setDefaultPackageName
(
packageName
);
...
...
@@ -140,12 +151,12 @@ public class ADE_XJC {
code
.
build
(
outputFolder
,
(
PrintStream
)
null
);
File
packageDir
=
new
File
(
outputFolder
.
getAbsolutePath
());
LOG
.
info
(
"JAXB classes successfully written to "
+
packageDir
.
getCanonicalPath
());
log
(
LogLevel
.
INFO
,
"JAXB classes successfully written to "
+
packageDir
.
getCanonicalPath
());
}
catch
(
Exception
e
)
{
if
(
e
.
getMessage
()
!=
null
)
LOG
.
error
(
e
.
getMessage
());
log
(
LogLevel
.
ERROR
,
e
.
getMessage
());
LOG
.
error
(
"Unable to recover from previous error(s). Aborting."
);
log
(
LogLevel
.
ERROR
,
"Unable to recover from previous error(s). Aborting."
);
status
=
1
;
if
(
clean
)
...
...
@@ -178,7 +189,7 @@ public class ADE_XJC {
throw
new
FileNotFoundException
(
"Could not open folder "
+
schema_dir
.
getAbsolutePath
());
if
(!
nonStrict
)
{
LOG
.
info
(
"Running in strict mode. Checking sanity of subfolder 'schemas'"
);
log
(
LogLevel
.
INFO
,
"Running in strict mode. Checking sanity of subfolder 'schemas'"
);
BigInteger
md5
=
new
BigInteger
(
"0"
);
md5
=
Util
.
dir2md5
(
schema_dir
,
md5
);
...
...
@@ -208,4 +219,33 @@ public class ADE_XJC {
parser
.
printUsage
(
System
.
out
);
out
.
println
();
}
private
void
log
(
LogLevel
level
,
String
msg
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"["
)
.
append
(
df
.
format
(
new
Date
()))
.
append
(
" "
)
.
append
(
level
.
toString
())
.
append
(
"] "
)
.
append
(
msg
);
System
.
out
.
println
(
builder
.
toString
());
}
private
enum
LogLevel
{
INFO
(
"info"
),
WARN
(
"warn"
),
ERROR
(
"error"
);
private
String
value
;
LogLevel
(
String
value
)
{
this
.
value
=
value
;
}
public
String
toString
()
{
return
value
;
}
}
}
src/org/citygml4j/ade_xjc/Logger.java
deleted
100644 → 0
View file @
0e9858d4
package
org.citygml4j.ade_xjc
;
import
java.text.DecimalFormat
;
import
java.util.Calendar
;
public
class
Logger
{
private
static
Logger
INSTANCE
=
new
Logger
();
private
LogLevelType
logLevel
=
LogLevelType
.
INFO
;
private
Calendar
cal
;
private
DecimalFormat
df
=
new
DecimalFormat
(
"00"
);
private
Logger
()
{
// just to thwart instantiation
}
public
static
Logger
getInstance
()
{
return
INSTANCE
;
}
public
void
setLogLevel
(
LogLevelType
logLevel
)
{
this
.
logLevel
=
logLevel
;
}
public
String
getPrefix
(
LogLevelType
type
)
{
cal
=
Calendar
.
getInstance
();
int
h
=
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
m
=
cal
.
get
(
Calendar
.
MINUTE
);
int
s
=
cal
.
get
(
Calendar
.
SECOND
);
StringBuffer
prefix
=
new
StringBuffer
();
prefix
.
append
(
"["
);
prefix
.
append
(
df
.
format
(
h
));
prefix
.
append
(
":"
);
prefix
.
append
(
df
.
format
(
m
));
prefix
.
append
(
":"
);
prefix
.
append
(
df
.
format
(
s
));
prefix
.
append
(
" "
);
prefix
.
append
(
type
.
value
);
prefix
.
append
(
"] "
);
return
prefix
.
toString
();
}
private
void
log
(
LogLevelType
type
,
String
msg
)
{
System
.
out
.
println
(
getPrefix
(
type
)
+
msg
);
}
public
void
debug
(
String
msg
)
{
if
(
logLevel
.
ordinal
()
<=
LogLevelType
.
DEBUBG
.
ordinal
())
log
(
LogLevelType
.
DEBUBG
,
msg
);
}
public
void
info
(
String
msg
)
{
if
(
logLevel
.
ordinal
()
<=
LogLevelType
.
INFO
.
ordinal
())
log
(
LogLevelType
.
INFO
,
msg
);
}
public
void
warn
(
String
msg
)
{
if
(
logLevel
.
ordinal
()
<=
LogLevelType
.
WARN
.
ordinal
())
log
(
LogLevelType
.
WARN
,
msg
);
}
public
void
error
(
String
msg
)
{
if
(
logLevel
.
ordinal
()
<=
LogLevelType
.
ERROR
.
ordinal
())
log
(
LogLevelType
.
ERROR
,
msg
);
}
public
enum
LogLevelType
{
DEBUBG
(
"DEBUG"
),
INFO
(
"INFO"
),
WARN
(
"WARN"
),
ERROR
(
"ERROR"
);
private
final
String
value
;
LogLevelType
(
String
v
)
{
value
=
v
;
}
public
String
value
()
{
return
value
;
}
};
}
src/org/citygml4j/ade_xjc/Util.java
View file @
20a05bb4
...
...
@@ -16,9 +16,7 @@ public class Util {
md5
=
string2md5
(
file
.
getName
(),
md5
);
if
(
file
.
isDirectory
())
{
File
[]
children
=
file
.
listFiles
(
new
FileFilter
()
{
@Override
File
[]
children
=
file
.
listFiles
(
new
FileFilter
()
{
public
boolean
accept
(
File
pathname
)
{
if
(
pathname
.
isDirectory
())
return
true
;
...
...
src/org/citygml4j/ade_xjc/XJCErrorListener.java
View file @
20a05bb4
...
...
@@ -6,22 +6,18 @@ import com.sun.tools.xjc.api.ErrorListener;
public
class
XJCErrorListener
implements
ErrorListener
{
@Override
public
void
error
(
SAXParseException
ex
)
{
ex
.
printStackTrace
();
}
@Override
public
void
fatalError
(
SAXParseException
ex
)
{
ex
.
printStackTrace
();
}
@Override
public
void
info
(
SAXParseException
ex
)
{
ex
.
printStackTrace
();
}
@Override
public
void
warning
(
SAXParseException
ex
)
{
ex
.
printStackTrace
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment