Re: quick question on XmlSerializer

Aleksander Slominski <[email protected]> Wed, 24 Mar 2004 22:31:02 -0500
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
--------------010108030703050603020705
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

hi Jinfan,

as you noticed interface/factory can not be extended (it is not fault of 
XmlPull but more of Java Interface design ...).

instead use adapter pattern and delegate calls.

http://c2.com/cgi/wiki?AdapterPattern

you can re-use existing adapter/wrapper (it /may/ already have methods 
you need ...) from

http://www.xmlpull.org/v1/doc/addons.html#wrapper

in particular:

http://www.xmlpull.org/v1/addons/java/wrapper/src/org/xmlpull/v1/wrapper/classic/StaticXmlSerializerWrapper.java

(this and other addons are part of XPP3)

HTH,

alek

Jinfan Duan wrote:

>Hello Alek,
>
>I have a question on subclassing you XmlSreializer, right now I need to add
>several functions to the serializer, and hope the factory rill create my
>subclass, how do I do this?
>
>This is my current code, and I would like the code return myXmlSerilizer,
>lets say. The new class is in this package and derived from the
>XmSerializer.
>
>
>   protected  XmlSerializer getXmlSerializer() throws
>XmlPullParserException,
>      IllegalStateException, IllegalArgumentException, IOException
>   {
>	// this is the line it will scream.-----------------------------
>      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
>
>      //   System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
>      return factory.newSerializer();
>   }
>
>Thanks a lot for your help.
> 
>
>
>
>  
>


-- 
The best way to predict the future is to invent it - Alan Kay


--------------010108030703050603020705
Content-Type: text/html; charset=US-ASCII
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body>


hi Jinfan,<br>
<br>
as you noticed interface/factory can not be extended (it is not fault
of XmlPull but more of Java Interface design ...). <br>
<br>
instead use adapter pattern and delegate calls.<br>
<br>
<a class="moz-txt-link-freetext" href="http://c2.com/cgi/wiki?AdapterPattern">http://c2.com/cgi/wiki?AdapterPattern</a><br>
<br>
you can re-use existing adapter/wrapper (it <i>may</i> already have
methods you need ...) from <br>
<br>
<a class="moz-txt-link-freetext" href="http://www.xmlpull.org/v1/doc/addons.html#wrapper">http://www.xmlpull.org/v1/doc/addons.html#wrapper</a><br>
<br>
in particular:<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.xmlpull.org/v1/addons/java/wrapper/src/org/xmlpull/v1/wrapper/classic/StaticXmlSerializerWrapper.java">http://www.xmlpull.org/v1/addons/java/wrapper/src/org/xmlpull/v1/wrapper/classic/StaticXmlSerializerWrapper.java</a><br>
<br>
(this and other addons are part of XPP3)<br>
<br>
HTH,<br>
<br>
alek<br>
<br>
Jinfan Duan wrote:
<blockquote cite="mid006b01c41213$a290e560$6501010a@jinfanl1"
 type="cite">
  <pre wrap="">Hello Alek,

I have a question on subclassing you XmlSreializer, right now I need to add
several functions to the serializer, and hope the factory rill create my
subclass, how do I do this?

This is my current code, and I would like the code return myXmlSerilizer,
lets say. The new class is in this package and derived from the
XmSerializer.


   protected  XmlSerializer getXmlSerializer() throws
XmlPullParserException,
      IllegalStateException, IllegalArgumentException, IOException
   {
	// this is the line it will scream.-----------------------------
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

      //   System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
      return factory.newSerializer();
   }

Thanks a lot for your help.
 



  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="103">-- 
The best way to predict the future is to invent it - Alan Kay
</pre>


<br>




<!-- |**|begin egp html banner|**| -->

<br>
<tt><hr width="500">
<b>Yahoo! Groups Links</b><br>
<ul>
<li>To visit your group on the web, go to:<br><a href="http://groups.yahoo.com/group/xmlpull-dev/">http://groups.yahoo.com/group/xmlpull-dev/</a><br>&nbsp;
<li>To unsubscribe from this group, send an email to:<br><a href="mailto:[email protected]?subject=Unsubscribe">[email protected]</a><br>&nbsp;
<li>Your use of Yahoo! Groups is subject to the <a href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.
</ul>
</tt>
</br>

<!-- |**|end egp html banner|**| -->


</body>
</html>

--------------010108030703050603020705--