当前位置: 首页>>代码示例>>Java>>正文


Java ValueHolder.setName方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ValueHolder.setName方法的具体用法?Java ValueHolder.setName怎么用?Java ValueHolder.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder的用法示例。


在下文中一共展示了ValueHolder.setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decorate

import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入方法依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
	if (node instanceof Attr) {
		Attr attr = (Attr) node;
		String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
		String argValue = StringUtils.trimWhitespace(attr.getValue());

		ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
		boolean ref = false;

		// handle -ref arguments
		if (argName.endsWith(REF_SUFFIX)) {
			ref = true;
			argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
		}

		ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
		valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));

		// handle "escaped"/"_" arguments
		if (argName.startsWith(DELIMITER_PREFIX)) {
			String arg = argName.substring(1).trim();

			// fast default check
			if (!StringUtils.hasText(arg)) {
				cvs.addGenericArgumentValue(valueHolder);
			}
			// assume an index otherwise
			else {
				int index = -1;
				try {
					index = Integer.parseInt(arg);
				} catch (NumberFormatException ex) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies an invalid integer", attr);
				}
				if (index < 0) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies a negative index", attr);
				}

				if (cvs.hasIndexedArgumentValue(index)){
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
							" Only one approach may be used per argument.", attr);
				}

				cvs.addIndexedArgumentValue(index, valueHolder);
			}
		}
		// no escaping -> ctr name
		else {
			String name = Conventions.attributeNameToPropertyName(argName);
			if (containsArgWithName(name, cvs)){
				parserContext.getReaderContext().error(
						"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
						" Only one approach may be used per argument.", attr);
			}
			valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
			cvs.addGenericArgumentValue(valueHolder);
		}
	}
	return definition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:65,代码来源:SimpleConstructorNamespaceHandler.java

示例2: decorate

import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入方法依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
	if (node instanceof Attr) {
		Attr attr = (Attr) node;
		String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
		String argValue = StringUtils.trimWhitespace(attr.getValue());

		ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
		boolean ref = false;

		// handle -ref arguments
		if (argName.endsWith(REF_SUFFIX)) {
			ref = true;
			argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
		}

		ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
		valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));

		// handle "escaped"/"_" arguments
		if (argName.startsWith(DELIMITER_PREFIX)) {
			String arg = argName.substring(1).trim();

			// fast default check
			if (!StringUtils.hasText(arg)) {
				cvs.addGenericArgumentValue(valueHolder);
			}
			// assume an index otherwise
			else {
				int index = -1;
				try {
					index = Integer.parseInt(arg);
				}
				catch (NumberFormatException ex) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies an invalid integer", attr);
				}
				if (index < 0) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies a negative index", attr);
				}

				if (cvs.hasIndexedArgumentValue(index)){
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
							" Only one approach may be used per argument.", attr);
				}

				cvs.addIndexedArgumentValue(index, valueHolder);
			}
		}
		// no escaping -> ctr name
		else {
			String name = Conventions.attributeNameToPropertyName(argName);
			if (containsArgWithName(name, cvs)){
				parserContext.getReaderContext().error(
						"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
						" Only one approach may be used per argument.", attr);
			}
			valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
			cvs.addGenericArgumentValue(valueHolder);
		}
	}
	return definition;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:66,代码来源:SimpleConstructorNamespaceHandler.java

示例3: decorate

import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; //导入方法依赖的package包/类
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
	if (node instanceof Attr) {
		Attr attr = (Attr) node;
		String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
		String argValue = StringUtils.trimWhitespace(attr.getValue());

		ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
		boolean ref = false;

		// handle -ref arguments
		if (argName.endsWith(REF_SUFFIX)) {
			ref = true;
			argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
		}

		ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
		valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));

		// handle "escaped"/"_" arguments
		if (argName.startsWith(DELIMITER_PREFIX)) {
			String arg = argName.substring(1).trim();

			// fast default check
			if (!StringUtils.hasText(arg)) {
				cvs.addGenericArgumentValue(valueHolder);
			}
			// assume an index otherwise
			else {
				int index = -1;
				try {
					index = Integer.parseInt(arg);
				} catch (NumberFormatException ex) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies an invalid integer", attr);
				}
				if (index < 0) {
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' specifies a negative index", attr);
				}

				if (cvs.hasIndexedArgumentValue(index)){
					parserContext.getReaderContext().error(
							"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
							" Only one approach may be used per argument.", attr);
				}

				cvs.addIndexedArgumentValue(index, valueHolder);
			}
		}
		// no escaping -> ctr name
		else {
			String name = Conventions.attributeNameToPropertyName(argName);
			if (containsArgWithName(name, cvs)){
				parserContext.getReaderContext().error(
						"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
						" Only one approach may be used per argument.", attr);
			}
			valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
			cvs.addGenericArgumentValue(valueHolder);
		}
	}
	return definition;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:64,代码来源:SimpleConstructorNamespaceHandler.java


注:本文中的org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。