FileDocCategorySizeDatePackage
Schema.javaAPI DocAndroid 1.5 API4411Wed May 06 22:41:42 BST 2009org.ccil.cowan.tagsoup

Schema

public abstract class Schema extends Object
Abstract class representing a TSSL schema. Actual TSSL schemas are compiled into concrete subclasses of this class.

Fields Summary
public static final int
M_ANY
public static final int
M_EMPTY
public static final int
M_PCDATA
public static final int
M_ROOT
public static final int
F_RESTART
public static final int
F_CDATA
public static final int
F_NOFORCE
private HashMap
theEntities
private HashMap
theElementTypes
private String
theURI
private String
thePrefix
private ElementType
theRoot
Constructors Summary
Methods Summary
public voidattribute(java.lang.String elemName, java.lang.String attrName, java.lang.String type, java.lang.String value)
Add or replace a default attribute for an element type in this schema.

param
elemName Name (Qname) of the element type
param
attrName Name (Qname) of the attribute
param
type Type of the attribute
param
value Default value of the attribute; null if no default

		ElementType e = getElementType(elemName);
		if (e == null) {
			throw new Error("Attribute " + attrName +
				" specified for unknown element type " +
				elemName);
			}
		e.setAttribute(attrName, type, value);
		
public voidelementType(java.lang.String name, int model, int memberOf, int flags)
Add or replace an element type for this schema.

param
name Name (Qname) of the element
param
model Models of the element's content as a vector of bits
param
memberOf Models the element is a member of as a vector of bits
param
flags Flags for the element


		        	      	           	             	     	

	          
		ElementType e = new ElementType(name, model, memberOf, flags, this);
		theElementTypes.put(name.toLowerCase(), e);
		if (memberOf == M_ROOT) theRoot = e;
		
public voidentity(java.lang.String name, int value)
Add to or replace a character entity in this schema.

param
name Name of the entity
param
value Value of the entity

		theEntities.put(name, new Integer(value));
		
public ElementTypegetElementType(java.lang.String name)
Get an ElementType by name.

param
name Name (Qname) of the element type
return
The corresponding ElementType

		return (ElementType)(theElementTypes.get(name.toLowerCase()));
		
public intgetEntity(java.lang.String name)
Get an entity value by name.

param
name Name of the entity
return
The corresponding character, or 0 if none

//		System.err.println("%% Looking up entity " + name);
		Integer ch = (Integer)theEntities.get(name);
		if (ch == null) return 0;
		return ch.intValue();
		
public java.lang.StringgetPrefix()
Return the prefix of this schema.

		return thePrefix;
		
public java.lang.StringgetURI()
Return the URI (namespace name) of this schema.

		return theURI;
		
public voidparent(java.lang.String name, java.lang.String parentName)
Specify natural parent of an element in this schema.

param
name Name of the child element
param
parentName Name of the parent element

		ElementType child = getElementType(name);
		ElementType parent = getElementType(parentName);
		if (child == null) {
			throw new Error("No child " + name + " for parent " + parentName);
			}
		if (parent == null) {
			throw new Error("No parent " + parentName + " for child " + name);
			}
		child.setParent(parent);
		
public ElementTyperootElementType()
Get the root element of this schema

		return theRoot;
		
public voidsetPrefix(java.lang.String prefix)
Change the prefix of this schema.

		thePrefix = prefix;
		
public voidsetURI(java.lang.String uri)
Change the URI (namespace name) of this schema.

		theURI = uri;