Entity (Java SE 26 & JDK 26)
Description: declaration: module: java.desktop, package: javax.swing.text.html.parser, class: Entity
Keywords: javax.swing.text.html.parser.Entity class

# Class Entity

java.lang.Object
javax.swing.text.html.parser.Entity

All Implemented Interfaces:
  `DTDConstants`

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 entity.

See Also:
  - `DTD`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `char[]`
  `data`
  The char array of data.
  `String`
  `name`
  The name of the entity.
  `int`
  `type`
  The type of the entity.

  ### Fields declared in interface DTDConstants

  `ANY, CDATA, CONREF, CURRENT, DEFAULT, EMPTY, ENDTAG, ENTITIES, ENTITY, FIXED, GENERAL, ID, IDREF, IDREFS, IMPLIED, MD, MODEL, MS, NAME, NAMES, NMTOKEN, NMTOKENS, NOTATION, NUMBER, NUMBERS, NUTOKEN, NUTOKENS, PARAMETER, PI, PUBLIC, RCDATA, REQUIRED, SDATA, STARTTAG, SYSTEM`
  Modifier and Type
  Field
  Description
  `static final int`
  `ANY`
  The DTD constant corresponds to ANY
  `static final int`
  `CDATA`
  The DTD constant corresponds to CDATA
  `static final int`
  `CONREF`
  The DTD constant corresponds to CONREF
  `static final int`
  `CURRENT`
  The DTD constant corresponds to CURRENT
  `static final int`
  `DEFAULT`
  The DTD constant corresponds to DEFAULT
  `static final int`
  `EMPTY`
  The DTD constant corresponds to EMPTY
  `static final int`
  `ENDTAG`
  The DTD constant corresponds to ENDTAG
  `static final int`
  `ENTITIES`
  The DTD constant corresponds to ENTITIES
  `static final int`
  `ENTITY`
  The DTD constant corresponds to ENTITY
  `static final int`
  `FIXED`
  The DTD constant corresponds to FIXED
  `static final int`
  `GENERAL`
  The DTD constant corresponds to GENERAL
  `static final int`
  `ID`
  The DTD constant corresponds to ID
  `static final int`
  `IDREF`
  The DTD constant corresponds to IDREF
  `static final int`
  `IDREFS`
  The DTD constant corresponds to IDREFS
  `static final int`
  `IMPLIED`
  The DTD constant corresponds to IMPLIED
  `static final int`
  `MD`
  The DTD constant corresponds to MD
  `static final int`
  `MODEL`
  The DTD constant corresponds to MODEL
  `static final int`
  `MS`
  The DTD constant corresponds to MS
  `static final int`
  `NAME`
  The DTD constant corresponds to NAME
  `static final int`
  `NAMES`
  The DTD constant corresponds to NAMES
  `static final int`
  `NMTOKEN`
  The DTD constant corresponds to NMTOKEN
  `static final int`
  `NMTOKENS`
  The DTD constant corresponds to NMTOKENS
  `static final int`
  `NOTATION`
  The DTD constant corresponds to NOTATION
  `static final int`
  `NUMBER`
  The DTD constant corresponds to NUMBER
  `static final int`
  `NUMBERS`
  The DTD constant corresponds to NUMBERS
  `static final int`
  `NUTOKEN`
  The DTD constant corresponds to NUTOKEN
  `static final int`
  `NUTOKENS`
  The DTD constant corresponds to NUTOKENS
  `static final int`
  `PARAMETER`
  The DTD constant corresponds to PARAMETER
  `static final int`
  `PI`
  The DTD constant corresponds to PI
  `static final int`
  `PUBLIC`
  The DTD constant corresponds to PUBLIC
  `static final int`
  `RCDATA`
  The DTD constant corresponds to RCDATA
  `static final int`
  `REQUIRED`
  The DTD constant corresponds to REQUIRED
  `static final int`
  `SDATA`
  The DTD constant corresponds to SDATA
  `static final int`
  `STARTTAG`
  The DTD constant corresponds to STARTTAG
  `static final int`
  `SYSTEM`
  The DTD constant corresponds to SYSTEM

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Entity(String name, int type, char[] data)`
  Creates an entity.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `char[]`
  `getData()`
  Returns the `data`.
  `String`
  `getName()`
  Gets the name of the entity.
  `String`
  `getString()`
  Returns the data as a `String`.
  `int`
  `getType()`
  Gets the type of the entity.
  `boolean`
  `isGeneral()`
  Returns `true` if it is a general entity.
  `boolean`
  `isParameter()`
  Returns `true` if it is a parameter entity.
  `static int`
  `name2type(String nm)`
  Converts `nm` string to the corresponding entity type.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Field Details

  - ### name

    public String name
    The name of the entity.

  - ### type

    public int type
    The type of the entity.

  - ### data

    public char[] data
    The char array of data.

- ## Constructor Details

  - ### Entity

    public Entity(String name, int type, char[] data)
    Creates an entity.
    Parameters:
      `name` - the name of the entity
      `type` - the type of the entity
      `data` - the char array of data

- ## Method Details

  - ### getName

    public String getName()
    Gets the name of the entity.
    Returns:
      the name of the entity, as a `String`

  - ### getType

    public int getType()
    Gets the type of the entity.
    Returns:
      the type of the entity

  - ### isParameter

    public boolean isParameter()
    Returns `true` if it is a parameter entity.
    Returns:
      `true` if it is a parameter entity

  - ### isGeneral

    public boolean isGeneral()
    Returns `true` if it is a general entity.
    Returns:
      `true` if it is a general entity

  - ### getData

    public char[] getData()
    Returns the `data`.
    Returns:
      the `data`

  - ### getString

    public String getString()
    Returns the data as a `String`.
    Returns:
      the data as a `String`

  - ### name2type

    public static int name2type(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".
    Parameters:
      `nm` - the string to be converted
    Returns:
      the corresponding entity type, or the type corresponding to "CDATA", if none exists