You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jeffery Painter <pa...@kiasoft.com> on 2003/06/18 16:51:00 UTC

extending user question

I have successfully extended my user with both boolean fields and String 
fields but I'm having trouble with field types of DOUBLE

Can anyone send me some code snippets or look at mine to see what is 
wrong. I have tried variations on getPerm() setPerm() but it seems
to only like String types in the setPerm() method...

my boolean type works fine using the String method.

any help would be appreciated... I'm still using TDK 2.1.. I know it is 
getting dated, but I can't upgrade at this point... 

also, on another note, I have tried adding some logging info to my 
extended user class and it is not getting called. I fear it has to do with 
the way the user is actually accessed through turbine and all this flux 
stuff... has anyone gotten logging within their extended user to work?


Error:

Caused by: java.lang.NumberFormatException: For input string: 
"TURBINE_USER.COMMISSION_PERCENT" at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at 
java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1213)
        at java.lang.Double.valueOf(Double.java:184)
        at java.lang.Double.<init>(Double.java:259)
        at 
com.kiasoft.ipmanager.util.db.map.TurbineMapBuilderAdapter.getUser_CommissionPercent(TurbineMapBuilderAdapter.java:123)
        at 
com.kiasoft.ipmanager.om.TurbineUserPeerAdapter.<clinit>(TurbineUserPeerAdapter.java:23)


------------------------------------------------------------------------------------------
public class TurbineUserPeerAdapter extends TurbineUserPeer
{
    public static final double COMMISSION_PERCENT = mapBuilder.getUser_CommissionPercent();
}

------------------------------------------------------------------------------------------
TurbineUserAdapter.java

    public void setCommissionPercent(String percent)
    {
        setPerm(COMMISSION_PERCENT, percent);
    }

    public double getCommissionPercent()
    {
        double tmp = 0.0;
        try { tmp = new Double ( (String) getPerm(COMMISSION_PERCENT) ).doubleValue(); }
        catch ( Exception e ) {}
        return tmp;
    }

------------------------------------------------------------------------------------------
TurbineMapBuilderAdapter.java

    public String getCommissionPercent()
    {
        return "COMMISSION_PERCENT";
    }

    public double getUser_CommissionPercent()
    {
        double tmp = 0.0;
        tmp = new Double( getTableUser() + '.' + getCommissionPercent() ).doubleValue();
        return tmp;
    }
------------------------------------------------------------------------------------------



-- 

Jeff Painter
------------
painter@kiasoft.com

http://kiasoft.com
(919) 677-8525


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: extending user question

Posted by Jeffery Painter <pa...@kiasoft.com>.
That did it! with a one modification

Thank you so much... my head was starting to get upset with me...



On Wed, 18 Jun 2003, Quinton McCombs wrote:

> > TurbineUserAdapter.java
> > 
> >     public double getCommissionPercent()
> >     {
> >         double tmp = 0.0;
> >         try { tmp = new Double ( (String) 
> > getPerm(COMMISSION_PERCENT) ).doubleValue(); }
> >         catch ( Exception e ) {}
> >         return tmp;
> >     }
> 
> Change to:
> 
> public double getCommissionPercent()
> {
>     Double temp = getPerm(COMMISSION_PERCENT);
>     return (temp==null ? 0.0 : temp.doubleValue() );
> }


must cast getPerm(COMMISSION_PERCENT) to a double first..

	Double temp = (Double) getPerm(COMMISSION_PERCENT);



-- 

Jeff Painter
------------
painter@kiasoft.com

http://kiasoft.com
(919) 677-8525


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: extending user question

Posted by Quinton McCombs <qm...@nequalsone.com>.
> -----Original Message-----
> From: Jeffery Painter [mailto:painter@kiasoft.com] 
> Sent: Wednesday, June 18, 2003 9:51 AM
> To: Turbine Users List
> Subject: extending user question
> 
> 
> 
> I have successfully extended my user with both boolean fields 
> and String 
> fields but I'm having trouble with field types of DOUBLE
> 
> Can anyone send me some code snippets or look at mine to see what is 
> wrong. I have tried variations on getPerm() setPerm() but it 
> seems to only like String types in the setPerm() method...
> 
> my boolean type works fine using the String method.
> 
> any help would be appreciated... I'm still using TDK 2.1.. I 
> know it is 
> getting dated, but I can't upgrade at this point... 
> 
> also, on another note, I have tried adding some logging info to my 
> extended user class and it is not getting called. I fear it 
> has to do with 
> the way the user is actually accessed through turbine and all 
> this flux 
> stuff... has anyone gotten logging within their extended user to work?
> 
> 
> Error:
> 
> Caused by: java.lang.NumberFormatException: For input string: 
> "TURBINE_USER.COMMISSION_PERCENT" at 
> java.lang.NumberFormatException.forInputString(NumberFormatExc
> eption.java:48)
>         at 
> java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal
> .java:1213)
>         at java.lang.Double.valueOf(Double.java:184)
>         at java.lang.Double.<init>(Double.java:259)
>         at 
> com.kiasoft.ipmanager.util.db.map.TurbineMapBuilderAdapter.get
> User_CommissionPercent(TurbineMapBuilderAdapter.java:123)
>         at 
> com.kiasoft.ipmanager.om.TurbineUserPeerAdapter.<clinit>(Turbi
> neUserPeerAdapter.java:23)
> 
> 
> --------------------------------------------------------------
> ----------------------------
> public class TurbineUserPeerAdapter extends TurbineUserPeer
> {
>     public static final double COMMISSION_PERCENT = 
> mapBuilder.getUser_CommissionPercent();
> }

This code should read as follows:
public class TurbineUserPeerAdapter extends TurbineUserPeer
{
    public static final String COMMISSION_PERCENT =
mapBuilder.getUser_CommissionPercent();
}

> 
> --------------------------------------------------------------
> ----------------------------
> TurbineUserAdapter.java
> 
>     public void setCommissionPercent(String percent)
>     {
>         setPerm(COMMISSION_PERCENT, percent);
>     }

Try this:

public void setCommissionPercent(double percent)
{
    setPerm(COMMISSION_PERCENT, new Double(percent));
}

> 
>     public double getCommissionPercent()
>     {
>         double tmp = 0.0;
>         try { tmp = new Double ( (String) 
> getPerm(COMMISSION_PERCENT) ).doubleValue(); }
>         catch ( Exception e ) {}
>         return tmp;
>     }

Change to:

public double getCommissionPercent()
{
    Double temp = getPerm(COMMISSION_PERCENT);
    return (temp==null ? 0.0 : temp.doubleValue() );
}

> 
> --------------------------------------------------------------
> ----------------------------
> TurbineMapBuilderAdapter.java
> 
>     public String getCommissionPercent()
>     {
>         return "COMMISSION_PERCENT";
>     }
> 
>     public double getUser_CommissionPercent()
>     {
>         double tmp = 0.0;
>         tmp = new Double( getTableUser() + '.' + 
> getCommissionPercent() ).doubleValue();
>         return tmp;
>     }

This method should return a String not a double.  Try the following:

public String getUser_CommissionPercent()
{
	return getTableUSer() + "." + getCommissionPercent();
}


> --------------------------------------------------------------
> ----------------------------
> 
> 
> 
> -- 
> 
> Jeff Painter
> ------------
> painter@kiasoft.com
> 
http://kiasoft.com
(919) 677-8525


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org