[EMAIL PROTECTED] wrote:
> org.apache.ecs.xhtml.Html html = new
> org.apache.ecs.xhtml.Html().addElement(/*someelement*/); // doesn't work because
> addElement returns the wrong datatype, and you can't override methods with
> different datatype returns.
>
> Hope that clarifys why you can't extend the html.* classes in ecs1.x.
>
Yes, you are quite right. I was expecting that addElement and similar
methods would return Element and not something so specific as the class
itself.
I'm not 100% on what was the motivation behind choosing to return a
specific class. It seems that most constructors of HTML elements and all
addElement methods take Element as an argument, so they don't really
know what's coming in unless they check it by reading it with
getElementType or using instanceof. That's why I was expecting that they
would return an Element as well...
Like in the example from the introduction page:
-----------
Html html = new Html()
.addElement(new Head()
.addElement(new Title("Demo")))
.addElement(new Body()
.addElement(new H1("Demo Header"))
.addElement(new H3("Sub Header:"))
.addElement(new Font().setSize("+1")
.setColor(HtmlColor.WHITE)
.setFace("Times")
.addElement("The big dog & the little cat
chased each other.")));
-----------
all new objects are going into addElement as just Elements.
I wasn't really planning on overriding the addElement methods at all. I
was counting on the above, but that's obviously not the case.
Here is a snippet of the (impossible) code...
Bojan
PS. I'll check out ECS2 files from the CVS and see where to go from
there.
-------------
package org.apache.ecs.xhtml;
import org.apache.ecs.*;
public class a extends org.apache.ecs.html.A
{
{
setElementType("a");
super.setCase(LOWERCASE);
}
public a()
{
}
public a(String href)
{
super(href);
}
public a(String href, String value)
{
super(href, value);
}
public a(String href, Element value)
{
super(href, value);
}
public a(String href, String name, String value)
{
super(href, name, value);
}
public a(String href, String name, Element value)
{
super(href, name, value);
}
public a(String href, String name, String target, Element value)
{
super(href, name, target, value);
}
public a(String href, String name, String target, String value)
{
super(href, name, target, value);
}
public a(String href, String name, String target, String lang,
String value)
{
super(href, name, target, lang, value);
}
public a(String href, String name, String target, String lang,
Element value)
{
setHref(href);
setName(name);
setTarget(target);
setLang(lang);
addElement(value);
}
public void setCase(int case_type)
{
}
public Element setLang(String lang)
{
addAttribute("lang",lang);
addAttribute("xml:lang",lang);
return(this);
}
}
-------------
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]