[jdom-interest] Exception: org.jdom.ContentList$FilterList

Azrael azrael at azrael-uk.f2s.com
Wed Aug 28 16:09:42 PDT 2002


I decided for simplicity to just read the whole file into memory, into 
an ArrayList and then do nextElement() and hasMoreElements() consulting 
that ... as someone suggested.
However... true to form..  I have another problem.. and am not sure 
what's causing it.

The Exception getMessage() is:

org.jdom.ContentList$FilterList

the code that results in the error is:

   try
   {  breadthFirstList=new ArrayList();
      if(document.getRootElement() != null) // not empty document
      {	
	Element currentElement = document.getRootElement();
	// create temp pointer to root element

	ArrayList list=new ArrayList();
	int cursor = 0;
	// keep track of position in array list
	
	list.add(currentElement); // add root to arraylist
			
	while(cursor < list.size())
	{
	  currentElement = (Element)list.get(cursor);
	  ArrayList temp=(ArrayList)currentElement.getChildren();
				
	  for(int i=0;i < temp.size();i++)
	  {
	    list.add(temp.get(i));
	  }
	  cursor++;
	}
	breadthFirstList=list;
		
	lastElement = 0;
     }
     else lastElement = -1;
   }
   catch(Exception ex)
   {	System.out.println(ex.getMessage());
   }

I suspect the problem is thrown somewhere along the line of:

ArrayList temp=(ArrayList)currentElement.getChildren();

And trying to get the document root returns null.. so perhaps the 
creation of the document has failed.
But that uses:
document=new org.jdom.input.SAXBuilder().build(filename);

where 'filename' is a File object.. and I know that there isn't a 
problem with the wrong file being passed.

Does this ring any bells for more experienced users of jdom ?

thanks..

-- Azrael




More information about the jdom-interest mailing list