本文整理汇总了Java中org.dom4j.Attribute.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.setValue方法的具体用法?Java Attribute.setValue怎么用?Java Attribute.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Attribute
的用法示例。
在下文中一共展示了Attribute.setValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateElement
import org.dom4j.Attribute; //导入方法依赖的package包/类
/**
* Update the attributes of element
*
* @param element
* @param properties
*/
private static void updateElement(Element element, Map<String, String> properties) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
String key = entry.getKey();
if (key.startsWith("tools:")) {
continue;
}
String keyNoPrefix = key;
String[] values = StringUtils.split(key, ":");
if (values.length > 1) {
keyNoPrefix = values[1];
}
if (null == entry.getValue()) {
continue;
} else {
Attribute attribute = element.attribute(keyNoPrefix);
if (null != attribute) {
attribute.setValue(entry.getValue());
} else {
element.addAttribute(key, entry.getValue());
}
}
}
}
示例2: fillFullClazzName
import org.dom4j.Attribute; //导入方法依赖的package包/类
private static void fillFullClazzName(Element root, String packageName, String type) {
List<? extends Node> applicatNodes = root.selectNodes("//" + type);
for (Node node : applicatNodes) {
Element element = (Element)node;
Attribute attribute = element.attribute("name");
if (attribute != null) {
if (attribute.getValue().startsWith(".")) {
attribute.setValue(packageName + attribute.getValue());
}
}
}
}
示例3: addJunctionConnection
import org.dom4j.Attribute; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public boolean addJunctionConnection(final String id, final String fromNode,
final String from_x, final String from_y,
final String toNode,
final String to_x, final String to_y,
final String dir)
{
String s = "intconnction[@fromNode='"+fromNode+"' and @toNode='"+toNode+"']";
List<Element> list = junction.selectNodes(s);
if(list.isEmpty())
{
intconnction = junction.addElement("intconnction");
intconnction.addAttribute("id", id);
intconnction.addAttribute("numLanes", "1");
intconnction.addAttribute("fromNode", fromNode);
intconnction.addAttribute("from_x", from_x);
intconnction.addAttribute("from_y", from_y);
intconnction.addAttribute("toNode", toNode);
intconnction.addAttribute("to_x", to_x);
intconnction.addAttribute("to_y", to_y);
intconnction.addAttribute("dir", dir);
return true;
}
else
{
Iterator<Element> iter = list.iterator();
//System.out.println(list.size());
while (iter.hasNext())
{
Element ele = iter.next();
Attribute attr = ele.attribute("numLanes");
Integer numLanes = Integer.parseInt(attr.getValue())+1;
attr.setValue(numLanes.toString());
}
//System.out.println("有重复的lane");
return false;
}
}
示例4: writeResponse
import org.dom4j.Attribute; //导入方法依赖的package包/类
@Override
protected void writeResponse(InputStream input, OutputStream output)
throws IOException
{
if (response.getContentType().startsWith(MimetypeMap.MIMETYPE_ATOM) ||
response.getContentType().startsWith(MimetypeMap.MIMETYPE_RSS))
{
// Only post-process ATOM and RSS feeds
// Replace all navigation links with "proxied" versions
SAXReader reader = new SAXReader();
try
{
Document document = reader.read(input);
Element rootElement = document.getRootElement();
XPath xpath = rootElement.createXPath(ATOM_LINK_XPATH);
Map<String,String> uris = new HashMap<String,String>();
uris.put(ATOM_NS_PREFIX, ATOM_NS_URI);
xpath.setNamespaceURIs(uris);
List nodes = xpath.selectNodes(rootElement);
Iterator iter = nodes.iterator();
while (iter.hasNext())
{
Element element = (Element)iter.next();
Attribute hrefAttr = element.attribute("href");
String mimetype = element.attributeValue("type");
if (mimetype == null || mimetype.length() == 0)
{
mimetype = MimetypeMap.MIMETYPE_HTML;
}
String url = createUrl(engine, hrefAttr.getValue(), mimetype);
if (url.startsWith("/"))
{
url = rootPath + url;
}
hrefAttr.setValue(url);
}
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(output, outputFormat);
writer.write(rootElement);
writer.flush();
}
catch(DocumentException e)
{
throw new IOException(e.toString());
}
}
else
{
super.writeResponse(input, output);
}
}