- 浏览: 124153 次
最新评论
-
gaoxikun:
看起来很齐全,很完美,但是不知道从哪里下载 。
myeclipse插件简单介绍 -
gaoxikun:
亲,能把这个集成了插件的myeclipse 6.5给我一下吗, ...
myeclipse插件简单介绍 -
hotsmile:
不错!!!!!!!!!
myeclipse插件简单介绍
package com.huawei.bss.xml;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* The Class XmlNode.
*/
public class XmlNode
{
/** The tag name. */
private String tagName = null;
/** The parent. */
private XmlNode parent = null;
/** The attributes. */
private Map<String, String> attributes = new LinkedHashMap<String, String>();
/** The nodes. */
private List<Object> nodes = new ArrayList<Object>();
/**
* Instantiates a new xml node.
*/
public XmlNode()
{
}
/**
* Instantiates a new xml node.
*
* @param tagName the tag name
*/
public XmlNode(String tagName)
{
this.tagName = tagName;
}
/**
* Gets the attributes.
*
* @return the attributes
*/
public Map<String, String> getAttributes()
{
return this.attributes;
}
/**
* Sets the attributes.
*
* @param attributes the attributes
*/
public void setAttributes(Map<String, String> attributes)
{
if (attributes != null)
{
this.attributes = attributes;
}
}
/**
* Gets the children.
*
* @return the children
*/
public List<Object> getChildren()
{
return this.nodes;
}
/**
* Gets the children by tag name.
*
* @param name the name
* @return the children by tag name
*/
public List<XmlNode> getChildrenByTagName(String name)
{
List<XmlNode> list = new ArrayList<XmlNode>();
List<Object> ch = getChildren();
for (int i = 0; i < ch.size(); ++i)
{
if ((ch.get(i).getClass() != XmlNode.class)
|| (!(((XmlNode) ch.get(i)).getTagName().equals(name))))
{
continue;
}
list.add((XmlNode) ch.get(i));
}
return list;
}
/**
* Gets the first.
*
* @param tag the tag
* @return the first
*/
public XmlNode getFirst(String tag)
{
List<XmlNode> tem = getChildrenByTagName(tag);
if (tem.isEmpty())
{
return null;
}
return (tem.get(0));
}
/**
* Gets the last.
*
* @param tag the tag
* @return the last
*/
public XmlNode getLast(String tag)
{
List<XmlNode> tem = getChildrenByTagName(tag);
if (tem.isEmpty())
{
return null;
}
return (tem.get(tem.size() - 1));
}
/**
* Gets the first.
*
* @return the first
*/
public Object getFirst()
{
List<Object> list = getChildren();
if (list.isEmpty())
{
return null;
}
return list.get(0);
}
/**
* Gets the last.
*
* @return the last
*/
public Object getLast()
{
List<Object> list = getChildren();
if (list.isEmpty())
{
return null;
}
return list.get(list.size() - 1);
}
/**
* Adds the node.
*
* @param obj the obj
* @return the xml node
*/
public XmlNode addNode(Object obj)
{
if (obj == null)
{
throw new IllegalArgumentException("addNode:node cant null");
}
this.nodes.add(obj);
if (obj instanceof XmlNode)
{
((XmlNode) obj).setParent(this);
}
return this;
}
/**
* Sets the attribute.
*
* @param name the name
* @param value the value
* @return the xml node
*/
public XmlNode setAttribute(String name, String value)
{
this.attributes.put(name, value);
return this;
}
/**
* Gets the parent.
*
* @return the parent
*/
public XmlNode getParent()
{
return this.parent;
}
/**
* Sets the parent.
*
* @param parent the new parent
*/
void setParent(XmlNode parent)
{
this.parent = parent;
}
/**
* Checks if is root.
*
* @return true, if is root
*/
public boolean isRoot()
{
return (this.parent == null);
}
/**
* Gets the tag name.
*
* @return the tag name
*/
public String getTagName()
{
return this.tagName;
}
/**
* Sets the tag name.
*
* @param tagName the tag name
* @return the xml node
*/
public XmlNode setTagName(String tagName)
{
this.tagName = tagName;
return this;
}
public String getText()
{
if (getChildren().isEmpty())
{
return null;
}
if (getChildren().size() != 1)
{
throw new RuntimeException("Not leaf node,nodeName:" + getTagName());
}
return getChildren().get(0).toString();
}
public String getAttribute(String arrtibuteName)
{
return getAttributes().get(arrtibuteName);
}
}
爱上
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* The Class XmlNode.
*/
public class XmlNode
{
/** The tag name. */
private String tagName = null;
/** The parent. */
private XmlNode parent = null;
/** The attributes. */
private Map<String, String> attributes = new LinkedHashMap<String, String>();
/** The nodes. */
private List<Object> nodes = new ArrayList<Object>();
/**
* Instantiates a new xml node.
*/
public XmlNode()
{
}
/**
* Instantiates a new xml node.
*
* @param tagName the tag name
*/
public XmlNode(String tagName)
{
this.tagName = tagName;
}
/**
* Gets the attributes.
*
* @return the attributes
*/
public Map<String, String> getAttributes()
{
return this.attributes;
}
/**
* Sets the attributes.
*
* @param attributes the attributes
*/
public void setAttributes(Map<String, String> attributes)
{
if (attributes != null)
{
this.attributes = attributes;
}
}
/**
* Gets the children.
*
* @return the children
*/
public List<Object> getChildren()
{
return this.nodes;
}
/**
* Gets the children by tag name.
*
* @param name the name
* @return the children by tag name
*/
public List<XmlNode> getChildrenByTagName(String name)
{
List<XmlNode> list = new ArrayList<XmlNode>();
List<Object> ch = getChildren();
for (int i = 0; i < ch.size(); ++i)
{
if ((ch.get(i).getClass() != XmlNode.class)
|| (!(((XmlNode) ch.get(i)).getTagName().equals(name))))
{
continue;
}
list.add((XmlNode) ch.get(i));
}
return list;
}
/**
* Gets the first.
*
* @param tag the tag
* @return the first
*/
public XmlNode getFirst(String tag)
{
List<XmlNode> tem = getChildrenByTagName(tag);
if (tem.isEmpty())
{
return null;
}
return (tem.get(0));
}
/**
* Gets the last.
*
* @param tag the tag
* @return the last
*/
public XmlNode getLast(String tag)
{
List<XmlNode> tem = getChildrenByTagName(tag);
if (tem.isEmpty())
{
return null;
}
return (tem.get(tem.size() - 1));
}
/**
* Gets the first.
*
* @return the first
*/
public Object getFirst()
{
List<Object> list = getChildren();
if (list.isEmpty())
{
return null;
}
return list.get(0);
}
/**
* Gets the last.
*
* @return the last
*/
public Object getLast()
{
List<Object> list = getChildren();
if (list.isEmpty())
{
return null;
}
return list.get(list.size() - 1);
}
/**
* Adds the node.
*
* @param obj the obj
* @return the xml node
*/
public XmlNode addNode(Object obj)
{
if (obj == null)
{
throw new IllegalArgumentException("addNode:node cant null");
}
this.nodes.add(obj);
if (obj instanceof XmlNode)
{
((XmlNode) obj).setParent(this);
}
return this;
}
/**
* Sets the attribute.
*
* @param name the name
* @param value the value
* @return the xml node
*/
public XmlNode setAttribute(String name, String value)
{
this.attributes.put(name, value);
return this;
}
/**
* Gets the parent.
*
* @return the parent
*/
public XmlNode getParent()
{
return this.parent;
}
/**
* Sets the parent.
*
* @param parent the new parent
*/
void setParent(XmlNode parent)
{
this.parent = parent;
}
/**
* Checks if is root.
*
* @return true, if is root
*/
public boolean isRoot()
{
return (this.parent == null);
}
/**
* Gets the tag name.
*
* @return the tag name
*/
public String getTagName()
{
return this.tagName;
}
/**
* Sets the tag name.
*
* @param tagName the tag name
* @return the xml node
*/
public XmlNode setTagName(String tagName)
{
this.tagName = tagName;
return this;
}
public String getText()
{
if (getChildren().isEmpty())
{
return null;
}
if (getChildren().size() != 1)
{
throw new RuntimeException("Not leaf node,nodeName:" + getTagName());
}
return getChildren().get(0).toString();
}
public String getAttribute(String arrtibuteName)
{
return getAttributes().get(arrtibuteName);
}
}
爱上
发表评论
-
java 中的文件读取信息
2013-03-11 08:56 1077import java.io.BufferedReader ... -
oracle结果集的操作信息
2013-03-04 16:22 929众所周知的几个结果集集合操作命令,今天详细地测试了一下,发现一 ... -
js正则表达式(二)
2013-01-09 11:20 898首先加个重要的东西 * ... -
java路径问题以及java对文件的基本操作信息
2012-12-19 14:09 9871.基本概念的理解 绝对 ... -
JS正则表达式
2012-11-15 17:10 861function isTrueName(s) { var pa ... -
java公用类
2012-11-15 17:05 874package cn.org.jshuwei.j2ee.uti ... -
java规范信息
2012-10-30 08:44 28011 一、判断选择题(每题1分) 1. 表达式要在低优先级操作符 ... -
java时间公用和StringUnitl以及java调用存储过程
2012-10-16 17:38 16271 构建存储过程的语句信息 /** * 从Fun ... -
jquery批量删除
2012-09-20 14:31 3398<%@ page language="java ... -
java操作execl文件(2003与2007不兼容问题)
2012-09-19 14:49 1480package com.huawei.bss.execlCom ... -
java操作execl文件
2012-09-19 08:53 996package com.huawei.bss.execlCom ... -
通过onkeypress和onkeydown事件禁用键盘中某些键
2012-09-17 15:09 963http://zywang.iteye.com/blog/70 ... -
properties的修改
2012-09-14 16:05 1022public static void modifyProper ... -
java学习的一点记录
2012-09-12 16:15 1247public class Tools { stati ... -
STRUTS2与JSON的LIST和MAP对象返回
2012-09-07 14:57 6695<%@ page language="java ... -
struts2 iterator双重叠迭取值
2012-09-05 18:08 1267•效果:Map<String,List<Derpa ... -
struts2多个配置文件的应用
2012-09-05 10:10 1082<!-- 定义Struts2的核心Filter --&g ... -
java中使用net.sf.json对json进行解析
2012-09-04 12:24 1035作者: http://zhangnet1.iteye.com/ ... -
XML的TreeConfig
2012-09-04 10:20 923/** * <?xml version=&qu ... -
JSON与 STRuts2
2012-09-04 10:20 1319package com.huawei.cmclient.com ...
相关推荐
Mark: xml文件保存路径为已经设置的路径,默认为打开文件时的路径,也可以通过SetValue函数修改路径,详见SetValue函数说明 如果当前节点为根节点,则记录的xml文件路径将被替换 如果当前节点不是跟节点,只保存...
此包可以解决XML文件的解析、对象转化为XML字符串的问题。 1 通过调用解析类,可以将XML的DATA数据转换为XmlNode对象,XmlNode以树形结构进行XML的数据封装,使用的时候按照树形结构进行数据的获取。(如有问题请...
* XML 文件的生成和解析 扩展阅读 * ASP.NET 操作 XML 技巧总结 * ASP.NET 文件操作技巧汇总 * ASP.NET Ajax 技巧总结专题 * ASP.NET 缓存操作技巧总结 * ASP.NET 中的 XmlDocument 类详解 * ASP.NET 实现TreeView...
方便对xml中任意节(多个同名节点)点属性进行获取、设置。 /// /// 设置指定节点的属性 /// /// <param name="xmlContent">xml结构 /// 父节点 /// 父节点所处同名节点的位置 为0表明只有一个该节点 /// ...
附件是我写的一个demo程序,该程序的功能是根据一个定义好的XSD文件去检查...1 解析XSD文件,并将其规定的XML结构映射至自定义的Java类(XMLNode); 2 根据得到XML结构,逐一检查目标XML中是否存在指定的元素或属性。
xml 文件内容: 代码如下: <?xml version=”1.0″ encoding=”utf-8″?> <subtitles> <info> 最新通告:五一放假七天!请各教员悉知</content> <speed>4</speed> <color>red</color> </info> </subtitles> C#...
XML概述 <br>2.1 XML的概念 2.1.1 XML元素 2.1.2 XML属性 2.1.3 XML解析器 2.1.4 构建XML 2.1.5 XML文档的各个组成部分 2.2 创建格式良好的XML文档 2.2.1 XML中的元素 2.2.2 XML中的属性...
来自CodeProject的jerry.Wang 的xml操作类,简单方便,...xsl类添加了直接将xml和xsl进行转化得到转化后的html代码的函数,从而不用生成文件再得到转化结果。 xml的用法参见source文件夹的示例,原作者写的非常棒!
1.首先是将解析完的XML文件绑定到TreeView上 2.用代码动态生成座位的label,生成触发事件Label_Click,俩组放映时间的售出座位是不同的 3.用序列化与反序列化实现代码的多次利用 4.打印票务 创建与本项目相关的10个...
public object Create(object parent, object configContext, System.Xml.XmlNode section) { ObjectInfo info; PropertyInfo propInfo; ConfigInfo cfgInfo = new ConfigInfo(); foreach(XmlNode node in ...