Java 类javax.swing.text.html.parser.DTDConstants 实例源码

项目:classpath    文件:Entity_Test.java   
public void testName2type()
{
  assertEquals("PUBLIC", Entity.name2type("PUBLIC"), DTDConstants.PUBLIC);
  assertEquals("SDATA", Entity.name2type("SDATA"), DTDConstants.SDATA);
  assertEquals("PI", Entity.name2type("PI"), DTDConstants.PI);
  assertEquals("STARTTAG", Entity.name2type("STARTTAG"), DTDConstants.STARTTAG);
  assertEquals("ENDTAG", Entity.name2type("ENDTAG"), DTDConstants.ENDTAG);
  assertEquals("MS", Entity.name2type("MS"), DTDConstants.MS);
  assertEquals("MD", Entity.name2type("MD"), DTDConstants.MD);
  assertEquals("SYSTEM", Entity.name2type("SYSTEM"), DTDConstants.SYSTEM);

  assertEquals("surely unknown ", Entity.name2type("audrius"),
               DTDConstants.CDATA
              );
}
项目:classpath    文件:Entity_Test.java   
public void testPublicSystemGeneralParameter()
{
  int[] pu_sy = new int[] { DTDConstants.PUBLIC, DTDConstants.SYSTEM, 0 };

  int[] gen_par =
    new int[] { DTDConstants.GENERAL, DTDConstants.PARAMETER, 0 };

  for (int ps = 0; ps < pu_sy.length; ps++)
    {
      for (int gp = 0; gp < gen_par.length; gp++)
        {
          Entity e = new Entity(null, 0, null);
          e.type = pu_sy [ ps ] | gen_par [ gp ];

          assertEquals(e.isGeneral(), gen_par [ gp ] == DTDConstants.GENERAL);
          assertEquals(e.isParameter(),
                       gen_par [ gp ] == DTDConstants.PARAMETER
                      );

          assertEquals((e.type & DTDConstants.SYSTEM) != 0,
                       pu_sy [ ps ] == DTDConstants.SYSTEM
                      );

          assertEquals((e.type & DTDConstants.PUBLIC) != 0,
                       pu_sy [ ps ] == DTDConstants.PUBLIC
                      );

          assertEquals((e.type & DTDConstants.GENERAL) != 0,
                       gen_par [ gp ] == DTDConstants.GENERAL
                      );

          assertEquals((e.type & DTDConstants.PARAMETER) != 0,
                       gen_par [ gp ] == DTDConstants.PARAMETER
                      );
        }
    }
}
项目:classpath    文件:Element_Test.java   
public void testName2type()
{
  assertEquals(Element.name2type("CDATA"), DTDConstants.CDATA);
  assertEquals(Element.name2type("RCDATA"), DTDConstants.RCDATA);
  assertEquals(Element.name2type("EMPTY"), DTDConstants.EMPTY);
  assertEquals(Element.name2type("ANY"), DTDConstants.ANY);

  assertEquals(Element.name2type("audrius"), 0);
  assertEquals(Element.name2type("rcdata"), 0);
}
项目:javify    文件:Parser.java   
/**
 * Handle the remaining of HTML tags. This is a common end for
 * TAG, SCRIPT and STYLE.
 * @param closing True for closing tags ( &lt;/TAG&gt; ).
 * @param name Name of element
 * @param start Token where element has started
 * @throws ParseException
 */
private void restOfTag(boolean closing, Token name, Token start)
                throws ParseException
{
  boolean end = false;
  Token next;

  optional(WS);

  readAttributes(name.getImage());

  optional(WS);

  next = getTokenAhead();
  if (next.kind == END)
    {
      mustBe(END);
      end = true;
    }

  hTag = new Token(start, next);

  if (!end)
    {
      // The tag body contains errors. If additionally the tag
      // name is not valid, this construction is treated as text.
      if (dtd.elementHash.get(name.getImage().toLowerCase()) == null &&
          backupMode
         )
        {
          error("Errors in tag body and unknown tag name. " +
                "Treating the tag as a text."
               );
          reset();

          hTag = mustBe(BEGIN);
          buffer.setLength(0);
          buffer.append(hTag.getImage());
          CDATA(false);
          return;
        }
      else
        {
          error("Forcibly closing invalid parameter list");
          forciblyCloseTheTag();
        }
    }

  if (closing)
    {
      endTag(false);
      _handleEndTag(makeTagElement(name.getImage(), false));
    }
  else
    {
      TagElement te = makeTagElement(name.getImage(), false);
      if (te.getElement().type == DTDConstants.EMPTY)
        _handleEmptyTag(te);
      else
        {
          // According to the specs we need to consume whitespace following
          // immediately after a opening tag.
          optional(WS);
          _handleStartTag(te);
        }
    }
}
项目:jvm-stm    文件:Parser.java   
/**
 * Handle the remaining of HTML tags. This is a common end for
 * TAG, SCRIPT and STYLE.
 * @param closing True for closing tags ( &lt;/TAG&gt; ).
 * @param name Name of element
 * @param start Token where element has started
 * @throws ParseException
 */
