Package org.jabsorb.serializer

Examples of org.jabsorb.serializer.ObjectMatch


    @Override
    public ObjectMatch tryUnmarshall(final SerializerState state,
                                     final Class<?> clazz, final Object jso)
            throws UnmarshallException {
        final ObjectMatch toReturn;
        if (jso instanceof StatusCodes) {
            toReturn = ObjectMatch.OKAY;
        } else {
            toReturn = ObjectMatch.ROUGHLY_SIMILAR;
        }
View Full Code Here


      if (best == null)
      {
        best = c;
        continue;
      }
      final ObjectMatch bestMatch = best.getMatch();
      final ObjectMatch cMatch = c.getMatch();
      if (bestMatch.getMismatch() > cMatch.getMismatch())
      {
        best = c;
      }
      else if (bestMatch.getMismatch() == cMatch.getMismatch())
      {
        best = betterSignature(best, c);
      }
    }
    if (best != null)
View Full Code Here

      }
      if (mismatch == -1)
      {
        return ObjectMatch.OKAY;
      }
      return new ObjectMatch(mismatch);
    }
View Full Code Here

      throw new UnmarshallException("Could not read dictionary: " + e.getMessage(), e);
    }
    if (jsondictionary == null) {
      throw new UnmarshallException("nsdictionary missing");
    }
    ObjectMatch m = new ObjectMatch(-1);
    Iterator i = jsondictionary.keys();
    String key = null;
    state.setSerialized(o, m);
    try {
      while (i.hasNext()) {
        key = (String) i.next();
        m.setMismatch(ser.tryUnmarshall(state, null, jsondictionary.get(key)).max(m).getMismatch());
      }
    }
    catch (UnmarshallException e) {
      throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
    }
View Full Code Here

      JSONObject jsonset = jso.getJSONObject("set");
      if (jsonset == null) {
        throw new UnmarshallException("set missing");
      }

      ObjectMatch m = new ObjectMatch(-1);

      Iterator i = jsonset.keys();
      String key = null;

      try {
View Full Code Here

    if (match == 0) {
      throw new UnmarshallException("bean has no matches");
    }

    // create a concrete ObjectMatch that is always returned in order to satisfy circular reference requirements
    ObjectMatch returnValue = new ObjectMatch(-1);
    state.setSerialized(o, returnValue);

    ObjectMatch m = null;
    ObjectMatch tmp;
    Iterator<String> i = jso.keys();
    while (i.hasNext()) {
      String field = i.next();
      Method setMethod = bd.writableProps.get(field);
      if (setMethod != null) {
        try {
          Class<?> param[] = setMethod.getParameterTypes();
          if (param.length != 1) {
            throw new UnmarshallException("bean " + clazz.getName() + " method " + setMethod.getName() + " does not have one arg");
          }
          tmp = ser.tryUnmarshall(state, param[0], jso.get(field));
          if (tmp != null) {
            if (m == null) {
              m = tmp;
            }
            else {
              m = m.max(tmp);
            }
          }
        }
        catch (UnmarshallException e) {
          throw new UnmarshallException("bean " + clazz.getName() + " " + e.getMessage(), e);
        }
        catch (JSONException e) {
          throw new UnmarshallException("bean " + clazz.getName() + " " + e.getMessage(), e);
        }
      }
      else {
        mismatch++;
      }
    }
    if (m != null) {
      returnValue.setMismatch(m.max(new ObjectMatch(mismatch)).getMismatch());
    }
    else {
      returnValue.setMismatch(mismatch);
    }
    return returnValue;
View Full Code Here

    }
    if (jsonNSArray == null) {
      throw new UnmarshallException("nsarray missing");
    }
    int i = 0;
    ObjectMatch m = new ObjectMatch(-1);
    state.setSerialized(o, m);
    try {
      for (; i < jsonNSArray.length(); i++) {
        m.setMismatch(ser.tryUnmarshall(state, null, jsonNSArray.get(i)).max(m).getMismatch());
      }
    }
    catch (UnmarshallException e) {
      throw new UnmarshallException("element " + i + " " + e.getMessage(), e);
    }
View Full Code Here

TOP

Related Classes of org.jabsorb.serializer.ObjectMatch

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.