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

com.thaiopensource.relaxng.pattern.NormalizedNameClass 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.relaxng.pattern;

import com.thaiopensource.xml.util.Name;

import java.util.Collections;
import java.util.Set;

/**
 * Base class for all implementations of com.thaiopensource.relaxng.match.NameClass.
 */
public abstract class NormalizedNameClass implements com.thaiopensource.relaxng.match.NameClass {
  private final Set includedNames;

  /**
   * Create a NormalizedNameClass representing a name class without any wildcards.
   * @param includedNames an immutable set of names
   */
  public NormalizedNameClass(Set includedNames) {
    this.includedNames = immutable(includedNames);
  }

  public boolean isEmpty() {
    return includedNames.isEmpty();
  }

  public boolean contains(Name name) {
    return includedNames.contains(name);
  }

  public boolean isAnyNameIncluded() {
    return false;
  }

  public Set getExcludedNamespaces() {
    return null;
  }

  public Set getIncludedNames() {
    return includedNames;
  }

  public Set getExcludedNames() {
    return null;
  }

  public Set getIncludedNamespaces() {
    return Collections.emptySet();
  }

  public Set getExcludedLocalNames(String ns) {
    return null;
  }

  public abstract boolean equals(Object obj);

  boolean equal(NormalizedNameClass nc1, NormalizedNameClass nc2) {
    return nc1.includedNames.equals(nc2.includedNames);
  }

  public int hashCode() {
    return includedNames.hashCode();
  }

   Set immutable(Set set) {
    if (set.isEmpty())
      return Collections.emptySet();
    return Collections.unmodifiableSet(set);
  }

  abstract boolean includesNamespace(String ns);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy