/*
Convert attributes array to a map.

Note: parse5 will have already handled multiple attrs of the
same name.
11041
function getAttrMap(attrs)
{
	var i;
	var map = {};
	var numAttrs = attrs.length;
	
	for (i=0; i<numAttrs; i++)
	{
		map[ attrs[i].name ] = attrs[i].value;
	}
	
	return map;
}
37666
function renderAttributes(ns, node, attrs) {
  let map = ATTRIBUTE_MAP[ns] || {};
  keys(map).forEach(key => {
    let attrKey = map[key];
    if(key in attrs) {
      node.setAttribute(attrKey, attrs[key]);
    }
  });
}
837668
@Override
    public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in ) {
        final ByteArrayInputStream bis = new ByteArrayInputStream( in );
        try {
            @SuppressWarnings( "unchecked" )
            final ConcurrentMap<String, Object> result = (ConcurrentMap<String, Object>) _xstream.fromXML( bis );
            return result;
        } catch ( final RuntimeException e ) {
            LOG.warn( "Caught Exception decoding "+ in.length +" bytes of data", e );
            throw new TranscoderDeserializationException(e);
        } finally {
            closeSilently( bis );
        }
    }
1282847
@Override
    public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in ) {
        ByteArrayInputStream bis = null;
        ObjectInputStream ois = null;
        try {
            bis = new ByteArrayInputStream( in );
            ois = createObjectInputStream( bis );

            final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
            final int n = ( (Integer) ois.readObject() ).intValue();
            for ( int i = 0; i < n; i++ ) {
                final String name = (String) ois.readObject();
                final Object value = ois.readObject();
                if ( ( value instanceof String ) && ( value.equals( NOT_SERIALIZED ) ) ) {
                    continue;
                }
                if ( LOG.isDebugEnabled() ) {
                    LOG.debug( "  loading attribute '" + name + "' with value '" + value + "'" );
                }
                attributes.put( name, value );
            }

            return attributes;
        } catch ( final ClassNotFoundException e ) {
            LOG.warn( "Caught CNFE decoding "+ in.length +" bytes of data", e );
            throw new TranscoderDeserializationException( "Caught CNFE decoding data", e );
        } catch ( final IOException e ) {
            LOG.warn( "Caught IOException decoding "+ in.length +" bytes of data", e );
            throw new TranscoderDeserializationException( "Caught IOException decoding data", e );
        } finally {
            closeSilently( bis );
            closeSilently( ois );
        }
    }
1224406
def array(attr, metadata={})
      add_attribute(attr, :array, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", Array(arg))
      end
    end
224845
protected function transformAttrToAssoc($node_map)
    {
        // NamedNodeMap is documented very well, so we're using undocumented
        // features, namely, the fact that it implements Iterator and
        // has a ->length attribute
        if ($node_map->length === 0) {
            return array();
        }
        $array = array();
        foreach ($node_map as $attr) {
            $array[$attr->name] = $attr->value;
        }
        return $array;
    }
698782
function processAttributeArray(attrArray) {
  let attrs = {
    'static': {},
    'dynamic': []
  };
  let name = [];
  let value = [];
  let item;
  let pushingTo = name;
  for (let i = 0; i < attrArray.length; i++) {
    item = attrArray[i];
    if (item.type === 'attributenameend') {
      pushingTo = value;
    } else if (item.type === 'attributeend') {
      // Ensure there are no tokens in a non-dynamic attribute name
      for (let j = 0; j < name.length; j++) {
        if (typeof name[j] !== 'string') {
          compilerErrors.mustacheTokenCannotBeInAttributeNames(name[j]);
        }
      }

      if (name.length === 1) {
        if (value.length) {
          if (value.length === 1 && typeof value[0] === 'string') {
            value = value[0];
          }
        } else {
          value = true;
        }
        attrs.static[name[0]] = flattenAttributeValues(value);
      } else {
        attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
        if (value.length) {
          attrs.dynamic.push('="');
          attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
          attrs.dynamic.push('"');
        }
      }
      name = [];
      value = [];
      pushingTo = name;
    } else if (item.type === 'attributename' || item.type === 'attributevalue') {
      pushingTo.push(item.value);
    } else if (pushingTo === name) {
      if (name.length === 0) {
        if (item.type === types.INTERPOLATOR) {
          compilerErrors.doubleCurlyInterpolatorsCannotBeInAttributes(item.value);
        } else if (item.type === types.SECTION) {
          attrs.dynamic.push(templateStack.processObject(item));
          continue;
        }
      }
      pushingTo.push(item);
    } else {
      pushingTo.push(item);
    }
  }

  attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
  attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
  mergeStrings(attrs.dynamic);

  return attrs;
}
1192634
@Override
    @Trivial
    public Map<String, ExtendedAttributeDefinition> getAttributeMap() {
        Map<String, ExtendedAttributeDefinition> map = null;
        AttributeDefinition[] attrDefs = getAttributeDefinitions(ObjectClassDefinition.ALL);
        if (attrDefs != null) {
            map = new HashMap<String, ExtendedAttributeDefinition>();
            for (AttributeDefinition attrDef : attrDefs) {
                map.put(attrDef.getID(), new ExtendedAttributeDefinitionImpl(attrDef));
            }
        } else {
            map = Collections.emptyMap();
        }
        return map;
    }
566502
function _parseAttributes($attributes)
    {
        if (is_array($attributes)) {
            $ret = array();
            foreach ($attributes as $key => $value) {
                if (is_int($key)) {
                    $key = $value = strtolower($value);
                } else {
                    $key = strtolower($key);
                }
                $ret[$key] = $value;
            }
            return $ret;

        } elseif (is_string($attributes)) {
            $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" .
                "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/";
            if (preg_match_all($preg, $attributes, $regs)) {
                for ($counter=0; $counter<count($regs[1]); $counter++) {
                    $name  = $regs[1][$counter];
                    $check = $regs[0][$counter];
                    $value = $regs[7][$counter];
                    if (trim($name) == trim($check)) {
                        $arrAttr[strtolower(trim($name))] = strtolower(trim($name));
                    } else {
                        if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") {
                            $value = substr($value, 1, -1);
                        }
                        $arrAttr[strtolower(trim($name))] = trim($value);
                    }
                }
                return $arrAttr;
            }
        }
    }
721675
protected Map<String, String> getElementAttributes() {
        // Preserve order of attributes
        Map<String, String> attrs = new HashMap<>();

        if (this.getFor_() != null) {
            attrs.put("for_", this.getFor_().toString());
        }
        if (this.getErrorTypes() != null) {
            attrs.put("errorType", this.getErrorTypesAsString());
        }
        if (this.getCardTypes() != null) {
            attrs.put("cardType", this.getCardTypesAsString());
        }
        if (this.getAttempts() != null) {
            attrs.put("attempt", this.getAttemptsAsString());
        }

        return attrs;
    }
1167411
public Object[] getAll(Map<String, Object> data, String attr) {
    return (Object[]) data.get(attr);
  }
991012
private Map<String, Object> cloneAttributes(Map<String, Object> attrs) {

        Map<String, Object> result = new HashMap<String, Object>();
        for (Entry<String, Object> entry : attrs.entrySet()) {
            if (entry.getValue() instanceof CmsJspStandardContextBean) {
                result.put(entry.getKey(), ((CmsJspStandardContextBean)entry.getValue()).createCopy());
            } else if (entry.getValue() instanceof Cloneable) {
                Object clone = null;
                try {
                    clone = ObjectUtils.clone(entry.getValue());
                } catch (Exception e) {
                    LOG.info(e.getMessage(), e);
                }

                result.put(entry.getKey(), clone != null ? clone : entry.getValue());
            } else {
                result.put(entry.getKey(), entry.getValue());
            }

        }

        return result;
    }
652511
function _mapInAttributes(&$root, $path, $asn1)
    {
        $attributes = &$this->_subArray($root, $path);

        if (is_array($attributes)) {
            for ($i = 0; $i < count($attributes); $i++) {
                $id = $attributes[$i]['type'];
                /* $value contains the DER encoding of an ASN.1 value
                   corresponding to the attribute type identified by type */
                $map = $this->_getMapping($id);
                if (is_array($attributes[$i]['value'])) {
                    $values = &$attributes[$i]['value'];
                    for ($j = 0; $j < count($values); $j++) {
                        $value = $asn1->encodeDER($values[$j], $this->AttributeValue);
                        $decoded = $asn1->decodeBER($value);
                        if (!is_bool($map)) {
                            $mapped = $asn1->asn1map($decoded[0], $map);
                            if ($mapped !== false) {
                                $values[$j] = $mapped;
                            }
                            if ($id == 'pkcs-9-at-extensionRequest' && $this->_isSubArrayValid($values, $j)) {
                                $this->_mapInExtensions($values, $j, $asn1);
                            }
                        } elseif ($map) {
                            $values[$j] = base64_encode($value);
                        }
                    }
                }
            }
        }
    }
