Helper for converting from a Map&lt;String, byte[]&gt; metadata map that may be in a
StorageObject into a Map&lt;String, String&gt; suitable for placement inside a
GoogleCloudStorageItemInfo.
519566
@VisibleForTesting
  static Map<String, String> encodeMetadata(Map<String, byte[]> metadata) {
    return Maps.transformValues(metadata, ENCODE_METADATA_VALUES);
  }
767540
public static String serializeMetaData(Map<String, List<String>> metaData) {
        StringBuilder buf = new StringBuilder();
        if (metaData != null && metaData.size() > 0) {
            buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
            for (String key : metaData.keySet()) {
                List<String> value = metaData.get(key);
                for (String v : value) {
                    buf.append("<value name=\"").append(key).append("\">");
                    buf.append(StringUtils.escapeForXmlText(v));
                    buf.append("</value>");
                }
            }
            buf.append("</metadata>");
        }
        return buf.toString();
    }
201568
String tagsToString(Map<String, String> tagMap) {
        StringBuilder sb = new StringBuilder();
        for (String key : tagMap.keySet()) {
            // Skip some tags
            if (key.equalsIgnoreCase("created_by")) {
                continue;
            }
            if (sb.length() > 0) {
                sb.append('\r');
            }
            sb.append(key).append('=').append(tagMap.get(key));
        }
        return sb.toString();
    }
221564
public Map<String, String> decode(byte[] bytes) throws DeserializationException {
        Map<String, String> map = new HashMap<String, String>();
        if (bytes == null || bytes.length == 0) {
            return map;
        }

        UnsafeByteArrayInputStream in = new UnsafeByteArrayInputStream(bytes);
        try {
            while (in.available() > 0) {
                String key = readString(in);
                String value = readString(in);
                map.put(key, value);
            }
            return map;
        } catch (IOException ex) {
            throw new DeserializationException(ex.getMessage(), ex);
        }
    }
380556
def encrypt_metadata(keys, fileName, fileType='application/octet-stream'):
    ''''''
    metadata = json.dumps({'iv' : unpadded_urlsafe_b64encode(keys.encryptIV), 'name' : fileName, 'type' : fileType}, sort_keys=True)

    cipher = Cryptodome.Cipher.AES.new(keys.metaKey, Cryptodome.Cipher.AES.MODE_GCM, keys.metaIV)
    encMeta, gcmTag = cipher.encrypt_and_digest(metadata.encode())

    # WebcryptoAPI expects the gcm tag at the end of the ciphertext, return them concatenated
    return encMeta + gcmTag
8421
@Override
  public void addEncryptionMetadata(StorageObjectMetadata meta,
                                    MatDesc matDesc,
                                    byte[] ivData,
                                    byte[] encKeK,
                                    long contentLength)
  {
    meta.addUserMetadata(getMatdescKey(),
                         matDesc.toString());
    meta.addUserMetadata(AZ_ENCRYPTIONDATAPROP, buildEncryptionMetadataJSON(
        Base64.encodeAsString(ivData),
        Base64.encodeAsString(encKeK))
    );
    meta.setContentLength(contentLength);
  }
560889
public Map<String, Object> toMap() {
        Map<String, Object> ret = new HashMap<>();
        ret.put(MetricUploader.METRIC_TIME, timestamp);
        ret.put(MetricUploader.METRIC_TYPE, type);
        
        return ret;
    }
839512
private Map<String, Object> documentToPackableMap(Map<String, Object> document) {
        if (compatibleValues) {
            try {
                return jsonMapper.readValue(jsonMapper.writeValueAsBytes(document), new TypeReference<Map<String, Object>>() {
                });
            } catch (Exception e) {
                throw new RuntimeException("Cannot convert document to json and back to Map " + e.getMessage());
            }
        }

        /**
         * A document in MongoDB has a special field "_id" of type ObjectId
         * This object is not "packable" by Neo4jPacker so it must be converted to a value that Neo4j can deal with
         *
         * If the document is not null we simply override the ObjectId instance with its string representation
         */

        if (document != null) {
            Object objectId = document.get("_id");
            if (objectId != null) {
                document.put("_id", objectId.toString());
            }

        }

        return document;
    }
214994
def from_maps(*maps):
        
        result = StringValueMap()
        
        if maps == None or len(maps) == 0:
            return result

        for map in maps:
            for (k, v) in map.items():
                key = StringConverter.to_string(k)
                result.put(key, v)

        return result
669130
public Map<String, String> getMetadata() {
    return metadata == null || Data.isNull(metadata) ? null : Collections.unmodifiableMap(metadata);
  }
900468
public static <K, V> Map<K, V> toCamelCaseMap(Map<K, V> map) {
		return (map instanceof LinkedHashMap) ? new CamelCaseLinkedMap<>(map) : new CamelCaseMap<>(map);
	}
409113
public RiakUserMetadata put(Map<String, String> metaMap)
    {
        for (Map.Entry<String, String> e : metaMap.entrySet())
        {
            BinaryValue wrappedKey = BinaryValue.unsafeCreate(e.getKey().getBytes());
            BinaryValue wrappedValue = BinaryValue.unsafeCreate(e.getValue().getBytes());
            meta.put(wrappedKey, wrappedValue);
        }
        return this;
    }
807548
public static String encodeMetadata(ServiceEndpoint serviceEndpoint) {
    try {
      return objectMapper.writeValueAsString(serviceEndpoint);
    } catch (IOException e) {
      LOGGER.error("Failed to write metadata: " + e);
      throw Exceptions.propagate(e);
    }
  }
250909
private String _serializeMap(Map map, Set<Object> done) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<struct>");

	Iterator it = map.keySet().iterator();

	deep++;
	while (it.hasNext()) {
	    Object key = it.next();
	    sb.append(goIn() + "<var name=" + del + XMLUtil.escapeXMLString(key.toString()) + del + ">");
	    sb.append(_serialize(map.get(key), done));
	    sb.append(goIn() + "</var>");
	}
	deep--;

	sb.append(goIn() + "</struct>");
	return sb.toString();
    }
440934
@Override
    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>();
        map.put(this.getClass().getSimpleName().toLowerCase(), toString());
        return map;
    }
643181
@SuppressWarnings("unchecked")
  public static Map<String, String> toStringMap(Object map) {
    if (map == null) {
      return null;
    }

    if (map instanceof Map) {
      Map<Object, Object> rawMap = (Map<Object, Object>) map;
      Map<String, String> stringMap = new HashMap<>();
      for (Entry<Object, Object> entry : rawMap.entrySet()) {
        stringMap.put(entry.getKey().toString(), entry.getValue().toString());
      }
      return stringMap;
    } else {
      throw new AvroRuntimeException("value must be a map");
    }
  }
162348
public Map<String, Collection<String>> toMap() {
        Map<String, Collection<String>> params = new HashMap<String, Collection<String>>();
        if (null != location) {
            ArrayList<String> valueList = new ArrayList<String>();
            valueList.add(location);
            params.put("location", valueList);
        }

        ArrayList<String> mediaModeValueList = new ArrayList<String>();
        mediaModeValueList.add(mediaMode.toString());
        params.put("p2p.preference", mediaModeValueList);

        ArrayList<String> archiveModeValueList = new ArrayList<String>();
        archiveModeValueList.add(archiveMode.toString());
        params.put("archiveMode", archiveModeValueList);

        return params;
    }