Projects >> fongo >>bc622ef708c1a5a0499bb8759c2d266424c53a23

Chunk
Conflicting content
  public final static String AND = "$and";
  public final static String REGEX = "$regex";
  public final static String REGEX_OPTIONS = "$options";
<<<<<<< HEAD
  public final static String TYPE = "$type";
=======
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
  public final static String NEAR = "$near";
  public final static String NEARSPHERE = "$nearSphere";
  public final static String MAXDISTANCE = "$maxDistance";
Solution content
  public final static String AND = "$and";
  public final static String REGEX = "$regex";
  public final static String REGEX_OPTIONS = "$options";
  public final static String TYPE = "$type";
  public final static String NEAR = "$near";
  public final static String NEARSPHERE = "$nearSphere";
  public final static String MAXDISTANCE = "$maxDistance";
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Attribute
Chunk
Conflicting content
  // TODO : http://docs.mongodb.org/manual/reference/operator/query-geospatial/
  // TODO : http://docs.mongodb.org/manual/reference/operator/geoWithin/#op._S_geoWithin
  // TODO : http://docs.mongodb.org/manual/reference/operator/geoIntersects/
<<<<<<< HEAD



  private static class Null {
  }

  private static final Map CLASS_TO_WEIGHT;

  static {
    // http://docs.mongodb.org/manual/reference/operator/type
    Map map = new HashMap();
//    map.put(Double.class, 1);
//    map.put(Float.class, 1);
//    map.put(String.class, 2);
//    map.put(Object.class, 3);
//    map.put(BasicDBList.class, 4);
//    map.put(LazyBSONList.class, 4);
//    map.put(ObjectId.class, 6);
//    map.put(Boolean.class, 7);
//    map.put(Date.class, 9);
//    map.put(Null.class, 10);
//    map.put(Pattern.class, 11);
//    map.put(Integer.class, 16);
////    map.put(Timestamp.class, 17);
//    map.put(Long.class, 18);
//    map.put(MinKey.class, -1); // 255
//    map.put(MaxKey.class, 127);
    map.put(MinKey.class, Integer.MIN_VALUE);
    map.put(Null.class, 0);
    map.put(Double.class, 1);
    map.put(Float.class, 1);
    map.put(Integer.class, 1);
    map.put(Long.class, 1);
    map.put(Short.class, 1);
    map.put(String.class, 2);
    map.put(Object.class, 3);
    map.put(BasicDBList.class, 4);
    map.put(LazyBSONList.class, 4);
    map.put(BasicDBObject.class, 4);
    map.put(LazyDBObject.class, 4);
    map.put(byte[].class, 5);
    map.put(ObjectId.class, 6);
    map.put(Boolean.class, 7);
    map.put(Date.class, 8);
    map.put(Pattern.class, 9);
//    map.put(Timestamp.class, 17);
    map.put(MaxKey.class, Integer.MAX_VALUE);

    CLASS_TO_WEIGHT = Collections.unmodifiableMap(map);
  }
