Package fit

Examples of fit.TypeAdapter


  public static boolean callEqualsMethod(Class<?> type, Object o1, Object o2)
  throws Exception
  {
    boolean result = false;

    TypeAdapter ta = TypeAdapter.adapterFor(type);
    if (ta != null &&
        !ta.getClass().equals(fit.TypeAdapter.class))
    {
      result = ta.equals(o1, ta.parse(o2.toString()));
    }
    else
    {
      Method m = type.getMethod("equals",
          new Class[] {Object.class});
View Full Code Here


      // is it a static class.field?
      Object ret = getStaticField(parameter);
      if (ret != null)
        return ret;

      TypeAdapter ta = TypeAdapter.adapterFor(paramType);
      //debug(paramType + " Parameter: [" + parameter + "] " + ta.getClass());
      if (ta != null &&
          !ta.getClass().equals(fit.TypeAdapter.class)
      )
      {
        //debug("Inside Parameter: [" + parameter + "] " + ta.getClass());
        try
        {
          if (paramType.isArray() && parameter.startsWith(ARRAY))
          {
            ta.init(this, paramType);
            Class<?> componentType = paramType.getComponentType();
            TypeAdapter cta = TypeAdapter.on(this, componentType);
            //debug(cta + " - componentType: " + componentType.getCanonicalName());

            String[] arrStr = parameter.substring(ARRAY.length()).split(",");
            paramObject = Array.newInstance(componentType, arrStr.length);
            for (int i=0; i < arrStr.length; i++) {
              String token = arrStr[i].trim();
              Object var = fetchVariable(token);
              if (var == null) {
                var = cta.parse(token);
                //debug(var + " - i: " + i + " - " + token);
              }
              Array.set(paramObject, i, var);
            }
          }
View Full Code Here

        storeVariable(re.varName, actual);
      else if (this.target != null && this.targetClass.equals(returnType))
        this.target = actual;
    }

    TypeAdapter ta = TypeAdapter.adapterFor(returnType);
    ta.init(this, returnType);

    if (returnType.isArray())
    {
      if (re.startReturnVals > 0 && re.returnVals.length > 0)
      {           
        if (actual == null && re.returnVals[0] == null)
          re.right();
        else
        {
          Object expected = null;

          Object v = fetchVariable(re.returnVals[0]);
          if (v != null)
          {
            // its a variable name
            expected = v;
            re.addText(re.startReturnVals, ta.toString(expected));
          }
          else
          {
            // need to parse comma delimited string into array
            expected = ta.parse(re.returnVals[0]);
          }

          if (ta.equals(expected, actual))
            re.right();
          else
            re.wrong(ta.toString(actual));
        }
      }
      else
        re.addText(ta.toString(actual));
    }
    else
    {
      if (re.startReturnVals > 0 && re.returnVals.length > 0)
      {
View Full Code Here

    boolean isNull = text.toLowerCase().equals("<null>");
    if (isNull) {
      return null;
    }

    TypeAdapter ta = TypeAdapter.adapterFor(this.type);
    boolean isTypeAdapter = ta.getClass().equals(TypeAdapter.class);
    if (isTypeAdapter) {
      return super.parse(text);
    } else {
      return ta.parse(text);
    }
  }
View Full Code Here

      String text = cells.text();
      try {
        MethodAccessor methodAccessor = new MethodAccessor<Object>(this, parsePropertyMethodName, String.class);
        return methodAccessor.invoke(this, new Object[] { text });
      } catch (NoSuchMethodRuntimeException e) {
        TypeAdapter typeAdapter = TypeAdapter.on(this, dtoClazz);
        return typeAdapter.parse(text);
      }
    }
    Object obj = dtoClazz.newInstance();

    for (int i = 0; cells != null && i < bindings.length; i++, cells = cells.more) {
View Full Code Here

        if (type.equals(String.class) && Options.isFixedLengthStringParsing() &&
                trim.startsWith("'") && trim.endsWith("'")) {
            return trim.substring(1, trim.length() - 1);
        }

        TypeAdapter ta = TypeAdapter.adapterFor(type);
        ta.init(fixture, type);

        return ta.parse(s);
    }
View Full Code Here

TOP

Related Classes of fit.TypeAdapter

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.