com.feilong.context.converter.builder.XmlNodeAttributeValueAndValueMapBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feilong Show documentation
Show all versions of feilong Show documentation
feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.
/*
* Copyright (C) 2008 feilong
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.feilong.context.converter.builder;
import java.util.Map;
import com.feilong.core.Validate;
import com.feilong.xml.XmlUtil;
/**
* 提取xml node属性值和string value 填充到bean里面去.
*
*
* {@code
*
*
*
*
*
*
* 868BBC35-A5D1-FCBF-0453F134C99B5553
*
*
* 000
*
*
*
*
*
* 9011999.0
*
*
* 2.0
*
*
*
*
*
* 010003170001
*
*
* IDR
*
*
* APPROVED
*
*
* Blanja2
*
*
* 2014-04-23 15:19:27
*
*
* AUTH20140423152019PM
*
*
*
*
*
*
*
*
* 298883
*
*
* AUTHORIZATION
*
*
*
*
* }
*
*
* @author feilong
* @since 1.11.2
*/
public class XmlNodeAttributeValueAndValueMapBuilder implements NameAndValueMapBuilder{
/** The xpath expression. */
private String xpathExpression;
/** The nodeAttributeName. */
private String nodeAttributeName;
//---------------------------------------------------------------
/**
* Instantiates a new xml node attribute value and value map builder.
*/
public XmlNodeAttributeValueAndValueMapBuilder(){
super();
}
/**
* Instantiates a new xml node attribute value and value map builder.
*
* @param xpathExpression
* the xpath expression
* @param nodeAttributeName
* the node attribute name
*/
public XmlNodeAttributeValueAndValueMapBuilder(String xpathExpression, String nodeAttributeName){
super();
this.xpathExpression = xpathExpression;
this.nodeAttributeName = nodeAttributeName;
}
//---------------------------------------------------------------
/*
* (non-Javadoc)
*
* @see com.feilong.bind.builder.NameAndValueMapBuilder#buildNameAndValueMap(java.lang.String)
*/
@Override
public Map build(String xml){
Validate.notBlank(xml, "xml can't be blank!");
return XmlUtil.getNodeAttributeValueAndStringValueMap(xml, xpathExpression, nodeAttributeName);
}
//---------------------------------------------------------------
/**
* 获得 xpath expression .
*
* @return the xpathExpression
*/
public String getXpathExpression(){
return xpathExpression;
}
/**
* 设置 xpath expression .
*
* @param xpathExpression
* the xpathExpression to set
*/
public void setXpathExpression(String xpathExpression){
this.xpathExpression = xpathExpression;
}
/**
* 获得 nodeAttributeName.
*
* @return the nodeAttributeName
*/
public String getNodeAttributeName(){
return nodeAttributeName;
}
/**
* 设置 nodeAttributeName.
*
* @param nodeAttributeName
* the nodeAttributeName to set
*/
public void setNodeAttributeName(String nodeAttributeName){
this.nodeAttributeName = nodeAttributeName;
}
}