System.out.println("NODE-NAME: " + node.getName());
System.out.println("NODE-VALUE: " + new String(node.getValue()));
System.out.println("NODE-TEXT VALUE: " + node.getTextValue());
//Attributes.
Attributes attrs = AttributeParser.getAttributes(node);
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}
//Modify the value of an Atribute.
System.out.println("\n\nModify: ");
for (int j = 0; j < attrs.size(); j++)
{
if (attrs.get(j).getName().equals("caption"))
{
attrs.get(j).setValue("Sets a new Caption to the Table!");
//attrs.set(attrs.get(j));
}
if (attrs.get(j).getName().equals("border"))
{
//System.out.println("\n\n\n\n= ===s=fsdf\n\n");
//sysout
attrs.get(j).setValue("0");
//attrs.set(attrs.get(j));
}
}
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}
//Add a new Attribute to the attribute collection of the Node.
Attribute newAttr = new Attribute("bgcolor", "red");
attrs.set(newAttr);
assertEquals(newAttr.getName(), "bgcolor");
assertEquals(newAttr.getValue(), "red");
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}
//Clear (remove) an Attribute in the attribute collection of the Node.
System.out.println("\n\nRemove:");
assertEquals(true, attrs.contains(new Attribute("bgcolor", "red")));
attrs.remove(new Attribute("bgcolor", "red"));
assertNull(attrs.get("bgcolor"));
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}
//Clear all the attributes of the Node.
attrs.clear();
assertEquals(true, attrs.isEmpty());
//assertEquals(attrs,null);
//Add a new Atribute collection to the Node.
System.out.println("\n\nAdd:");
List<Attribute> attrList = new ArrayList<Attribute>();
attrList.add(new Attribute("caption", "New Table"));
attrList.add(1, new Attribute("border", "2"));
attrList.add(2, new Attribute("bgcolor", "blue"));
assertEquals(true, attrs.addAll(0, attrList));
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}
//Insert a new Attribute to the attribute collection of the Node.
attrs.add(attrs.size() - 1, new Attribute("cellspacing", "2"));
//assertEquals(attrs.get(attrs.size()-1),new Attribute("cellspacing","2"));
assertNotNull(attrs.get(attrs.size() - 1));
System.out.println("\n\nInsert:");
for (Attribute attr : attrs)
{
System.out.println("NAME: " + attr.getName() + " & " + "VALUE: " + attr.getValue());
}