下面列出了怎么用javax.xml.bind.Unmarshaller.Listener的API类实例代码及写法,或者点击链接到github查看源代码。
static <T extends Persistable> ReTestXmlDataContainer<T> migrateAndRead( final XmlTransformer xml,
final NamedBufferedInputStream inputStream, final Listener unmarshallListener ) throws IOException {
NamedBufferedInputStream bin = inputStream;
final XmlVersionCheckResult checkResult = XmlVersionCheckResult.create( bin );
if ( checkResult.newDataTypeInstance == null ) {
throw new RuntimeException( "Unexpected data type " + checkResult.oldDataType );
}
if ( !checkResult.isCompatible() ) {
bin = XmlMigrator.tryToMigrate( checkResult, bin );
if ( bin == null ) {
throw new RuntimeException( "Could not migrate XML." );
}
}
return xml.fromXML( bin, unmarshallListener );
}
public static synchronized void afterUnmarshal(ArrayList<?> list) {
for (Object object : list) {
if(object instanceof Listener)
((Listener) object).afterUnmarshal(null, null);
}
}
public static synchronized void afterUnmarshal(Object object) {
if(object instanceof Listener)
((Listener) object).afterUnmarshal(null, null);
}