Package org.soybeanMilk.core.exe.support

Examples of org.soybeanMilk.core.exe.support.ValueArg


    Type argType=null;
    if(strType!=null && strType.length()>0)
      argType=nameToType(strType);
   
    if(strArg==null || strArg.length()==0)
      re=new ValueArg(strArg, argType);
    else
    {
      int len=strArg.length();
      char first=strArg.charAt(0);
      char end=strArg.charAt(len-1);
     
      //数值
      if(Character.isDigit(first))
      {
        Type wrappedType=(argType == null ? null : SbmUtils.wrapType(argType));
       
        if(Byte.class.equals(wrappedType))
        {
          re=new ValueArg(new Byte(strArg), argType);
        }
        else if(Short.class.equals(wrappedType))
        {
          re=new ValueArg(new Short(strArg), argType);
        }
        else if(Integer.class.equals(wrappedType))
        {
          re=new ValueArg(new Integer(strArg), argType);
        }
        else if(Long.class.equals(wrappedType))
        {
          re=new ValueArg(new Long(strArg), argType);
        }
        else if(Float.class.equals(wrappedType))
        {
          re=new ValueArg(new Float(strArg), argType);
        }
        else if(Double.class.equals(wrappedType))
        {
          re=new ValueArg(new Double(strArg), argType);
        }
        else if('L' == end)
        {
          re=new ValueArg(new Long(strArg.substring(0, len-1)), Long.class);
        }
        else if('l' == end)
        {
          re=new ValueArg(new Long(strArg.substring(0, len-1)), long.class);
        }
        else if('F' == end)
        {
          re=new ValueArg(new Float(strArg.substring(0, len-1)), Float.class);
        }
        else if('f'==end)
        {
          re=new ValueArg(new Float(strArg.substring(0, len-1)), float.class);
        }
        else if('D' == end)
        {
          re=new ValueArg(new Double(strArg.substring(0, len-1)), Double.class);
        }
        else if('d' == end)
        {
          re=new ValueArg(new Double(strArg.substring(0, len-1)), double.class);
        }
        else
        {
          boolean point=strArg.indexOf('.') >= 0;
         
          if(point)
            re=new ValueArg(new Double(strArg), argType);
          else
            re=new ValueArg(new Integer(strArg), argType);
        }
      }
      else if(first =='"')
      {
        String ue=SbmUtils.unEscape(strArg);
        len=ue.length();
       
        if(len<2 || ue.charAt(len-1) != '"')
          throw new ParseException("illegal String definition: "+strArg);
       
        if(len == 2)
          re=new ValueArg("", argType);
        else
          re=new ValueArg(ue.subSequence(1, len-1), argType);
      }
      else if(first =='\'')
      {
        String ue=SbmUtils.unEscape(strArg);
        len=ue.length();
       
        if(len!=3 || end!= '\'')
          throw new ParseException("illegal char definition: "+strArg);
       
        re=new ValueArg(ue.charAt(1), argType);
      }
      else if("true".equals(strArg))
      {
        re=new ValueArg(Boolean.TRUE, argType);
      }
      else if("false".equals(strArg))
      {
        re=new ValueArg(Boolean.FALSE, argType);
      }
      else if("null".equals(strArg))
      {
        re=new ValueArg(null, argType);
      }
      else
        re=new KeyArg(strArg, argType);
    }
   
View Full Code Here


 
  @Test
  public void init_byResolver() throws Exception
  {
    Arg[] args=new Arg[]{
        new ValueArg("aaa"),
        new ValueArg("bbb"),
    };
    Resolver rp=new ObjectResolver(new TestResolver());
   
    Invoke re=new Invoke("test", rp,  "test1", args, RESULT_KEY);
   
View Full Code Here

 
  @Test
  public void init_byResolverClass() throws Exception
  {
    Arg[] args=new Arg[]{
        new ValueArg("aaa"),
        new ValueArg("bbb"),
    };
   
    Resolver rp=new ObjectResolver(TestResolver.class);
   
    Invoke re=new Invoke("test", rp, "test1", args, RESULT_KEY);
View Full Code Here

  @Test
  public void execute_similarMethod_valueArg_wrapperType() throws Exception
  {
    {
      Arg[] args=new Arg[]{
          new ValueArg(33D),
        };
     
      Resolver rp=new ObjectResolver(new TestResolver());
     
      Invoke invoke=new Invoke("test", rp, "sameMethod", args, RESULT_KEY);
     
      ObjectSource os=new HashMapObjectSource(new DefaultGenericConverter());
     
      invoke.execute(os);
     
      Assert.assertEquals("Double", os.get(RESULT_KEY));
    }
   
    {
      Arg[] args=new Arg[]{
          new ValueArg(33),
        };
     
      Resolver rp=new ObjectResolver(new TestResolver());
     
      Invoke invoke=new Invoke("test", rp, "sameMethod", args, RESULT_KEY);
View Full Code Here

 
  @Test
  public void execute_similarMethod_valueArg_primitiveType() throws Exception
  {
    Arg[] args=new Arg[]{
        new ValueArg(33, int.class),
      };
   
    Resolver rp=new ObjectResolver(new TestResolver());
   
    Invoke invoke=new Invoke("test", rp, "sameMethod", args, RESULT_KEY);
View Full Code Here

 
  @Test
  public void execute_similarMethod_valueArgNull() throws Exception
  {
    Arg[] args=new Arg[]{
        new ValueArg(null, Integer.class),
      };
   
    Resolver rp=new ObjectResolver(new TestResolver());
   
    Invoke invoke=new Invoke("test", rp, "sameMethod", args, RESULT_KEY);
View Full Code Here

TOP

Related Classes of org.soybeanMilk.core.exe.support.ValueArg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.