This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JavaME Internal DOM classes  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to implement my own org.w3c.dom.Element class that later on is used as a node in a org.w3c.dom.Document instance.
My own element class essentially implements the required interface and everything works fine, at least in a Java standard edition.

Running it on a micro edition (v 8) I do see some unexpected behaviour. I get a class cast exception.

java.lang.ClassCastException
- com/sun/ukit/dom/XParent.appendChild(), bci=21

Looking for the code I found the following on [1]

public Node appendChild(Node newChild)
throws DOMException
{
if (_isRO())
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "");

XNode nchild = (XNode)newChild;
if (newChild.getNodeType() != DOCUMENT_FRAGMENT_NODE) {
// Append a new child node.
_appendChild(nchild);
_childAdded(nchild);
} else {
// Recursive call to appendChild for each child of doc fragment
while (nchild.getLength() > 0)
appendChild(nchild.item(0));
}
return nchild;
}


It looks like each newChild node gets casted to XNode. First of all I wonder why and second I would like to know how I can now write my own Node classes. I cannot simply extend XNode given that it seems internal somehow.

Any ideas? Thank you very much for every hint,


-- Daniel

[1] https://svn.java.net/svn/phoneme~svn/components/jsr280/branches/jsr280-cr-6781500/src/share/oi/com/sun/ukit/dom/XParent.java
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!