=======
  public final static String TYPE = "$type";
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af

  public class ObjectComparator implements Comparator {
    private final int asc;
Solution content
  // TODO : http://docs.mongodb.org/manual/reference/operator/query-geospatial/
  // TODO : http://docs.mongodb.org/manual/reference/operator/geoWithin/#op._S_geoWithin
  // TODO : http://docs.mongodb.org/manual/reference/operator/geoIntersects/

  private static class Null {
  }

  private static final Map CLASS_TO_WEIGHT;

  static {
    // http://docs.mongodb.org/manual/reference/operator/type
    Map map = new HashMap();
//    map.put(Double.class, 1);
//    map.put(Float.class, 1);
//    map.put(String.class, 2);
//    map.put(Object.class, 3);
//    map.put(BasicDBList.class, 4);
//    map.put(LazyBSONList.class, 4);
//    map.put(ObjectId.class, 6);
//    map.put(Boolean.class, 7);
//    map.put(Date.class, 9);
//    map.put(Null.class, 10);
//    map.put(Pattern.class, 11);
//    map.put(Integer.class, 16);
////    map.put(Timestamp.class, 17);
//    map.put(Long.class, 18);
//    map.put(MinKey.class, -1); // 255
//    map.put(MaxKey.class, 127);
    map.put(MinKey.class, Integer.MIN_VALUE);
    map.put(Null.class, 0);
    map.put(Double.class, 1);
    map.put(Float.class, 1);
    map.put(Integer.class, 1);
    map.put(Long.class, 1);
    map.put(Short.class, 1);
    map.put(String.class, 2);
    map.put(Object.class, 3);
    map.put(BasicDBList.class, 4);
    map.put(LazyBSONList.class, 4);
    map.put(BasicDBObject.class, 4);
    map.put(LazyDBObject.class, 4);
    map.put(byte[].class, 5);
    map.put(ObjectId.class, 6);
    map.put(Boolean.class, 7);
    map.put(Date.class, 8);
    map.put(Pattern.class, 9);
//    map.put(Timestamp.class, 17);
    map.put(MaxKey.class, Integer.MAX_VALUE);

    CLASS_TO_WEIGHT = Collections.unmodifiableMap(map);
  }

  public class ObjectComparator implements Comparator {
    private final int asc;
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Attribute
Class declaration
Static initializer
Chunk
Conflicting content
  List filterFactories = Arrays.asList(
      new ConditionalOperatorFilterFactory(GTE) {
        boolean singleCompare(Object queryValue, Object storedValue) {
<<<<<<< HEAD
          Integer result = compareObjects(queryValue, storedValue, true);
=======
          Integer result = compareObjects(queryValue, storedValue);
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
          return result != null && result.intValue() <= 0;
        }
      },
Solution content
  List filterFactories = Arrays.asList(
      new ConditionalOperatorFilterFactory(GTE) {
        boolean singleCompare(Object queryValue, Object storedValue) {
          Integer result = compareObjects(queryValue, storedValue, true);
          return result != null && result.intValue() <= 0;
        }
      },
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
      },
      new ConditionalOperatorFilterFactory(LTE) {
        boolean singleCompare(Object queryValue, Object storedValue) {
<<<<<<< HEAD
          Integer result = compareObjects(queryValue, storedValue, true);
=======
          Integer result = compareObjects(queryValue, storedValue);
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
          return result != null && result.intValue() >= 0;
        }
      },
Solution content
      },
      new ConditionalOperatorFilterFactory(LTE) {
        boolean singleCompare(Object queryValue, Object storedValue) {
          Integer result = compareObjects(queryValue, storedValue, true);
          return result != null && result.intValue() >= 0;
        }
      },
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
      },
      new ConditionalOperatorFilterFactory(GT) {
        boolean singleCompare(Object queryValue, Object storedValue) {
<<<<<<< HEAD
          Integer result = compareObjects(queryValue, storedValue, true);
=======
          Integer result = compareObjects(queryValue, storedValue);
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
          return result != null && result.intValue() < 0;
        }
      },
Solution content
      },
      new ConditionalOperatorFilterFactory(GT) {
        boolean singleCompare(Object queryValue, Object storedValue) {
          Integer result = compareObjects(queryValue, storedValue, true);
          return result != null && result.intValue() < 0;
        }
      },
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
      },
      new ConditionalOperatorFilterFactory(LT) {
        boolean singleCompare(Object queryValue, Object storedValue) {
<<<<<<< HEAD
          Integer result = compareObjects(queryValue, storedValue, true);
=======
          Integer result = compareObjects(queryValue, storedValue);
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
          return result != null && result.intValue() > 0;
        }
      },
Solution content
      },
      new ConditionalOperatorFilterFactory(LT) {
        boolean singleCompare(Object queryValue, Object storedValue) {
          Integer result = compareObjects(queryValue, storedValue, true);
          return result != null && result.intValue() > 0;
        }
      },
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
          return createPatternFilter(path, pattern);
        }
      },
