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

项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(Element)'*
 * ContentModel(Element( "elemento",',',false,false,('*',new
 * ContentModel()),BitSet(0).set(1),BitSet(168).set(45),AttributeList("1") .
 * It checks if an instance is created, content is equal to el ,type is 0
 * and next is null.
 */
public void testContentModelElement003() {
    dtd = new DTDGetter("TestContentModelSemantic");
    ContentModel cm2 = new ContentModel('*', new ContentModel());
    BitSet bs1 = new BitSet(0);
    bs1.set(1);
    BitSet bs2 = new BitSet(168);
    bs2.set(45);
    AttributeList al = new AttributeList("1");
    Element el = dtd.defineElement("elemento", ',', false, false, cm2,
            bs1, bs2, al);
    cm = new ContentModel(el);
    assertNotNull(cm);
    assertEquals(el, cm.content);
    assertEquals(cm2, el.content);
    assertEquals(el, cm.content);
    assertEquals(0, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.first(Object)'
 * ContentModel(0,ContentModel(Element("1",0,true,true,null,null,null,null)))
 * parameter: ContentModel(Element("1",0,true,true,null,null,null,null))
 * expected: true
 */

public void testFirstObject042() {
    dtd = new DTDGetter("TestContentModelSemantic");
    Element el = dtd.defineElement("1", 0, true, true, null, null,
            null, null);
    cm = new ContentModel(el);
    ContentModel cm2 = new ContentModel(0, cm);
    assertTrue(cm2.first(cm));
    assertFalse(cm2.first(cm2));
    assertFalse(cm2.first(el));
    assertFalse(cm2.first(""));
    assertFalse(cm2.first("1"));

    assertFalse(cm2.first(dtd));
    assertFalse(cm2.first(null));
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.first(Object)'
 * ContentModel("elemento",',',false,false,('*',new
 * ContentModel()),BitSet(0).set(1),BitSet(168).set(45),AttributeList("1"))
 * "elemento",',',false,false,('*',new
 * ContentModel()),BitSet(0).set(1),BitSet(168).set(45),AttributeList("1")
 * Expected: true
 */
public void testFirstObject005() {
    dtd = new DTDGetter("TestContentModelSemantic");
    ContentModel cm2 = new ContentModel('*', new ContentModel());
    BitSet bs1 = new BitSet(0);
    bs1.set(1);
    BitSet bs2 = new BitSet(168);
    bs2.set(45);
    AttributeList al = new AttributeList("1");
    Element el = dtd.defineElement("elemento", ',', false, false, cm2,
            bs1, bs2, al);
    cm = new ContentModel(el);
    assertTrue(cm.first(el));
    assertFalse(cm.first(cm));
    assertFalse(cm.first(cm2));
    assertFalse(cm.first(dtd));

    assertFalse(cm.first(bs1));
    assertFalse(cm.first(bs2));
    assertFalse(cm.first(al));
    assertFalse(cm.first(""));
    assertFalse(cm.first("elemento"));
    assertFalse(cm.first(null));
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int, Object,
 * ContentModel)' Parameters type=-38, (element is defined in a dtd as el=
 * "elemento",',',false,false,('*',new
 * ContentModel()),BitSet(0).set(1),BitSet(168).set(45),AttributeList("1")),
 * null Verifies that an instance is created. content is equal to element,
 * type is -38 and next is null
 */
public void testContentModelIntObjectContentModel045() {
    dtd = new DTDGetter("TestContentModelSemantic");
    ContentModel cm2 = new ContentModel('*', new ContentModel());
    BitSet bs1 = new BitSet(0);
    bs1.set(1);
    BitSet bs2 = new BitSet(168);
    bs2.set(45);
    AttributeList al = new AttributeList("1");
    Element el = dtd.defineElement("elemento", ',', false, false, cm2,
            bs1, bs2, al);
    cm = new ContentModel(-38, el, null);
    assertNotNull(cm);
    assertEquals(el, cm.content);
    assertEquals(-38, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int, Object,
 * ContentModel)' Parameters type=Integer.MIN_VALUE, el=
 * "",',',false,false,('*',new
 * ContentModel()),BitSet(128).set(1),BitSet(7),AttributeList("bigC",-2147483648,-1,"value",new
 * Vector(),new AttributeList(null)), new ContentModel() Verifies that an
 * instance is created. content is equal to el= "",',',false,false,('*',new
 * ContentModel()),BitSet(128).set(1),BitSet(7),AttributeList("bigC",-2147483648,-1,"value",new
 * Vector(),new AttributeList(null)), type is Integer.MIN_VALUE and next is
 * new ContentModel()
 */
public void testContentModelIntObjectContentModel080() {
    dtd = new DTDGetter("TestContentModelSemantic");
    ContentModel cmnext = new ContentModel();
    ContentModel cm2 = new ContentModel('*', new ContentModel());
    BitSet bs1 = new BitSet(128);
    bs1.set(1);
    BitSet bs2 = new BitSet(7);
    AttributeList al = new AttributeList("bigC", -2147483648, -1,
            "value", new Vector(), new AttributeList(null));
    Element el = dtd.defineElement("", '*', true, false, cm2, bs1, bs2,
            al);
    cm = new ContentModel(Integer.MIN_VALUE, el, cmnext);
    assertNotNull(cm);
    assertEquals(el, cm.content);
    assertEquals(Integer.MIN_VALUE, cm.type);
    assertEquals(cmnext, cm.next);
}
项目:jdk8u-jdk    文件:bug8074956.java   
public static void main(String[] args) throws Exception {
    final DTD html32 = DTD.getDTD("html32");
    ContentModel contentModel = new ContentModel('&', new ContentModel());

    Element elem1 = html32.getElement("html-element");
    contentModel.first(elem1);

    Element elem2 = html32.getElement("test-element");
    // Shouldn't throw ArrayIndexOutOfBoundsException
    contentModel.first(elem2);
}
项目:openjdk-jdk10    文件:bug8074956.java   
public static void main(String[] args) throws Exception {
    final DTD html32 = DTD.getDTD("html32");
    ContentModel contentModel = new ContentModel('&', new ContentModel());

    Element elem1 = html32.getElement("html-element");
    contentModel.first(elem1);

    Element elem2 = html32.getElement("test-element");
    // Shouldn't throw ArrayIndexOutOfBoundsException
    contentModel.first(elem2);
}
项目:openjdk9    文件:bug8074956.java   
public static void main(String[] args) throws Exception {
    final DTD html32 = DTD.getDTD("html32");
    ContentModel contentModel = new ContentModel('&', new ContentModel());

    Element elem1 = html32.getElement("html-element");
    contentModel.first(elem1);

    Element elem2 = html32.getElement("test-element");
    // Shouldn't throw ArrayIndexOutOfBoundsException
    contentModel.first(elem2);
}
项目:jdk8u_jdk    文件:bug8074956.java   
public static void main(String[] args) throws Exception {
    final DTD html32 = DTD.getDTD("html32");
    ContentModel contentModel = new ContentModel('&', new ContentModel());

    Element elem1 = html32.getElement("html-element");
    contentModel.first(elem1);

    Element elem2 = html32.getElement("test-element");
    // Shouldn't throw ArrayIndexOutOfBoundsException
    contentModel.first(elem2);
}
项目:lookaside_java-1.8.0-openjdk    文件:bug8074956.java   
public static void main(String[] args) throws Exception {
    final DTD html32 = DTD.getDTD("html32");
    ContentModel contentModel = new ContentModel('&', new ContentModel());

    Element elem1 = html32.getElement("html-element");
    contentModel.first(elem1);

    Element elem2 = html32.getElement("test-element");
    // Shouldn't throw ArrayIndexOutOfBoundsException
    contentModel.first(elem2);
}
项目:javify    文件:gnuDTD.java   
/**
 * Defines a new element and adds it to the element table.
 * If the element alredy exists,
 * overrides it settings with the specified values.
 * @param name the name of the new element
 * @param type the type of the element
 * @param headless true if the element needs no starting tag
 * @param tailless true if the element needs no closing tag
 * @param content the element content.
 * @param exclusions the elements that must be excluded from the
 * content of this element, in all levels of the hierarchy.
 * @param inclusions the elements that can be included as the
 * content of this element.
 * @param attributes the element attributes (an array and not a
 * linked list). The attributes are chained into the linked list
 * inside this method.
 * @return the created or updated element.
 */
public Element defElement(String name, int type, boolean headless,
                          boolean tailless, ContentModel content,
                          String[] exclusions, String[] inclusions,
                          AttributeList[] attributes
                         )
{
  AttributeList list;

  if (attributes == null || attributes.length == 0)
    list = null;
  else
    {
      if (attributes.length > 1)
        for (int i = 1; i < attributes.length; i++)
          {
            attributes [ i - 1 ].next = attributes [ i ];
          }
      list = attributes [ 0 ];
    }

  Element e =
    super.defElement(name, type, headless, tailless, content, exclusions,
                     inclusions, list
                    );
  return e;
}
项目:javify    文件:transformer.java   
/**
 * Measure length of the linked list of the content models.
 * @param c The heading element of the linked list.
 * @return the length of the list (0 for null 1 if c!=null and c.next==null,
 * etc.
 */
public static int measureChainLength(ContentModel c)
{
  if (c == null)
    return 0;
  else
    return measureChainLength(c.next) + 1;
}
项目:javify    文件:transformer.java   
private static node optionalTransform(ContentModel c, DTD dtd)
{
  node n;
  if (c.content instanceof ContentModel)
    n = transform((ContentModel) c.content, dtd);
  else

    /* A single token with the specified operation */
    n = new node((char) 0, (char) 0, c.content);
  return n;
}
项目:javify    文件:HTML_401F.java   
/**
 * Crate a chain from the two content models,
 * the last containing the given element and
 * the specified unary operation.
 */
private ContentModel model(String element, int unary)
{
  ContentModel ct = model(element);
  ct.type = unary;
  return new ContentModel(0, ct);
}
项目:javify    文件:HTML_401F.java   
/**
 * Create the model HEAD, BODY
 * @return the HTML content model of the whole document
 */
protected ContentModel createHtmlContentModel()
{
  ContentModel head = model(HEAD);
  ContentModel body = model(BODY);
  head.next = body;
  head.type = ',';
  return head;
}
项目:javify    文件:HTML_401F.java   
/**
 * Creates a model for &lt;DL&gt; tag:
 * <code> DT+ | DL+ </code>.
 * @return
 */
protected ContentModel createDefListModel()
{
  ContentModel dt = model(DT, '+');
  ContentModel dd = model(DD, '+');

  dt.next = dd;
  dt.type = dd.type = '|';
  return dt;
}
项目:javify    文件:HTML_401F.java   
/**
 * This model is used for UL, OL, MENU and DIR.
 *  HTML 4.01 specifies LI only, but the nested
 * list seems rendered correctly only if
 * it is not enclosed into <LI>-</LI> of the
 * parent list.
 */
protected ContentModel createListModel()
{
  ContentModel li = model(LI, '+');
  ContentModel ul = model(UL, '+');
  ContentModel ol = model(OL, '+');

  li.next = ul;
  ul.next = ol;
  li.type = ul.type = ol.type = '|';
  return li;
}
项目:jvm-stm    文件:gnuDTD.java   
/**
 * Defines a new element and adds it to the element table.
 * If the element alredy exists,
 * overrides it settings with the specified values.
 * @param name the name of the new element
 * @param type the type of the element
 * @param headless true if the element needs no starting tag
 * @param tailless true if the element needs no closing tag
 * @param content the element content.
 * @param exclusions the elements that must be excluded from the
 * content of this element, in all levels of the hierarchy.
 * @param inclusions the elements that can be included as the
 * content of this element.
 * @param attributes the element attributes (an array and not a
 * linked list). The attributes are chained into the linked list
 * inside this method.
 * @return the created or updated element.
 */
public Element defElement(String name, int type, boolean headless,
                          boolean tailless, ContentModel content,
                          String[] exclusions, String[] inclusions,
                          AttributeList[] attributes
                         )
{
  AttributeList list;

  if (attributes == null || attributes.length == 0)
    list = null;
  else
    {
      if (attributes.length > 1)
        for (int i = 1; i < attributes.length; i++)
          {
            attributes [ i - 1 ].next = attributes [ i ];
          }
      list = attributes [ 0 ];
    }

  Element e =
    super.defElement(name, type, headless, tailless, content, exclusions,
                     inclusions, list
                    );
  return e;
}
项目:jvm-stm    文件:transformer.java   
/**
 * Measure length of the linked list of the content models.
 * @param c The heading element of the linked list.
 * @return the length of the list (0 for null 1 if c!=null and c.next==null,
 * etc.
 */
public static int measureChainLength(ContentModel c)
{
  if (c == null)
    return 0;
  else
    return measureChainLength(c.next) + 1;
}
项目:jvm-stm    文件:transformer.java   
private static node optionalTransform(ContentModel c, DTD dtd)
{
  node n;
  if (c.content instanceof ContentModel)
    n = transform((ContentModel) c.content, dtd);
  else

    /* A single token with the specified operation */
    n = new node((char) 0, (char) 0, c.content);
  return n;
}
项目:jvm-stm    文件:HTML_401F.java   
/**
 * Crate a chain from the two content models,
 * the last containing the given element and
 * the specified unary operation.
 */
private ContentModel model(String element, int unary)
{
  ContentModel ct = model(element);
  ct.type = unary;
  return new ContentModel(0, ct);
}
项目:jvm-stm    文件:HTML_401F.java   
/**
 * Create the model HEAD, BODY
 * @return the HTML content model of the whole document
 */
protected ContentModel createHtmlContentModel()
{
  ContentModel head = model(HEAD);
  ContentModel body = model(BODY);
  head.next = body;
  head.type = ',';
  return head;
}
项目:jvm-stm    文件:HTML_401F.java   
/**
 * Creates a model for &lt;DL&gt; tag:
 * <code> DT+ | DL+ </code>.
 * @return
 */
protected ContentModel createDefListModel()
{
  ContentModel dt = model(DT, '+');
  ContentModel dd = model(DD, '+');

  dt.next = dd;
  dt.type = dd.type = '|';
  return dt;
}
项目:jvm-stm    文件:HTML_401F.java   
/**
 * This model is used for UL, OL, MENU and DIR.
 *  HTML 4.01 specifies LI only, but the nested
 * list seems rendered correctly only if
 * it is not enclosed into <LI>-</LI> of the
 * parent list.
 */
protected ContentModel createListModel()
{
  ContentModel li = model(LI, '+');
  ContentModel ul = model(UL, '+');
  ContentModel ol = model(OL, '+');

  li.next = ul;
  ul.next = ol;
  li.type = ul.type = ol.type = '|';
  return li;
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(Element)' Null is
 * passed as parameter Verifies that an instance is created. Fields content
 * and next are null and type is 0.
 */
public void testContentModelElement001() {
    cm = new ContentModel(null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(0, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.getElements(Vector)'
 * ContentModel(63,null) parameter: new Vector() expected:
 * NullPointerException
 */
public void testGetElements028() {
    try {
        cm = new ContentModel(63, null);
        Vector v = new Vector();
        cm.getElements(v);
        fail("Should raise NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(Element)'*
 * ContentModel(Element( "1",0,true,true,null,null,null,null . It checks if
 * an instance is created, content is equal to el ,type is 0 and next is
 * null.
 */
public void testContentModelElement005() {
    dtd = new DTDGetter("TestContentModelSemantic");
    Element el = dtd.defineElement("1", 0, true, true, null, null,
            null, null);
    cm = new ContentModel(el);
    assertNotNull(cm);
    assertEquals(el, cm.content);
    assertNull(el.content);
    assertEquals(el, cm.content);
    assertEquals(0, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelSemanticTest.java   
public void testContentModelSemantic_4_5() {
    Element el1 = newElement("el1");
    Element el2 = newElement("el2");
    ContentModel cm1 = newContentModel('+', '|', 0, 0, el1, el2);

    assertTrue(cm1.first(el2));
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.first(Object)'
 * ContentModel(43,ContentModel(42,null)) parameter: ContentModel(43,null)
 * expected: NullPointerException
 */
public void testFirstObject059() {
    try {
        ContentModel cm2 = new ContentModel(42, null);
        cm = new ContentModel(43, cm2);
        cm.first(cm2);

        fail("Should raise NullPointerException");

    } catch (NullPointerException e) {
        // Expected
    }
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=43, ContentModel() Verifies that an
 * instance is created. content is equal to ContentModel(), type is 43 and
 * next is null
 */
public void testContentModelIntContentModel005() {
    ContentModel cm2 = new ContentModel();
    cm = new ContentModel(43, cm2);
    assertNotNull(cm);
    assertEquals(cm2, cm.content);
    assertEquals(43, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=44, ContentModel() Verifies that an
 * instance is created. content is equal to ContentModel(), type is 44 and
 * next is null
 */
public void testContentModelIntContentModel006() {
    ContentModel cm2 = new ContentModel();
    cm = new ContentModel(44, cm2);
    assertNotNull(cm);
    assertEquals(cm2, cm.content);
    assertEquals(44, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.first(Object)'
 * ContentModel(42,ContentModel(42,null)) parameter: ContentModel(42,null)
 * expected: NullPointerException
 */
public void testFirstObject056() {
    try {
        ContentModel cm2 = new ContentModel(42, null);
        cm = new ContentModel(42, cm2);

        cm.first(cm);

        fail("Should raise NullPointerException");

    } catch (NullPointerException e) {
        // Expected
    }
}
项目:cn1    文件:ContentModelSemanticTest.java   
public void testContentModelSemantic_6_4() {
    Element el1 = newElement("el1");
    Element el2 = newElement("el2");
    ContentModel cm1 = newContentModel('?', '&', 0, 0, el1, el2);

    assertTrue(cm1.first(el1));
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=38, ContentModel() Verifies that an
 * instance is created. content is equal to ContentModel(), type is 38 and
 * next is null
 */
public void testContentModelIntContentModel009() {
    ContentModel cm2 = new ContentModel();
    cm = new ContentModel(38, cm2);
    assertNotNull(cm);
    assertEquals(cm2, cm.content);
    assertEquals(38, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=0, null Verifies that an instance is
 * created. content is equal to null, type is 0 and next is null
 */
public void testContentModelIntContentModel010() {
    cm = new ContentModel(0, null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(0, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=Integer.MIN_VALUE, null Verifies that an
 * instance is created. content is equal to null, type is Integer.MIN_VALUE
 * and next is null
 */
public void testContentModelIntContentModel011() {
    cm = new ContentModel(Integer.MIN_VALUE, null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(Integer.MIN_VALUE, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelSemanticTest.java   
public void testContentModelSemantic_1_1() {
    Element el1 = newElement("el1");
    Element el2 = newElement("el2");
    ContentModel cm1 = newContentModel('+', ',', 0, 0, el1, el2);

    assertEquals(cm1.toString(), "(el1 , el2)+");
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=42, null Verifies that an instance is
 * created. content is equal to null, type is 42 and next is null
 */
public void testContentModelIntContentModel013() {
    cm = new ContentModel(42, null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(42, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=43, null Verifies that an instance is
 * created. content is equal to null, type is 43 and next is null
 */
public void testContentModelIntContentModel014() {
    cm = new ContentModel(43, null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(43, cm.type);
    assertNull(cm.next);
}
项目:cn1    文件:ContentModelCompatilityTest.java   
/**
 * Test method for
 * 'org.apache.harmony.swing.tests.javax.swing.text.parser.ContentModel.ContentModel(int,
 * ContentModel)' Parameters type=44, null Verifies that an instance is
 * created. content is equal to null, type is 44 and next is null
 */
public void testContentModelIntContentModel015() {
    cm = new ContentModel(44, null);
    assertNotNull(cm);
    assertNull(cm.content);
    assertEquals(44, cm.type);
    assertNull(cm.next);
}