com.thaiopensource.validate.SchemaReaderLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wicketstuff-jing Show documentation
Show all versions of wicketstuff-jing Show documentation
Jing is a validator for RELAX NG and other schema languages. This
project was taken from http://code.google.com/p/jing-trang and
mavenized for inclusion in the Wicket Stuff HTML Validator.
The code was taken from the 20091111 release.
package com.thaiopensource.validate;
import com.thaiopensource.util.Service;
import java.util.Iterator;
/**
* A SchemaReaderFactory that automatically discovers SchemaReader implementations.
* For a SchemeaReader implementation to be discoverable by this class, it must have
* a factory class with a no-argument constructor implementing SchemaReaderFactory,
* and the fully-qualified name of this factory class must be listed in the file
* META-INF/services/com.thaiopensource.validate.SchemaReaderFactory
.
*/
public class SchemaReaderLoader implements SchemaReaderFactory {
private final Service service = Service.newInstance(SchemaReaderFactory.class);
public SchemaReader createSchemaReader(String namespaceUri) {
for (Iterator iter = service.getProviders(); iter.hasNext();) {
SchemaReaderFactory srf = iter.next();
SchemaReader sr = srf.createSchemaReader(namespaceUri);
if (sr != null)
return sr;
}
return null;
}
public Option getOption(String uri) {
for (Iterator iter = service.getProviders(); iter.hasNext();) {
SchemaReaderFactory srf = iter.next();
Option option = srf.getOption(uri);
if (option != null)
return option;
}
return null;
}
}