Skip to main content
gamedev.net
🔒 Locked

[java] Problem with Beans

Started by aidan_walsh 1 reply 500+ views
Original Post
aidan_walsh
aidan_walsh
I''m having a problem getting my class to work properly through java.beans.XMLEncoder.writeObject() What I want is for the XML file to contain both the class header and the data inside in the Vector. I''ve never really used Beans before, but the tutorials I have read basically say that as long as you implement Serializable you should have no bother... Yet all I get is the basic class header in the XML file. Can anybody tell me what I need to do to get this working? Thanks in advance!
public class FileStructure implements Serializable
{
  Vector fileStructure = new Vector();

  public void addDirectory(File root, boolean subfolders) throws
      InvalidDirectoryException
  {
    
  }

  public void addFiles(File[] target) throws InvalidFileException
  {
    
  }

  public void remove(File root) throws IOException
  {
    
  }

  public File[] describe()
  {
    
  }

  public DefaultMutableTreeNode describeAsTree()
  {
   
  }

  public long count()
  {
    
  }

  public class InvalidDirectoryException extends Exception
  {
    
  }

  public class InvalidFileException extends Exception
  {
    
  }
}
 

SketchSoft OFFLINE | SketchNews OFFLINE | NewKlear Studios

www.aidanwalsh(.net)(.info)
-vic-
-vic-
Took a fast look at your source, but from what i saw there''s apparently no getFileStructure() method on your class.

If there isn a ''getter'' for the property, the reflection can''t get the property, so it won''t encode it in XML.

Victor.
c[_]~~
aidan_walsh
aidan_walsh
I''ve since added getFileStructure to the file, but still no avail... I''m just thinking now that its down to no similar function in Vectors by default, and that I may have to extend the Vector rather than instansiate it... Have to take a look at it tonight...


SketchSoft OFFLINE | SketchNews OFFLINE | NewKlear Studios

www.aidanwalsh(.net)(.info)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.