Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
QualityADE
Commits
4ef4c11f
Commit
4ef4c11f
authored
Apr 12, 2022
by
Matthias Betz
Browse files
added type adapters
added validation tests
parent
5fe70e14
Changes
74
Hide whitespace changes
Inline
Side-by-side
citygml4j-quality-ade/pom.xml
View file @
4ef4c11f
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
de.hft.stuttgart
</groupId>
<artifactId>
citygml4j-quality-ade
</artifactId>
<version>
0
.1.
3
</version>
<version>
3
.1.
4
</version>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
...
...
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/properties/ValidationResultPropertyAdapter.java
0 → 100644
View file @
4ef4c11f
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* 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
de.hft.stuttgart.quality.adapter.properties
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.gml.adapter.base.AbstractInlineOrByReferencePropertyAdapter
;
import
de.hft.stuttgart.quality.model.properties.ValidationResultProperty
;
public
class
ValidationResultPropertyAdapter
extends
AbstractInlineOrByReferencePropertyAdapter
<
ValidationResultProperty
>
{
@Override
public
ValidationResultProperty
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
ValidationResultProperty
();
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
de.hft.stuttgart.quality.model.types.AbstractError
;
public
abstract
class
AbstractErrorAdapter
<
T
extends
AbstractError
>
implements
ObjectBuilder
<
T
>,
ObjectSerializer
<
T
>
{
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractGeometryErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
de.hft.stuttgart.quality.model.types.AbstractGeometryError
;
public
abstract
class
AbstractGeometryErrorAdapter
<
T
extends
AbstractGeometryError
>
extends
AbstractErrorAdapter
<
T
>
{
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractPolygonErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.AbstractPolygonError
;
public
abstract
class
AbstractPolygonErrorAdapter
<
T
extends
AbstractPolygonError
>
extends
AbstractGeometryErrorAdapter
<
T
>
{
@Override
public
void
buildChildObject
(
AbstractPolygonError
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"polygonId"
->
reader
.
getTextContent
().
ifPresent
(
object:
:
setPolygonId
);
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building AbstractPolygonError element"
);
}
}
@Override
public
void
writeChildElements
(
AbstractPolygonError
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getPolygonId
()
!=
null
)
{
writer
.
writeElement
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"polygonId"
).
addTextContent
(
object
.
getPolygonId
()));
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractRingErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.AbstractRingError
;
public
abstract
class
AbstractRingErrorAdapter
<
T
extends
AbstractRingError
>
extends
AbstractGeometryErrorAdapter
<
T
>
{
@Override
public
void
buildChildObject
(
AbstractRingError
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"linearRingId"
->
reader
.
getTextContent
().
ifPresent
(
object:
:
setLinearRingId
);
}
}
@Override
public
void
writeChildElements
(
AbstractRingError
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getLinearRingId
()
!=
null
)
{
writer
.
writeElement
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"linearRingId"
).
addTextContent
(
object
.
getLinearRingId
()));
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractSemanticErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
de.hft.stuttgart.quality.model.types.AbstractSemanticError
;
public
abstract
class
AbstractSemanticErrorAdapter
<
T
extends
AbstractSemanticError
>
extends
AbstractErrorAdapter
<
T
>
{
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AbstractSolidErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.AbstractSolidError
;
public
abstract
class
AbstractSolidErrorAdapter
<
T
extends
AbstractSolidError
>
extends
AbstractGeometryErrorAdapter
<
T
>
{
@Override
public
void
buildChildObject
(
AbstractSolidError
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"geometryId"
->
reader
.
getTextContent
().
ifPresent
(
object:
:
setGeometryId
);
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building AbstractSolidError element"
);
}
}
@Override
public
void
writeChildElements
(
AbstractSolidError
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getGeometryId
()
!=
null
)
{
writer
.
writeElement
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"geometryId"
).
addTextContent
(
object
.
getGeometryId
()));
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/AllPolygonsOrientedWrongErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.AllPolygonsOrientedWrongError
;
@XMLElement
(
name
=
"GE_S_ALL_POLYGONS_WRONG_ORIENTATION"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
AllPolygonsOrientedWrongErrorAdapter
extends
AbstractSolidErrorAdapter
<
AllPolygonsOrientedWrongError
>
{
@Override
public
AllPolygonsOrientedWrongError
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
AllPolygonsOrientedWrongError
();
}
@Override
public
Element
createElement
(
AllPolygonsOrientedWrongError
object
,
Namespaces
namespaces
)
throws
ObjectSerializeException
{
return
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"GE_S_ALL_POLYGONS_WRONG_ORIENTATION"
);
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/CheckingAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
de.hft.stuttgart.quality.model.enums.TopLevelFeatureType
;
import
de.hft.stuttgart.quality.model.types.Checking
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
javax.xml.namespace.QName
;
@XMLElement
(
name
=
"Checking"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
CheckingAdapter
implements
ObjectBuilder
<
Checking
>,
ObjectSerializer
<
Checking
>
{
@Override
public
Checking
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
Checking
();
}
@Override
public
void
buildChildObject
(
Checking
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"featureType"
->
reader
.
getTextContent
()
.
ifPresent
(
s
->
object
.
setFeatureType
(
TopLevelFeatureType
.
valueOf
(
s
)));
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building Checking element"
);
}
}
@Override
public
Element
createElement
(
Checking
object
,
Namespaces
namespaces
)
throws
ObjectSerializeException
{
return
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"Checking"
);
}
@Override
public
void
writeChildElements
(
Checking
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getFeatureType
()
!=
null
)
{
writer
.
writeElement
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"featureType"
)
.
addTextContent
(
object
.
getFeatureType
().
toString
()));
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/CityObjectPropertiesAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.adapter.properties.ValidationResultPropertyAdapter
;
import
de.hft.stuttgart.quality.model.types.CityObjectProperties
;
@XMLElement
(
name
=
"validationResult"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
CityObjectPropertiesAdapter
implements
ObjectBuilder
<
CityObjectProperties
>,
ObjectSerializer
<
CityObjectProperties
>
{
@Override
public
CityObjectProperties
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
CityObjectProperties
();
}
@Override
public
void
buildChildObject
(
CityObjectProperties
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"validationResult"
->
object
.
setValidationResult
(
reader
.
getObjectUsingBuilder
(
ValidationResultPropertyAdapter
.
class
));
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building CityObjectProperties element"
);
}
}
@Override
public
void
writeChildElements
(
CityObjectProperties
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getValidationResult
()
!=
null
)
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"validationResult"
),
object
.
getValidationResult
(),
ValidationResultPropertyAdapter
.
class
,
namespaces
);
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/ComponentListAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.adapter.properties.PolygonIdListPropertyAdapter
;
import
de.hft.stuttgart.quality.model.properties.PolygonIdListProperty
;
import
de.hft.stuttgart.quality.model.types.ComponentList
;
@XMLElement
(
name
=
"ComponentList"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
ComponentListAdapter
implements
ObjectBuilder
<
ComponentList
>,
ObjectSerializer
<
ComponentList
>
{
@Override
public
ComponentList
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
ComponentList
();
}
@Override
public
void
buildChildObject
(
ComponentList
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"component"
->
object
.
getComponents
()
.
add
(
reader
.
getObjectUsingBuilder
(
PolygonIdListPropertyAdapter
.
class
));
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building ComponentList element"
);
}
}
@Override
public
Element
createElement
(
ComponentList
object
,
Namespaces
namespaces
)
throws
ObjectSerializeException
{
return
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"ComponentList"
);
}
@Override
public
void
writeChildElements
(
ComponentList
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
for
(
PolygonIdListProperty
listProperty
:
object
.
getComponents
())
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"component"
),
listProperty
,
PolygonIdListPropertyAdapter
.
class
,
namespaces
);
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/ConsecutivePointsSameErrorAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.gml.adapter.geometry.DirectPositionAdapter
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.ConsecutivePointsSameError
;
@XMLElement
(
name
=
"GE_R_CONSECUTIVE_POINTS_SAME"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
ConsecutivePointsSameErrorAdapter
extends
AbstractRingErrorAdapter
<
ConsecutivePointsSameError
>
{
@Override
public
ConsecutivePointsSameError
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
ConsecutivePointsSameError
();
}
@Override
public
void
buildChildObject
(
ConsecutivePointsSameError
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"vertex1"
->
object
.
setVertex1
(
reader
.
getObjectUsingBuilder
(
DirectPositionAdapter
.
class
));
case
"vertex2"
->
object
.
setVertex2
(
reader
.
getObjectUsingBuilder
(
DirectPositionAdapter
.
class
));
default
->
super
.
buildChildObject
(
object
,
name
,
attributes
,
reader
);
}
}
@Override
public
Element
createElement
(
ConsecutivePointsSameError
object
,
Namespaces
namespaces
)
throws
ObjectSerializeException
{
return
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"GE_R_CONSECUTIVE_POINTS_SAME"
);
}
@Override
public
void
writeChildElements
(
ConsecutivePointsSameError
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
super
.
writeChildElements
(
object
,
namespaces
,
writer
);
if
(
object
.
getVertex1
()
!=
null
)
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"vertex1"
),
object
.
getVertex1
(),
DirectPositionAdapter
.
class
,
namespaces
);
}
if
(
object
.
getVertex2
()
!=
null
)
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"vertex2"
),
object
.
getVertex2
(),
DirectPositionAdapter
.
class
,
namespaces
);
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/EdgeAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.gml.adapter.geometry.DirectPositionAdapter
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.model.types.Edge
;
@XMLElement
(
name
=
"Edge"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
EdgeAdapter
implements
ObjectBuilder
<
Edge
>,
ObjectSerializer
<
Edge
>
{
@Override
public
Edge
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
Edge
();
}
@Override
public
void
buildChildObject
(
Edge
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"from"
->
object
.
setFrom
(
reader
.
getObjectUsingBuilder
(
DirectPositionAdapter
.
class
));
case
"to"
->
object
.
setTo
(
reader
.
getObjectUsingBuilder
(
DirectPositionAdapter
.
class
));
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building Edge element"
);
}
}
@Override
public
Element
createElement
(
Edge
object
,
Namespaces
namespaces
)
throws
ObjectSerializeException
{
return
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"Edge"
);
}
@Override
public
void
writeChildElements
(
Edge
object
,
Namespaces
namespaces
,
XMLWriter
writer
)
throws
ObjectSerializeException
,
XMLWriteException
{
if
(
object
.
getFrom
()
!=
null
)
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"from"
),
object
.
getFrom
(),
DirectPositionAdapter
.
class
,
namespaces
);
}
if
(
object
.
getTo
()
!=
null
)
{
writer
.
writeElementUsingSerializer
(
Element
.
of
(
QualityADEModule
.
NAMESPACE_URI
,
"to"
),
object
.
getTo
(),
DirectPositionAdapter
.
class
,
namespaces
);
}
}
}
citygml4j-quality-ade/src/main/java/de/hft/stuttgart/quality/adapter/types/EdgeListAdapter.java
0 → 100644
View file @
4ef4c11f
package
de.hft.stuttgart.quality.adapter.types
;
import
javax.xml.namespace.QName
;
import
org.xmlobjects.annotation.XMLElement
;
import
org.xmlobjects.builder.ObjectBuildException
;
import
org.xmlobjects.builder.ObjectBuilder
;
import
org.xmlobjects.serializer.ObjectSerializeException
;
import
org.xmlobjects.serializer.ObjectSerializer
;
import
org.xmlobjects.stream.XMLReadException
;
import
org.xmlobjects.stream.XMLReader
;
import
org.xmlobjects.stream.XMLWriteException
;
import
org.xmlobjects.stream.XMLWriter
;
import
org.xmlobjects.xml.Attributes
;
import
org.xmlobjects.xml.Element
;
import
org.xmlobjects.xml.Namespaces
;
import
de.hft.stuttgart.quality.QualityADEModule
;
import
de.hft.stuttgart.quality.adapter.properties.EdgePropertyAdapter
;
import
de.hft.stuttgart.quality.model.properties.EdgeProperty
;
import
de.hft.stuttgart.quality.model.types.EdgeList
;
@XMLElement
(
name
=
"EdgeList"
,
namespaceURI
=
QualityADEModule
.
NAMESPACE_URI
)
public
class
EdgeListAdapter
implements
ObjectBuilder
<
EdgeList
>,
ObjectSerializer
<
EdgeList
>
{
@Override
public
EdgeList
createObject
(
QName
name
,
Object
parent
)
throws
ObjectBuildException
{
return
new
EdgeList
();
}
@Override
public
void
buildChildObject
(
EdgeList
object
,
QName
name
,
Attributes
attributes
,
XMLReader
reader
)
throws
ObjectBuildException
,
XMLReadException
{
if
(!
QualityADEModule
.
NAMESPACE_URI
.
equals
(
name
.
getNamespaceURI
()))
{
return
;
}
switch
(
name
.
getLocalPart
())
{
case
"edge"
->
object
.
getEdges
().
add
(
reader
.
getObjectUsingBuilder
(
EdgePropertyAdapter
.
class
));
default
->
throw
new
IllegalStateException
(
"Cannot handle name "
+
name
+
" when building EdgeList element"
);
}