List of usage examples for org.springframework.beans.factory.config TypedStringValue setSource
public void setSource(@Nullable Object source)
From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java
/** * Return a typed String value Object for the given value element. *//*from www. j a va 2s. com*/ public Object parseValueElement(Element ele, @Nullable String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java
/** * Build a typed String value Object for the given raw value. * @see org.springframework.beans.factory.config.TypedStringValue *///from www.java2s . c o m protected final Object buildTypedStringValueForMap(String value, String defaultTypeName, Element entryEle) { try { TypedStringValue typedValue = buildTypedStringValue(value, defaultTypeName); typedValue.setSource(extractSource(entryEle)); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + defaultTypeName + "] not found for Map key/value type", entryEle, ex); return value; } }
From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java
/** * Parse a props element.//from ww w . j a va 2 s .co m */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
From source file:org.springframework.ide.eclipse.osgi.blueprint.internal.BlueprintParser.java
/** * Parse a value, ref or collection sub-element of a property or * constructor-arg element. This method is called from several places to * handle reusable elements such as idref, ref, null, value and so on. * // www .j a v a 2 s .co m * In fact, this method is the main reason why the * BeanDefinitionParserDelegate is not used in full since the element * namespace becomes important as mixed rfc124/bean content can coexist. * * @param ele * subelement of property element; we don't know which yet * @param defaultValueType * the default type (class name) for any * <code><value></code> tag that might be created */ private Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) { // skip other namespace String namespaceUri = ele.getNamespaceURI(); // check Spring own namespace if (parserContext.getDelegate().isDefaultNamespace(namespaceUri)) { return parserContext.getDelegate().parsePropertySubElement(ele, bd); } // let the delegate handle other ns else if (!NAMESPACE_URI.equals(namespaceUri)) { return parserContext.getDelegate().parseCustomElement(ele); } // else { if (DomUtils.nodeNameEquals(ele, BEAN)) { BeanDefinitionHolder bdHolder = parseComponentDefinitionElement(ele, bd); if (bdHolder != null) { bdHolder = ParsingUtils.decorateBeanDefinitionIfRequired(ele, bdHolder, parserContext); } return bdHolder; } if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.REF_ELEMENT)) { return parseRefElement(ele); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.IDREF_ELEMENT)) { return parseIdRefElement(ele); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.VALUE_ELEMENT)) { return parseValueElement(ele, defaultValueType); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.NULL_ELEMENT)) { // It's a distinguished null value. Let's wrap it in a // TypedStringValue // object in order to preserve the source location. TypedStringValue nullHolder = new TypedStringValue(null); nullHolder.setSource(parserContext.extractSource(ele)); return nullHolder; } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.ARRAY_ELEMENT)) { return parseArrayElement(ele, bd); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.LIST_ELEMENT)) { return parseListElement(ele, bd); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.SET_ELEMENT)) { return parseSetElement(ele, bd); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.MAP_ELEMENT)) { return parseMapElement(ele, bd); } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.PROPS_ELEMENT)) { return parsePropsElement(ele); } // maybe it's a nested service/reference/ref-list/ref-set return parserContext.getDelegate().parseCustomElement(ele, bd); } }
From source file:org.springframework.ide.eclipse.osgi.blueprint.internal.BlueprintParser.java
/** * Parse a props element.// w ww.j a v a 2 s . c o m */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new OrderedManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT); for (Iterator<Element> it = propEles.iterator(); it.hasNext();) { Element propEle = it.next(); String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }