Replaces the content of one or more XML attributes.

@param xml
Xml with content to replace.
@param keyValues
Attribute name and new value.

@return Replaced content.
160933
public static String replaceXmlAttr(final String xml, final KV... keyValues) {

        final List<String> searchList = new ArrayList<String>();
        final List<String> replacementList = new ArrayList<String>();

        for (final KV kv : keyValues) {
            final String tag = kv.getKey() + "=\"";
            int pa = xml.indexOf(tag);
            while (pa > -1) {
                final int s = pa + tag.length();
                final int pe = xml.indexOf("\"", s);
                if (pe > -1) {
                    final String str = xml.substring(pa, pe + 1);
                    searchList.add(str);
                    final String repl = xml.substring(pa, pa + tag.length()) + kv.getValue() + "\"";
                    replacementList.add(repl);
                }
                pa = xml.indexOf(tag, s);
            }
        }

        final String[] searchArray = searchList.toArray(new String[searchList.size()]);
        final String[] replacementArray = replacementList.toArray(new String[replacementList.size()]);
        return StringUtils.replaceEachRepeatedly(xml, searchArray, replacementArray);
    }
1238919
@Override
  public <O> O replaceTerms(Map substitutions) throws KbTypeException, CreateException {
    return wrapped().replaceTerms(substitutions);
  }
841969
@SuppressWarnings("unchecked")
    private void setValue(List<Element> elements, String attrName, Object pojo,
                          CustomPropertyDescriptor field) {
        XmlNode attrXmlNode = field.getAnnotation(XmlNode.class);
        log.debug("要赋值的fieldName为{}", field.getName());
        final XmlTypeConvert convert = XmlTypeConverterUtil.resolve(attrXmlNode, field);

        Class<? extends Collection> collectionClass;
        Class<? extends Collection> real = (Class<? extends Collection>) field.getRealType();

        if (attrXmlNode != null) {
            collectionClass = attrXmlNode.arrayType();
            if (!collectionClass.equals(real) && !real.isAssignableFrom(collectionClass)) {
                log.warn("用户指定的集合类型[{}]不是字段的实际集合类型[{}]的子类，使用字段的实际集合类型", collectionClass, real);
                collectionClass = real;
            }
        } else {
            collectionClass = real;
        }

        if (!StringUtils.isEmpty(attrXmlNode.arrayRoot()) && !elements.isEmpty()) {
            elements = elements.get(0).elements(attrXmlNode.arrayRoot());
        }

        //将数据转换为用户指定数据
        List<?> list = elements.stream().map(d -> convert.read(d, attrName))
            .collect(Collectors.toList());

        if (!trySetValue(list, pojo, field, collectionClass)) {
            //使用注解标记的类型赋值失败并且注解的集合类型与实际字段类型不符时尝试使用字段实际类型赋值
            if (!trySetValue(list, pojo, field, real)) {
                log.warn("无法为字段[{}]赋值", field.getName());
            }
        }
    }
1329697
public V put(String key, V value) {

	if (key == null || value == null) {
	    throw new NullPointerException("keys and values cannot be null");
	}

	int keyLength = key.length();
	Node<V> n = rootNode;

	for (int curKeyIndex = 0; curKeyIndex <= keyLength; ++curKeyIndex) {	    

	    CharSequence nodePrefix = n.getPrefix();

	    int nextCharIndex = curKeyIndex + 1;

	    // if the current node is an intermediate node, then we need to
	    // match all of the prefix characters to use its children.  
	    if (nodePrefix.length() > 0) {
		int charOverlap = countOverlap(key, curKeyIndex, nodePrefix,0);
		int prefixLength = nodePrefix.length();
		
		// if 0 ore more characters overlapped, add this node to
		// somewhere in the middle
		if (charOverlap < prefixLength) {
		    addIntermediateNode(n,
					charOverlap,
					key,
					curKeyIndex,
					value);
		    size++;
		    return null;
		}

		// if all of the characters overlapped, then lookup the
		// transition to the next node based on the next character after
		// the matching prefix
		curKeyIndex += prefixLength;
		nextCharIndex = curKeyIndex + 1;
	    }

	    // If we have exhausted all the characters in the key, then the
	    // current node should map to the value
	    if (curKeyIndex == keyLength) {
		return replaceValue(n, value);
	    }
	    	    
	    // Otherwise, more characters exist, so check to see if there is a
	    // transition from the next sequence of the key to node.  If so, we
	    // use this to keep searching for the key's node
	    else {
		Node<V> child = n.getChild(key.charAt(curKeyIndex));
		
		// if there was no other node to transition to, then the
		// remaining portion of the key is used to form a child node of
		// the current node.  Since this is a new mapping, we can return
		// null immediately.
		if (child == null) {
		    addChildNode(n, key, curKeyIndex, value);
		    return null;
		}
		// otherwise, update the current node to the child and repeat
		// the search process
		else {
		    n = child;
		}
	    }	    
	}

	// NOTE: we should never reach this case, as the one of the conditions
	// in the for loop will determine where the key goes.
	return null;
    }
1342951
public void transform(XmlNode node, StringBuilder builder) {
        switch (node.getType()) {
            case XmlNode.ELEMENT_NODE: {
                builder.append("<");
                builder.append(node.getName());
                for (XmlNode attribute : node.getAttributes().values()) {
                    transform(attribute, builder);
                }
                builder.append(">");
                for (XmlNode child : node.getChildren()) {
                    transform(child, builder);
                }
                builder.append("</");
                builder.append(node.getName());
                builder.append(">");
            }
                break;
            case XmlNode.ATTRIBUTE_NODE: {
                builder.append(" ");
                builder.append(node.getName());
                builder.append("=\"");
                builder.append(node.getValue());
                builder.append("\"");
            }
                break;
            case XmlNode.TEXT_NODE: {
                builder.append(node.getValue());
            }
        }
    }
284880
public static String replaceStrByMap(Map<String, String> requestParameters,
            String sourceContent) {

        String contentAfterReplace = sourceContent;

        for (Entry<String, String> entry : requestParameters.entrySet()) {

            String sourceContentHelperNew = contentAfterReplace;
            String varName = entry.getKey();
            String replacement = entry.getValue();

            if (varName.contains(PcConstants.NODE_REQUEST_PREFIX_REPLACE_VAR)) {

                String varTrueName = "$"
                        + varName
                                .replace(
                                        PcConstants.NODE_REQUEST_PREFIX_REPLACE_VAR,
                                        "");
                sourceContentHelperNew = contentAfterReplace.replace(
                        varTrueName, replacement);
                contentAfterReplace = sourceContentHelperNew;
            }

        }

        return contentAfterReplace;
    }
285089
function(ctx) {
    assert(this.args.length == 2);
    var nodes = this.args[0].evaluate(ctx).nodeSetValue();
    var delim = this.args[1].evaluate(ctx).stringValue();
    var ret = '';
    for (var i = 0; i < nodes.length; ++i) {
      if (ret) {
        ret += delim;
      }
      ret += xmlValue(nodes[i]);
    }
    return new StringValue(ret);
  }
906240
public void replaceValues(List<Object> values) {
    Preconditions.checkArgument(values != null, "Values cannot be null");
    Preconditions.checkArgument(values.size() <= fields.size(), "Values cannot be larger than fields size");
    this.values = values;
  }
277388
@Override
  public boolean replace    ( TypeK  key, TypeV  oldValue, TypeV newValue ) {
    return Objects.equals(putIfMatch( key, newValue, oldValue ), oldValue);
  }
115696
private void initKeySetForXmlBundle() {

        // consider only available locales
        for (Locale l : m_locales) {
            if (m_xmlBundle.hasLocale(l)) {
                Set<Object> keys = new HashSet<Object>();
                for (I_CmsXmlContentValue msg : m_xmlBundle.getValueSequence("Message", l).getValues()) {
                    String msgpath = msg.getPath();
                    keys.add(m_xmlBundle.getStringValue(m_cms, msgpath + "/Key", l));
                }
                m_keyset.updateKeySet(null, keys);
            }
        }

    }
1173090
protected void replaceValue(Map<String, Object> content, String key, Object value) {
		if (content.containsKey(key) && value != null) {
			content.put(key, value);
		}
	}
412025
public static Properties jslPropertiesToJavaProperties(
            final JSLProperties xmlProperties) {

        final Properties props = new Properties();

        for (final Property prop : xmlProperties.getPropertyList()) {
            props.setProperty(prop.getName(), prop.getValue());
        }

        return props;

    }
551339
public void setXmlns(java.lang.String xmlns) {
        getStateHelper().put(PropertyKeys.xmlns, xmlns);
        handleAttribute("xmlns", xmlns);
    }
5375
public void replaceValue(Object bodyObj, Object replaceValue) {
        Object parentObj = bodyObj;

        if(this.listChild) {
            ValidationData rootListParent = this.findListParent();
            if(this.deepLevel - rootListParent.deepLevel > 1 ){
                parentObj = this.parent.getValue(bodyObj);
            }
        }
        else {
            if (this.parentId != null) {
                parentObj = this.parent.getValue(bodyObj);
            }
        }

        this.setter(this, parentObj, replaceValue);
    }
589832
protected static String getSubstitutedTemplateContent(String templateContent, NamesValuesList<String, String> namesValues) {
        String templateContentSubst = templateContent;
        // substitute the name/values

        for (NameValue<String, String> nameValue : namesValues) {
            templateContentSubst = templateContentSubst.replace(nameValue.name, nameValue.value);
        }
        return templateContentSubst;
    }
595581
protected static String xml2jname( String xml ) {
    // Convert pname to a valid java name
    StringBuilder nn = new StringBuilder();
    char[] cs = xml.toCharArray();
    if( !Character.isJavaIdentifierStart(cs[0]) )
      nn.append('X');
    for( char c : cs ) {
      if( !Character.isJavaIdentifierPart(c) ) {
        nn.append('_');
      } else {
        nn.append(c);
      }
    }
    String jname = nn.toString();
    return jname;
  }
755391
@Override
    public V replace(K key, V value) {
        int hash = hash(key);
        if (value == null) {
          throw new NullPointerException();
        }
        Segment<K,V> s = segmentForHash(hash);
        return s == null ? null : s.replace(key, hash, value);
    }