Class MongoComplexUtilities


  • public final class MongoComplexUtilities
    extends Object
    This class contains utilities methods for dealing with MongoDB complex features.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String MONGO_PARENT_PATH  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Feature extractFeature​(Object feature, String jsonPath)  
      static Feature extractFeature​(Feature feature, String jsonPath)
      Method for extracting or casting a feature from the provided object.
      static Map<String,​Class> findMappings​(DBCursor cursor)
      Compute the mappings for a mongodb cursor(iterator), this can be used to create a feature mapping.
      static Map<String,​Class> findMappings​(DBObject dbObject)
      Compute the mappings for a mongo db object, this can be used to create a feature mapping.
      static Object getValue​(DBObject mongoObject, String jsonPath, Supplier<GeometryCoordinateSequenceTransformer> transformer)
      Will extract from the mongo db object the value that correspond to the given json path.
      static Object getValue​(DBObject mongoObject, Map<String,​Integer> collectionsIndexes, String jsonPath, Supplier<GeometryCoordinateSequenceTransformer> transformer)
      Will extract from the mongo db object the value that correspond to the given json path.
      static Object getValue​(Object object, String jsonPath)
      Will try to extract from the provided object the value that correspond to the given json path.
      static Object getValues​(DBObject dbObject, String jsonPath, Supplier<GeometryCoordinateSequenceTransformer> transformer)
      Will extract from the mongo db object all the values that correspond to the given json path.
      static Object getValues​(Object object, String jsonPath)
      Will try to extract from the provided object all the values that correspond to the given json path.
      static String resolvePath​(Feature feature, String jsonPath)
      Concat the parent path if it exists to the provided JSON path.
      static void setParentPath​(Feature feature, String parentPath)
      Store the parent path in a feature user data map.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • resolvePath

        public static String resolvePath​(Feature feature,
                                         String jsonPath)
        Concat the parent path if it exists to the provided JSON path.
      • setParentPath

        public static void setParentPath​(Feature feature,
                                         String parentPath)
        Store the parent path in a feature user data map.
      • getValue

        public static Object getValue​(Object object,
                                      String jsonPath)
        Will try to extract from the provided object the value that correspond to the given json path.
      • extractFeature

        public static Feature extractFeature​(Object feature,
                                             String jsonPath)
      • extractFeature

        public static Feature extractFeature​(Feature feature,
                                             String jsonPath)
        Method for extracting or casting a feature from the provided object.
      • getValue

        public static Object getValue​(DBObject mongoObject,
                                      String jsonPath,
                                      Supplier<GeometryCoordinateSequenceTransformer> transformer)
        Will extract from the mongo db object the value that correspond to the given json path. If the path contain a nested list of values an exception will be throw.
      • getValue

        public static Object getValue​(DBObject mongoObject,
                                      Map<String,​Integer> collectionsIndexes,
                                      String jsonPath,
                                      Supplier<GeometryCoordinateSequenceTransformer> transformer)
        Will extract from the mongo db object the value that correspond to the given json path. The provided collections indexes will be used to select the proper element for the collections present in the path.
      • getValues

        public static Object getValues​(Object object,
                                       String jsonPath)
        Will try to extract from the provided object all the values that correspond to the given json path.
      • getValues

        public static Object getValues​(DBObject dbObject,
                                       String jsonPath,
                                       Supplier<GeometryCoordinateSequenceTransformer> transformer)
        Will extract from the mongo db object all the values that correspond to the given json path. If the path contains nested collections the values from all the branches will be merged.
      • findMappings

        public static Map<String,​Class> findMappings​(DBObject dbObject)
        Compute the mappings for a mongo db object, this can be used to create a feature mapping.
      • findMappings

        public static Map<String,​Class> findMappings​(DBCursor cursor)
        Compute the mappings for a mongodb cursor(iterator), this can be used to create a feature mapping. This method will close the cursor.