< prev index next >
src/java.desktop/share/classes/javax/swing/text/html/parser/DTD.java
Print this page
*** 144,154 ****
*/
public static final int FILE_VERSION = 1;
/**
* Creates a new DTD with the specified name.
! * @param name the name, as a <code>String</code> of the new DTD
*/
protected DTD(String name) {
this.name = name;
defEntity("#RE", GENERAL, '\r');
defEntity("#RS", GENERAL, '\n');
--- 144,154 ----
*/
public static final int FILE_VERSION = 1;
/**
* Creates a new DTD with the specified name.
! * @param name the name, as a {@code String} of the new DTD
*/
protected DTD(String name) {
this.name = name;
defEntity("#RE", GENERAL, '\r');
defEntity("#RS", GENERAL, '\n');
*** 165,210 ****
}
/**
* Gets an entity by name.
* @param name the entity name
! * @return the <code>Entity</code> corresponding to the
! * <code>name</code> <code>String</code>
*/
public Entity getEntity(String name) {
return entityHash.get(name);
}
/**
* Gets a character entity.
* @param ch the character
! * @return the <code>Entity</code> corresponding to the
! * <code>ch</code> character
*/
public Entity getEntity(int ch) {
return entityHash.get(Integer.valueOf(ch));
}
/**
! * Returns <code>true</code> if the element is part of the DTD,
! * otherwise returns <code>false</code>.
*
! * @param name the requested <code>String</code>
! * @return <code>true</code> if <code>name</code> exists as
! * part of the DTD, otherwise returns <code>false</code>
*/
boolean elementExists(String name) {
return !"unknown".equals(name) && (elementHash.get(name) != null);
}
/**
* Gets an element by name. A new element is
* created if the element doesn't exist.
*
! * @param name the requested <code>String</code>
! * @return the <code>Element</code> corresponding to
! * <code>name</code>, which may be newly created
*/
public Element getElement(String name) {
Element e = elementHash.get(name);
if (e == null) {
e = new Element(name, elements.size());
--- 165,210 ----
}
/**
* Gets an entity by name.
* @param name the entity name
! * @return the {@code Entity} corresponding to the
! * {@code name String}
*/
public Entity getEntity(String name) {
return entityHash.get(name);
}
/**
* Gets a character entity.
* @param ch the character
! * @return the {@code Entity} corresponding to the
! * {@code ch} character
*/
public Entity getEntity(int ch) {
return entityHash.get(Integer.valueOf(ch));
}
/**
! * Returns {@code true} if the element is part of the DTD,
! * otherwise returns {@code false}.
*
! * @param name the requested {@code String}
! * @return {@code true} if {@code name} exists as
! * part of the DTD, otherwise returns {@code false}
*/
boolean elementExists(String name) {
return !"unknown".equals(name) && (elementHash.get(name) != null);
}
/**
* Gets an element by name. A new element is
* created if the element doesn't exist.
*
! * @param name the requested {@code String}
! * @return the {@code Element} corresponding to
! * {@code name}, which may be newly created
*/
public Element getElement(String name) {
Element e = elementHash.get(name);
if (e == null) {
e = new Element(name, elements.size());
*** 216,242 ****
/**
* Gets an element by index.
*
* @param index the requested index
! * @return the <code>Element</code> corresponding to
! * <code>index</code>
*/
public Element getElement(int index) {
return elements.elementAt(index);
}
/**
! * Defines an entity. If the <code>Entity</code> specified
! * by <code>name</code>, <code>type</code>, and <code>data</code>
! * exists, it is returned; otherwise a new <code>Entity</code>
* is created and is returned.
*
! * @param name the name of the <code>Entity</code> as a <code>String</code>
! * @param type the type of the <code>Entity</code>
! * @param data the <code>Entity</code>'s data
! * @return the <code>Entity</code> requested or a new <code>Entity</code>
* if not found
*/
public Entity defineEntity(String name, int type, char data[]) {
Entity ent = entityHash.get(name);
if (ent == null) {
--- 216,242 ----
/**
* Gets an element by index.
*
* @param index the requested index
! * @return the {@code Element} corresponding to
! * {@code index}
*/
public Element getElement(int index) {
return elements.elementAt(index);
}
/**
! * Defines an entity. If the {@code Entity} specified
! * by {@code name}, {@code type}, and {@code data}
! * exists, it is returned; otherwise a new {@code Entity}
* is created and is returned.
*
! * @param name the name of the {@code Entity} as a {@code String}
! * @param type the type of the {@code Entity}
! * @param data the {@code Entity}'s data
! * @return the {@code Entity} requested or a new {@code Entity}
* if not found
*/
public Entity defineEntity(String name, int type, char data[]) {
Entity ent = entityHash.get(name);
if (ent == null) {
*** 253,276 ****
}
return ent;
}
/**
! * Returns the <code>Element</code> which matches the
* specified parameters. If one doesn't exist, a new
* one is created and returned.
*
! * @param name the name of the <code>Element</code>
! * @param type the type of the <code>Element</code>
! * @param omitStart <code>true</code> if start should be omitted
! * @param omitEnd <code>true</code> if end should be omitted
! * @param content the <code>ContentModel</code>
* @param exclusions the set of elements that must not occur inside the element
* @param inclusions the set of elements that can occur inside the element
! * @param atts the <code>AttributeList</code> specifying the
! * <code>Element</code>
! * @return the <code>Element</code> specified
*/
public Element defineElement(String name, int type,
boolean omitStart, boolean omitEnd, ContentModel content,
BitSet exclusions, BitSet inclusions, AttributeList atts) {
Element e = getElement(name);
--- 253,276 ----
}
return ent;
}
/**
! * Returns the {@code Element} which matches the
* specified parameters. If one doesn't exist, a new
* one is created and returned.
*
! * @param name the name of the {@code Element}
! * @param type the type of the {@code Element}
! * @param omitStart {@code true} if start should be omitted
! * @param omitEnd {@code true} if end should be omitted
! * @param content the {@code ContentModel}
* @param exclusions the set of elements that must not occur inside the element
* @param inclusions the set of elements that can occur inside the element
! * @param atts the {@code AttributeList} specifying the
! * {@code Element}
! * @return the {@code Element} specified
*/
public Element defineElement(String name, int type,
boolean omitStart, boolean omitEnd, ContentModel content,
BitSet exclusions, BitSet inclusions, AttributeList atts) {
Element e = getElement(name);
*** 285,340 ****
}
/**
* Defines attributes for an {@code Element}.
*
! * @param name the name of the <code>Element</code>
! * @param atts the <code>AttributeList</code> specifying the
! * <code>Element</code>
*/
public void defineAttributes(String name, AttributeList atts) {
Element e = getElement(name);
e.atts = atts;
}
/**
! * Creates and returns a character <code>Entity</code>.
* @param name the entity's name
* @param type the entity's type
* @param ch the entity's value (character)
! * @return the new character <code>Entity</code>
*/
public Entity defEntity(String name, int type, int ch) {
char data[] = {(char)ch};
return defineEntity(name, type, data);
}
/**
! * Creates and returns an <code>Entity</code>.
* @param name the entity's name
* @param type the entity's type
* @param str the entity's data section
! * @return the new <code>Entity</code>
*/
protected Entity defEntity(String name, int type, String str) {
int len = str.length();
char data[] = new char[len];
str.getChars(0, len, data, 0);
return defineEntity(name, type, data);
}
/**
! * Creates and returns an <code>Element</code>.
* @param name the element's name
* @param type the element's type
* @param omitStart {@code true} if the element needs no starting tag
* @param omitEnd {@code true} if the element needs no closing tag
* @param content the element's content
* @param exclusions the elements that must be excluded from the content of the element
* @param inclusions the elements that can be included as the content of the element
* @param atts the attributes of the element
! * @return the new <code>Element</code>
*/
protected Element defElement(String name, int type,
boolean omitStart, boolean omitEnd, ContentModel content,
String[] exclusions, String[] inclusions, AttributeList atts) {
BitSet excl = null;
--- 285,340 ----
}
/**
* Defines attributes for an {@code Element}.
*
! * @param name the name of the {@code Element}
! * @param atts the {@code AttributeList} specifying the
! * {@code Element}
*/
public void defineAttributes(String name, AttributeList atts) {
Element e = getElement(name);
e.atts = atts;
}
/**
! * Creates and returns a character {@code Entity}.
* @param name the entity's name
* @param type the entity's type
* @param ch the entity's value (character)
! * @return the new character {@code Entity}
*/
public Entity defEntity(String name, int type, int ch) {
char data[] = {(char)ch};
return defineEntity(name, type, data);
}
/**
! * Creates and returns an {@code Entity}.
* @param name the entity's name
* @param type the entity's type
* @param str the entity's data section
! * @return the new {@code Entity}
*/
protected Entity defEntity(String name, int type, String str) {
int len = str.length();
char data[] = new char[len];
str.getChars(0, len, data, 0);
return defineEntity(name, type, data);
}
/**
! * Creates and returns an {@code Element}.
* @param name the element's name
* @param type the element's type
* @param omitStart {@code true} if the element needs no starting tag
* @param omitEnd {@code true} if the element needs no closing tag
* @param content the element's content
* @param exclusions the elements that must be excluded from the content of the element
* @param inclusions the elements that can be included as the content of the element
* @param atts the attributes of the element
! * @return the new {@code Element}
*/
protected Element defElement(String name, int type,
boolean omitStart, boolean omitEnd, ContentModel content,
String[] exclusions, String[] inclusions, AttributeList atts) {
BitSet excl = null;
*** 357,375 ****
}
return defineElement(name, type, omitStart, omitEnd, content, excl, incl, atts);
}
/**
! * Creates and returns an <code>AttributeList</code> responding to a new attribute.
* @param name the attribute's name
* @param type the attribute's type
* @param modifier the attribute's modifier
* @param value the default value of the attribute
* @param values the allowed values for the attribute (multiple values could be separated by '|')
* @param atts the previous attribute of the element; to be placed to {@code AttributeList.next},
* creating a linked list
! * @return the new <code>AttributeList</code>
*/
protected AttributeList defAttributeList(String name, int type, int modifier,
String value, String values, AttributeList atts) {
Vector<String> vals = null;
if (values != null) {
--- 357,375 ----
}
return defineElement(name, type, omitStart, omitEnd, content, excl, incl, atts);
}
/**
! * Creates and returns an {@code AttributeList} responding to a new attribute.
* @param name the attribute's name
* @param type the attribute's type
* @param modifier the attribute's modifier
* @param value the default value of the attribute
* @param values the allowed values for the attribute (multiple values could be separated by '|')
* @param atts the previous attribute of the element; to be placed to {@code AttributeList.next},
* creating a linked list
! * @return the new {@code AttributeList}
*/
protected AttributeList defAttributeList(String name, int type, int modifier,
String value, String values, AttributeList atts) {
Vector<String> vals = null;
if (values != null) {
*** 387,397 ****
/**
* Creates and returns a new content model.
* @param type the type of the new content model
* @param obj the content of the content model
* @param next pointer to the next content model
! * @return the new <code>ContentModel</code>
*/
protected ContentModel defContentModel(int type, Object obj, ContentModel next) {
return new ContentModel(type, obj, next);
}
--- 387,397 ----
/**
* Creates and returns a new content model.
* @param type the type of the new content model
* @param obj the content of the content model
* @param next pointer to the next content model
! * @return the new {@code ContentModel}
*/
protected ContentModel defContentModel(int type, Object obj, ContentModel next) {
return new ContentModel(type, obj, next);
}
*** 417,433 ****
public static void putDTDHash(String name, DTD dtd) {
getDtdHash().put(name, dtd);
}
/**
! * Returns a DTD with the specified <code>name</code>. If
* a DTD with that name doesn't exist, one is created
* and returned. Any uppercase characters in the name
* are converted to lowercase.
*
* @param name the name of the DTD
! * @return the DTD which corresponds to <code>name</code>
* @throws IOException if an I/O error occurs
*/
public static DTD getDTD(String name) throws IOException {
name = name.toLowerCase();
DTD dtd = getDtdHash().get(name);
--- 417,433 ----
public static void putDTDHash(String name, DTD dtd) {
getDtdHash().put(name, dtd);
}
/**
! * Returns a DTD with the specified {@code name}. If
* a DTD with that name doesn't exist, one is created
* and returned. Any uppercase characters in the name
* are converted to lowercase.
*
* @param name the name of the DTD
! * @return the DTD which corresponds to {@code name}
* @throws IOException if an I/O error occurs
*/
public static DTD getDTD(String name) throws IOException {
name = name.toLowerCase();
DTD dtd = getDtdHash().get(name);
*** 452,462 ****
return result;
}
/**
* Recreates a DTD from an archived format.
! * @param in the <code>DataInputStream</code> to read from
* @throws IOException if an I/O error occurs
*/
public void read(DataInputStream in) throws IOException {
if (in.readInt() != FILE_VERSION) {
}
--- 452,462 ----
return result;
}
/**
* Recreates a DTD from an archived format.
! * @param in the {@code DataInputStream} to read from
* @throws IOException if an I/O error occurs
*/
public void read(DataInputStream in) throws IOException {
if (in.readInt() != FILE_VERSION) {
}
< prev index next >