<<<<<<< HEAD
=======
      new NearCommandFilterFactory(NEARSPHERE, true),
      new NearCommandFilterFactory(NEAR, false),
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
      new BasicCommandFilterFactory(TYPE) {
        @Override
        public Filter createFilter(final List path, DBObject refExpression) {
Solution content
          return createPatternFilter(path, pattern);
        }
      },
      new NearCommandFilterFactory(NEARSPHERE, true),
      new NearCommandFilterFactory(NEAR, false),
      new BasicCommandFilterFactory(TYPE) {
        @Override
        public Filter createFilter(final List path, DBObject refExpression) {
File
ExpressionParser.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
        }

          return createTypeFilter(path, type.intValue());
<<<<<<< HEAD
      },
      new NearCommandFilterFactory(NEARSPHERE, true),
      new NearCommandFilterFactory(NEAR, false)
=======
      }
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
  );

  boolean objectMatchesPattern(Object obj, Pattern pattern) {
Solution content
          return createTypeFilter(path, type.intValue());
        }
      }
  );

  boolean objectMatchesPattern(Object obj, Pattern pattern) {
File
ExpressionParser.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
   * @return
   */
  @SuppressWarnings("all")
<<<<<<< HEAD
  public Integer compareObjects(Object queryValue, Object storedValue, boolean comparableFilter) {
=======
  public Integer compareObjects(Object queryValue, Object storedValue) {
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
    LOG.debug("comparing {} and {}", queryValue, storedValue);

    if (queryValue instanceof DBObject && storedValue instanceof DBObject) {
Solution content
   * @return
   */
  @SuppressWarnings("all")
  public Integer compareObjects(Object queryValue, Object storedValue, boolean comparableFilter) {
    LOG.debug("comparing {} and {}", queryValue, storedValue);

    if (queryValue instanceof DBObject && storedValue instanceof DBObject) {
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method signature
Chunk
Conflicting content
      if (storedComp == null) {
      List storedList = (List) storedValue;
      return compareLists(queryList, storedList);
    } else {
<<<<<<< HEAD
      Object queryComp = typecast("query value", queryValue, Object.class);
      if (comparableFilter && !(storedValue instanceof Comparable)) {
        return null;
      }
      Object storedComp = typecast("stored value", storedValue, Object.class);
      return compareTo(queryComp, storedComp);
    }
  }

  //@VisibleForTesting
  protected int compareTo(Object c1, Object c2) { // Object to handle MinKey/MaxKey
    Object cc1 = c1;
    Object cc2 = c2;
    Class clazz1 = c1 == null ? Null.class : c1.getClass();
    Class clazz2 = c2 == null ? Null.class : c2.getClass();
    // Not comparable for MinKey/MaxKey
    if (!clazz1.equals(clazz2) || !(cc1 instanceof Comparable)) {
      boolean checkTypes = true;
      if (cc1 instanceof Number) {
        if (cc2 instanceof Number) {
          cc1 = new BigDecimal(cc1.toString());
          cc2 = new BigDecimal(cc2.toString());
          checkTypes = false;
        }
      }
      if(checkTypes) {
        Integer type1 = CLASS_TO_WEIGHT.get(clazz1);
        Integer type2 = CLASS_TO_WEIGHT.get(clazz2);
        if (type1 != null && type2 != null) {
          cc1 = type1;
          cc2 = type2;
        } else {
          throw new FongoException("Don't know how to compare " + cc1.getClass() + " and " + cc2.getClass() + " values are : " + c1 + " vs " + c2);
        }
=======
      Comparable queryComp = typecast("query value", queryValue, Comparable.class);
      if(!(storedValue instanceof Comparable) && storedValue != null) {
        return null;
      }
      Comparable storedComp = typecast("stored value", storedValue, Comparable.class);
        return 1;
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
      }
    }
Solution content
      List storedList = (List) storedValue;
      return compareLists(queryList, storedList);
    } else {
      Object queryComp = typecast("query value", queryValue, Object.class);
      if (comparableFilter && !(storedValue instanceof Comparable)) {
        return null;
      }
      Object storedComp = typecast("stored value", storedValue, Object.class);
      return compareTo(queryComp, storedComp);
    }
  }

  //@VisibleForTesting
  protected int compareTo(Object c1, Object c2) { // Object to handle MinKey/MaxKey
    Object cc1 = c1;
    Object cc2 = c2;
    Class clazz1 = c1 == null ? Null.class : c1.getClass();
    Class clazz2 = c2 == null ? Null.class : c2.getClass();
    // Not comparable for MinKey/MaxKey
    if (!clazz1.equals(clazz2) || !(cc1 instanceof Comparable)) {
      boolean checkTypes = true;
      if (cc1 instanceof Number) {
        if (cc2 instanceof Number) {
          cc1 = new BigDecimal(cc1.toString());
          cc2 = new BigDecimal(cc2.toString());
          checkTypes = false;
        }
      }
      if(checkTypes) {
        Integer type1 = CLASS_TO_WEIGHT.get(clazz1);
        Integer type2 = CLASS_TO_WEIGHT.get(clazz2);
        if (type1 != null && type2 != null) {
          cc1 = type1;
          cc2 = type2;
        } else {
          throw new FongoException("Don't know how to compare " + cc1.getClass() + " and " + cc2.getClass() + " values are : " + c1 + " vs " + c2);
        }
      }
    }
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Comment
If statement
Method invocation
Method signature
Return statement
Variable
Chunk
Conflicting content
    };
  }

<<<<<<< HEAD
  public Filter createTypeFilter(final List path, final int type) {
    return new Filter() {
      public boolean apply(DBObject o) {
        List storedOption = getEmbeddedValues(path, o);
        if (storedOption.isEmpty()) {
          return false;
        } else {
          for (Object storedValue : storedOption) {
            if (storedValue instanceof Collection) {
              for (Object object : (Collection) storedValue) {
                if (objectMatchesType(object, type)) {
                  return true;
                }
              }
            } else if (objectMatchesType(storedValue, type)) {
              return true;
            }
          }
          return false;
        }
      }
    };
  }

=======
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
  // Take care of : https://groups.google.com/forum/?fromgroups=#!topic/mongomapper/MfRDh2vtCFg
  public Filter createNearFilter(final List path, final List coordinates, final Number maxDistance, final boolean sphere) {
    return new Filter() {
Solution content
    };
  }

  public Filter createTypeFilter(final List path, final int type) {
    return new Filter() {
      public boolean apply(DBObject o) {
        List storedOption = getEmbeddedValues(path, o);
        if (storedOption.isEmpty()) {
          return false;
        } else {
          for (Object storedValue : storedOption) {
            if (storedValue instanceof Collection) {
              for (Object object : (Collection) storedValue) {
                if (objectMatchesType(object, type)) {
                  return true;
                }
              }
            } else if (objectMatchesType(storedValue, type)) {
              return true;
            }
          }
          return false;
        }
      }
    };
  }

  // Take care of : https://groups.google.com/forum/?fromgroups=#!topic/mongomapper/MfRDh2vtCFg
  public Filter createNearFilter(final List path, final List coordinates, final Number maxDistance, final boolean sphere) {
    return new Filter() {
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method declaration
Chunk
Conflicting content
          limit--;
        }
        return result;
<<<<<<< HEAD
=======
      }
    };
  }

  public Filter createTypeFilter(final List path, final int type) {
    return new Filter() {
      public boolean apply(DBObject o) {
        List storedOption = getEmbeddedValues(path, o);
        if (storedOption.isEmpty()) {
          return false;
        } else {
          for (Object storedValue : storedOption) {
            if (storedValue instanceof Collection) {
              for (Object object : (Collection) storedValue) {
                if (objectMatchesType(object, type)) {
                  return true;
                }
              }
            } else if (objectMatchesType(storedValue, type)) {
              return true;
            }
          }
          return false;
        }
>>>>>>> 12027f6b63a54486dca494dc73bfb86ea86c73af
      }
    };
  }
Solution content
          limit--;
        }
        return result;
      }
    };
  }
File
ExpressionParser.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Method signature
Return statement