131532
protected function parseMappings()
    {
        $this->mappedAttributes = [];

        foreach ($this->getMaps() as $attribute => $mapping) {
            if (is_array($mapping)) {
                $this->parseImplicitMapping($mapping, $attribute);
            } else {
                $this->mappedAttributes[$attribute] = $mapping;
            }
        }
    }
237926
def [](attr)
      return nil unless instance_variable_defined?(:@attributes) and @attributes.is_a?(Hash)
      @attributes[attr] or (attr.is_a?(String) ? @attributes[attr.to_sym] : @attributes[attr.to_s])
    end
1166624
private Attributes toAttributes(Map<String,String> attrs){
        AttributesImpl impl = new AttributesImpl();
        for (Map.Entry<String,String> attr : attrs.entrySet()){
        	impl.addAttribute("", attr.getKey(), "", "CDATA", attr.getValue());
        }
        return impl;
    }
20498
function dataMap()
    {
        if ( $this->ContentObjectAttributeArray === false )
        {
            $data = $this->contentObjectAttributes();
            // Store the attributes for later use
            $this->ContentObjectAttributeArray = $data;
        }
        else
        {
            $data = $this->ContentObjectAttributeArray;
        }

        if ( $this->DataMap == false )
        {
            $ret = array();
            foreach( $data as $item )
            {
                $ret[$item->contentClassAttributeIdentifier()] = $item;
            }
            $this->DataMap = $ret;
        }
        else
        {
            $ret = $this->DataMap;
        }
        return $ret;
    }