Java Question Problem with Library and IDE

keirS

Well-Known Member
Licensed User
Longtime User
A very simple problem. The class below attempts to extend editText. The IDE shows the new property recordSource in the drop down but does not show the two new methods. Why is this please?


B4X:
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.DesignerName;
import anywheresoftware.b4a.objects.*;




@ShortName("DBEditText") 
@ActivityObject 
@Author("KeirS") 
@Version(1.0f) 
@DesignerName("DBEditText")
public class dbedittext extends EditTextWrapper {

    String recordSource = null;
   
   /**
   * Set the recordSource
   */
   public void setRecordSource  (String setSource) {
      
      recordSource = setSource;
      
      
   }
   
   /**
   * Get the recordSource
   */
   public String getRecordSource () {
      return recordSource;
      
            
      
   }
   }
 

keirS

Well-Known Member
Licensed User
Longtime User
This appears to be a problem with Javadoc and BADoclet. If I put a "g" in front of the method names it shows in the IDE. With the names as they are JavaDoc screws up.

B4X:
        <property>
            <name>RecordSource</name>
            <returntype>java.lang.String</returntype>
            <parameter>
                <name>setSource</name>
                <type>java.lang.String</type>
            </parameter>
            <comment>Get the recordSource</comment>

With g in front:

B4X:
- <method>
  <name>ggetRecordSource</name> 
  <comment>Get the recordSource</comment> 
  <returntype>java.lang.String</returntype> 
  </method>
  
- <method>
  <name>gsetRecordSource</name> 
  <comment>Set the recordSource</comment> 
  <returntype>void</returntype> 
- <parameter>
  <name>setSource</name> 
  <type>java.lang.String</type> 
  </parameter>
  </method>

Very odd behaviour.
 

warwound

Expert
Licensed User
Longtime User
You can use an upper case G and S if you want to ensure these methods remain methods instead of becoming properties:

B4X:
    /**
    * Set the recordSource
    */
    public void SetRecordSource  (String setSource) {
        recordSource = setSource;
    }
    
    /**
    * Get the recordSource
    */
    public String GetRecordSource () {
        return recordSource;
    }

Note that lower case get??? and set??? methods are not always converted from methods into properties, for example passing one or more parameters:

B4X:
public int getSum(int A, int B){
    return A+B;
}

public void setMyValues(int Value1, int Value2){
    // do something with Value1 and Value 2 here
}

Neither of these two methods will be automatically converted to properties.
It not possible to convert a getter which accepts a parameter to a property and likewise it's not possible to convert a setter which accepts more than one parameter to a property.

Martin.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…