All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thaiopensource.validate.SchemaReaderLoader Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.11
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy