FileDocCategorySizeDatePackage
Entity.javaAPI DocJava SE 5 API3191Fri Aug 26 14:58:20 BST 2005javax.swing.text.html.parser

Entity

public final class Entity extends Object implements DTDConstants
An entity is described in a DTD using the ENTITY construct. It defines the type and value of the the entity.
see
DTD
version
1.10, 12/19/03
author
Arthur van Hoff

Fields Summary
public String
name
public int
type
public char[]
data
static Hashtable
entityTypes
Constructors Summary
public Entity(String name, int type, char[] data)
Creates an entity.

param
name the name of the entity
param
type the type of the entity
param
data the char array of data

	this.name = name;
	this.type = type;
	this.data = data;
    
Methods Summary
public char[]getData()
Returns the data.

return
the data

	return data;
    
public java.lang.StringgetName()
Gets the name of the entity.

return
the name of the entity, as a String

	return name;
    
public java.lang.StringgetString()
Returns the data as a String.

return
the data as a String

	return new String(data, 0, data.length);
    
public intgetType()
Gets the type of the entity.

return
the type of the entity

	return type & 0xFFFF;
    
public booleanisGeneral()
Returns true if it is a general entity.

return
true if it is a general entity

	return (type & GENERAL) != 0;
    
public booleanisParameter()
Returns true if it is a parameter entity.

return
true if it is a parameter entity

	return (type & PARAMETER) != 0;
    
public static intname2type(java.lang.String nm)
Converts nm string to the corresponding entity type. If the string does not have a corresponding entity type, returns the type corresponding to "CDATA". Valid entity types are: "PUBLIC", "CDATA", "SDATA", "PI", "STARTTAG", "ENDTAG", "MS", "MD", "SYSTEM".

param
nm the string to be converted
return
the corresponding entity type, or the type corresponding to "CDATA", if none exists


     
	entityTypes.put("PUBLIC", new Integer(PUBLIC));
	entityTypes.put("CDATA", new Integer(CDATA));
	entityTypes.put("SDATA", new Integer(SDATA));
	entityTypes.put("PI", new Integer(PI));
	entityTypes.put("STARTTAG", new Integer(STARTTAG));
	entityTypes.put("ENDTAG", new Integer(ENDTAG));
	entityTypes.put("MS", new Integer(MS));
	entityTypes.put("MD", new Integer(MD));
	entityTypes.put("SYSTEM", new Integer(SYSTEM));
    
	Integer i = (Integer)entityTypes.get(nm);
	return (i == null) ? CDATA : i.intValue();