This is what i mean by ecs 1.x stuff is not extensible.
package org.apache.ecs.html;
// this isn't a real ecs class
public class Html {
Html() {}
public Html addElement(Element element) {
// do something
}
}
package org.apahce.ecs.xhtml;
public class Html extends org.apache.ecs.html.Html {
Html() {}
// you cannot override this method because it returns
org.apache.ecs.html.Html
public Html addElemnt(Element element) {
// do something
}
}
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.
What i've done in ecs2 ( which is in cvs under the ecs2 tag ) is something like
this.
package org.apache.ecs.html;
public class Html {
public pElement element = new pElement();
Html() {}
public void addElement(Element element) {
// do something
}
private Html getInstance() {
return this;
}
public class pElement {
public Html add(Element element) {
getInstance().addElement(element);
return getInstance();
}
}
}
This allows you to subclass Html like this.
package org.apache.ecs.xhtml;
pubilc class Html extends org.apache.ecs.html.Html {
public pElement element = new pElement();
private Html getEnstance() {
return this;
}
public class pElement {
public Html add(Element element) {
getInstance().addElement(element);
return getInstance();
}
}
}
you can do this in your code.
org.apache.ecs.html.Html h = new
org.apache.ecs.html.Html().element.add(/*someelement*/);
org.apache.ecs.xhtml.Html h1 = new
org.apache.ecs.xhtml.Html().element.add(/*someelement*/);
All of the set* methods in html.* return voids so you can extend the elements in
other packages, and if you want to support method chaining you implement you own
public innerclass and override the element variable with it, pretty cool eh?
Wish i could take credit for the idea but someone on the list came up with it.
WIsh i could remember their name :-(. Also as it stands right now ecs2 is about
2x-3x faster then ecs1.x and uses about 30%-40% less memory, but as you can see
the new way of doing method chaining breaks any code implemented on the ecs1.x
codebase. :-(
-stephan
Bojan Smojver <[EMAIL PROTECTED]> on 09/21/2000 11:31:29 PM
Please respond to "ECS" <[EMAIL PROTECTED]>
To: "'ECS'" <[EMAIL PROTECTED]>
cc: (bcc: Stephan Nagy/TheSphereHQ)
Subject: RE: XHTML
My plan was based on the release version 1.3.3. I know should have checked
the latest CVS first #8-(
Anyway, this was my plan for 1.3.3 (basically I wanted to upset the existing
code at little as possible):
- add three more DTD's to Doctype for XHTML (Strict, Transitional and
Frameset)
- create a package org.apache.ecs.xhtml
- extend all classes from org.apache.ecs.html and make them lowercase (eg.
'A' becomes 'a' - XHTML is lowercase only - this might not be too smart due
to possible name conflicts with other classes people use)
- redefine setCase() method in all classes to do nothing (ie. XHTML is
always lowercase); call super.setCase(LOWERCASE) in the constructor of the
class
- call setBeginEndModifier('/') in the constructor of single part elements
like <hr>, <br>, <img ...> so that they become <hr />, <br /> and <img ...
/> respectively (another one of the XHTML quirks)
- I'm not sure yet about the attributes (have to look at the code and docs a
bit more), but XHTML doesn't allow minimised form (ie. you have to say
nowrap="nowrap")
- there are a few other little things from the XHTML spec that might need a
bit of work
Does this sound about right or am I totally off the mark? I only had a
glance at the code/docs and I could be dead wrong about what some of the
mentioned methods do. I'm still in the process of wrapping my head around
ECS #8-)
Bojan
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, September 22, 2000 4:01 AM
> To: ECS
> Subject: RE: XHTML
>
>
>
> Sadly, the stuff in ecs1.x isn't very exstensible. ecs2 fixes this but i
> haven't finished coding the html classes yet ( ecs2 takes a different
> approach
> to method chaining utilizing innerclasses which is in no way compatible
> with
> ecs1.x ) If you go with ecs1.x you will have to recreate all of the xhtml
> classes from scratch.
>
> -stephan
>
>
>
>
> --
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html>
> Problems?: [EMAIL PROTECTED]
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]