Package com.linkedin.restli.internal.common.PathSegment

Examples of com.linkedin.restli.internal.common.PathSegment.MapMap


    //   index values, since the indices may come in any order in the query parameter,
    //   while we want to preserve the order.
    // - second, DataMap only accepts Data objects as values, so ListMaps cannot
    //   be stored there, so using an intermediary structure even for maps.

    MapMap dataMap = new MapMap();

    for (Map.Entry<String, List<String>> entry : queryParameters.entrySet())
    {
      // As per the notation above, we no longer support multiple occurrences of
      // a parameter (considering its full multi-part and indexed name), i.e
      // there should be only a single entry in each list. For backward compatibility
      // as well as ease of use, repeated parameters are still allowed if they
      // are "simple", i.e. they are not multi-part or indexed.
      List<String> valueList = entry.getValue();
      if (valueList.size() == 1)
      {
        String[] key = SEGMENT_DELIMITER_PATTERN.split(entry.getKey());
        parseParameter(key, valueList.get(0), dataMap);
      }
      else
      {
        String parameterName = entry.getKey();
        // In case of multiple parameters ensure they are not delimited or
        // indexed and then simulate the index for each one.
        if(parameterName.indexOf('.') != -1)
          throw new PathSegmentSyntaxException("Multiple values of complex query parameter are not supported");

        if(parameterName.charAt(parameterName.length()-1) == ']')
          throw new PathSegmentSyntaxException("Multiple values of indexed query parameter are not supported");

        if(dataMap.containsKey(parameterName))
          throw new PathSegmentSyntaxException("Conflicting references to key " + parameterName + "[0]");

        else
        {
          dataMap.put(parameterName, new DataList(valueList));
        }
      }
    }

    return (DataMap)convertToDataCollection(dataMap);
View Full Code Here


  private static void parseParameter(String key[], String value, MapMap dataMap) throws PathSegmentSyntaxException
  {
    if (key == null || key.length == 0)
      throw new IllegalArgumentException("Error parsing query parameters: query parameter name cannot be empty");

    MapMap currentMap = dataMap;
    for(int index = 0; index < key.length - 1; index++)
    {
      // get the DataMap referenced by the current path segment
      // and parse the rest of the path recursively
      PathSegment pathSegment = PathSegment.parse(key[index]);
View Full Code Here

    // If this map is not an instance of ListMap, just call this method
    // recursively on every value that is itself a map
    if (map instanceof MapMap)
    {
      DataMap result = new DataMap();
      MapMap mapMap = (MapMap) map;
      for (Entry<String, Object> entry : mapMap.entrySet())
      {
        Object value = entry.getValue();
        if (value instanceof Map<?, ?>)
          value = convertToDataCollection((Map<?, ?>) value);
        result.put(entry.getKey(), value);
View Full Code Here

TOP

Related Classes of com.linkedin.restli.internal.common.PathSegment.MapMap

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.