private void restOfTag(boolean closing, Token name, Token start)
                throws ParseException
{
  boolean end = false;
  Token next;

  optional(WS);

  readAttributes(name.getImage());

  optional(WS);

  next = getTokenAhead();
  if (next.kind == END)
    {
      mustBe(END);
      end = true;
    }

  hTag = new Token(start, next);

  if (!end)
    {
      // The tag body contains errors. If additionally the tag
      // name is not valid, this construction is treated as text.
      if (dtd.elementHash.get(name.getImage().toLowerCase()) == null &&
          backupMode
         )
        {
          error("Errors in tag body and unknown tag name. " +
                "Treating the tag as a text."
               );
          reset();

          hTag = mustBe(BEGIN);
          buffer.setLength(0);
          buffer.append(hTag.getImage());
          CDATA(false);
          return;
        }
      else
        {
          error("Forcibly closing invalid parameter list");
          forciblyCloseTheTag();
        }
    }

  if (closing)
    {
      endTag(false);
      _handleEndTag(makeTagElement(name.getImage(), false));
    }
  else
    {
      TagElement te = makeTagElement(name.getImage(), false);
      if (te.getElement().type == DTDConstants.EMPTY)
        _handleEmptyTag(te);
      else
        {
          // According to the specs we need to consume whitespace following
          // immediately after a opening tag.
          optional(WS);
          _handleStartTag(te);
        }
    }
}
项目:JamVM-PH    文件:Parser.java   
/**
 * Handle the remaining of HTML tags. This is a common end for
 * TAG, SCRIPT and STYLE.
 * @param closing True for closing tags ( &lt;/TAG&gt; ).
 * @param name Name of element
 * @param start Token where element has started
 * @throws ParseException
 */
private void restOfTag(boolean closing, Token name, Token start)
                throws ParseException
{
  boolean end = false;
  Token next;

  optional(WS);

  readAttributes(name.getImage());

  optional(WS);

  next = getTokenAhead();
  if (next.kind == END)
    {
      mustBe(END);
      end = true;
    }

  hTag = new Token(start, next);

  if (!end)
    {
      // The tag body contains errors. If additionally the tag
      // name is not valid, this construction is treated as text.
      if (dtd.elementHash.get(name.getImage().toLowerCase()) == null &&
          backupMode
         )
        {
          error("Errors in tag body and unknown tag name. " +
                "Treating the tag as a text."
               );
          reset();

          hTag = mustBe(BEGIN);
          buffer.setLength(0);
          buffer.append(hTag.getImage());
          CDATA(false);
          return;
        }
      else
        {
          error("Forcibly closing invalid parameter list");
          forciblyCloseTheTag();
        }
    }

  if (closing)
    {
      endTag(false);
      _handleEndTag(makeTagElement(name.getImage(), false));
    }
  else
    {
      TagElement te = makeTagElement(name.getImage(), false);
      if (te.getElement().type == DTDConstants.EMPTY)
        _handleEmptyTag(te);
      else
        {
          // According to the specs we need to consume whitespace following
          // immediately after a opening tag.
          optional(WS);
          _handleStartTag(te);
        }
    }
}
项目:classpath    文件:Parser.java   
/**
 * Handle the remaining of HTML tags. This is a common end for
 * TAG, SCRIPT and STYLE.
 * @param closing True for closing tags ( &lt;/TAG&gt; ).
 * @param name Name of element
 * @param start Token where element has started
 * @throws ParseException
 */
private void restOfTag(boolean closing, Token name, Token start)
                throws ParseException
{
  boolean end = false;
  Token next;

  optional(WS);

  readAttributes(name.getImage());

  optional(WS);

  next = getTokenAhead();
  if (next.kind == END)
    {
      mustBe(END);
      end = true;
    }

  hTag = new Token(start, next);

  if (!end)
    {
      // The tag body contains errors. If additionally the tag
      // name is not valid, this construction is treated as text.
      if (dtd.elementHash.get(name.getImage().toLowerCase()) == null &&
          backupMode
         )
        {
          error("Errors in tag body and unknown tag name. " +
                "Treating the tag as a text."
               );
          reset();

          hTag = mustBe(BEGIN);
          buffer.setLength(0);
          buffer.append(hTag.getImage());
          CDATA(false);
          return;
        }
      else
        {
          error("Forcibly closing invalid parameter list");
          forciblyCloseTheTag();
        }
    }

  if (closing)
    {
      endTag(false);
      _handleEndTag(makeTagElement(name.getImage(), false));
    }
  else
    {
      TagElement te = makeTagElement(name.getImage(), false);
      if (te.getElement().type == DTDConstants.EMPTY)
        _handleEmptyTag(te);
      else
        {
          // According to the specs we need to consume whitespace following
          // immediately after a opening tag.
          optional(WS);
          _handleStartTag(te);
        }
    }
}