The Artima Developer Community
Sponsored Link

Java Answers Forum
Reading From File

1 reply on 1 page. Most recent reply: Aug 19, 2002 8:43 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Janu

Posts: 8
Nickname: janu
Registered: May, 2002

Reading From File Posted: Aug 17, 2002 1:51 AM
Reply to this message Reply
Advertisement
I am developing a tool Called Bean Developer.
Which Creates JavaBeans on providing the properties and there data types and the Class Name.

For example i want to create bean with property name

I will provide the following for the Applet
(UI is designed to accept all this stuff)
Class name : LoginFormBean

Property Name : name
Property Data Type : String


This Creates the following java File
LoginFormBean.java
public class LoginFormBean
{
   private String _name;
   
   public void setName(String name)
   {
       _name = name;
   }
   public String getName()
   {
        return _name;
   }
  
}


Creating Beans is working fine.
Problem lies in Editing the Bean.I want to editing Bean,like adding properties or deleting properties etc.

So how can i read all the properties available from the given java file

Any help will be appreciated.


Thanx
Janu


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Reading From File Posted: Aug 19, 2002 8:43 AM
Reply to this message Reply
Class bean = Class.forName("LoginFormBean");
Method[] methods = bean.getDeclaredMethods();
for (int i =0;i< methods.length;i++){
     String nextMethod = methods[i].getName();
     if (nextMethod.indexOf("get") == 0){
 
         System.out.println("Bean Property: " +   nextMethod.subString(3));
     }
}

Flat View: This topic has 1 reply on 1 page
Topic: Telnet Previous Topic   Next Topic Topic: passing serialized object from servlet to applet

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use