本文整理汇总了Java中org.dom4j.Element.addElement方法的典型用法代码示例。如果您正苦于以下问题:Java Element.addElement方法的具体用法?Java Element.addElement怎么用?Java Element.addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveXml
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public void saveXml(Document document, Session session, Properties parameters) throws Exception {
try {
beginTransaction();
Element root = document.addElement("students");
root.addAttribute("campus", session.getAcademicInitiative());
root.addAttribute("year", session.getAcademicYear());
root.addAttribute("term", session.getAcademicTerm());
document.addDocType("students", "-//UniTime//UniTime Students DTD/EN", "http://www.unitime.org/interface/Student.dtd");
for (Student student: (List<Student>)getHibSession().createQuery(
"select s from Student s where s.session.uniqueId = :sessionId")
.setLong("sessionId", session.getUniqueId()).list()) {
Element studentEl = root.addElement("student");
exportStudent(studentEl, student);
}
commitTransaction();
} catch (Exception e) {
fatal("Exception: "+e.getMessage(),e);
rollbackTransaction();
}
}
示例2: getCollapseWidget
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Render open/close widget for this element.
*
* @return The collapseWidget value
*/
protected Element getCollapseWidget() {
Element img_template = df.createElement("img")
.addAttribute("id", "${id}_img")
.addAttribute("border", "0")
.addAttribute("hspace", "3")
.addAttribute("height", "12")
.addAttribute("width", "12");
Element choose = df.createElement("c__choose");
Element isOpen = choose.addElement("c__when")
.addAttribute("test", "${" + formBeanName + ".collapseBean.isOpen}");
Element openedImg = img_template.createCopy();
isOpen.add(openedImg);
openedImg.addAttribute("src", "../images/opened.gif");
Element otherwise = choose.addElement("c__otherwise");
Element closedImg = (Element) img_template.createCopy();
otherwise.add(closedImg);
closedImg.addAttribute("src", "../images/closed.gif");
return choose;
}
示例3: parseList2Xml
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* 将List数据类型转换为符合XML格式规范的字符串(基于节点属性值的方式)
*
* @param pList 传入的List数据(List对象可以是Dto、VO、Domain的属性集)
* @param pRootNodeName 根节点名称
* @param pFirstNodeName 行节点名称
* @return string 返回XML格式字符串
*/
public static final String parseList2Xml(List pList, String pRootNodeName, String pFirstNodeName) {
Document document = DocumentHelper.createDocument();
Element elRoot = document.addElement(pRootNodeName);
for (int i = 0; i < pList.size(); i++) {
Map map = (Map) pList.get(i);
Element elRow = elRoot.addElement(pFirstNodeName);
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
elRow.addAttribute((String) entry.getKey(), String.valueOf(entry.getValue()));
}
}
String outXml = document.asXML().substring(39);
return outXml;
}
示例4: parseList2XmlBasedNode
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* 将List数据类型转换为符合XML格式规范的字符串(基于节点值的方式)
*
* @param pList 传入的List数据(List对象可以是Dto、VO、Domain的属性集)
* @param pRootNodeName 根节点名称
* @param pFirstNodeName 行节点名称
* @return string 返回XML格式字符串
*/
public static final String parseList2XmlBasedNode(List pList, String pRootNodeName, String pFirstNodeName) {
Document document = DocumentHelper.createDocument();
Element output = document.addElement(pRootNodeName);
for (int i = 0; i < pList.size(); i++) {
Map map = (Map)pList.get(i);
Element elRow = output.addElement(pFirstNodeName);
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
Element leaf = elRow.addElement((String)entry.getKey());
leaf.setText(String.valueOf(entry.getValue()));
}
}
String outXml = document.asXML().substring(39);
return outXml;
}
示例5: rolesMapToElement
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Description of the Method
*
*@return Description of the Return Value
*/
private Element rolesMapToElement() {
Element rolesElement = DocumentHelper.createElement("roles");
if (!this.isAdminUser()) {
for (Iterator i = this.getRoleMap().keySet().iterator(); i.hasNext(); ) {
String collection = (String) i.next();
// TODO - eliminate "default" collection. this can be removed after user files
// for each User instance are written.
Roles.Role role = this.getAssignedRole(collection);
if (role != Roles.NO_ROLE) {
Element roleElement = rolesElement.addElement("role");
roleElement.addElement("rolename").setText(role.toString());
roleElement.addElement("collection").setText(collection);
}
}
}
return rolesElement;
}
示例6: toDsml
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* Creates the Request Element and adds RequestID and Controls.
*
* @param root the root element
* @return the Request Element of the given name containing
*/
@Override
public Element toDsml( Element root )
{
Element element = root.addElement( getRequestName() );
// Request ID
int requestID = getDecorated().getMessageId();
if ( requestID > 0 )
{
element.addAttribute( "requestID", Integer.toString( requestID ) );
}
// Controls
ParserUtils.addControls( getCodecService(), element, getDecorated().getControls().values() );
return element;
}
示例7: parseDto2XmlHasHead
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* 将Dto转换为符合XML标准规范格式的字符串(基于节点值形式)
*
* @param dto 传入的Dto对象
* @param pRootNodeName 根结点名
* @return string 返回XML格式字符串
*/
public static final String parseDto2XmlHasHead(Map map, String pRootNodeName) {
Document document = DocumentHelper.createDocument();
// 增加一个根元素节点
document.addElement(pRootNodeName);
Element root = document.getRootElement();
Iterator keyIterator = map.keySet().iterator();
while (keyIterator.hasNext()) {
String key = (String) keyIterator.next();
String value = (String) map.get(key);
Element leaf = root.addElement(key);
leaf.setText(value);
}
// 将XML的头声明信息截去
// String outXml = document.asXML().substring(39);
String outXml = document.asXML();
return outXml;
}
示例8: addUpdateFor
import org.dom4j.Element; //导入方法依赖的package包/类
private Consumer<String> addUpdateFor(DaoGen daoGen, String key, MapperMethod method, Element root) {
return (prefix) -> {
Element sql = root.addElement("update");
sql.addComment(COMMENT);
sql.addAttribute("id", key);
StringBuilder updateSql = new StringBuilder(50);
updateSql.append("update ")
.append(method.getDaoEnv().getTableName())
.append(" set \n");
String left = key.replaceFirst(prefix, "");
List<String> fields = split(left, daoGen.separator()).stream().map(this::lowerFirst).collect(Collectors.toList());
fields.add(method.getDaoEnv().getUpdateTime());
String pk = daoGen.primaryKey();
updateSql.append(
Joiner.on(", ").join(
fields.stream().filter((field -> !field.equals(pk) &&
!method.getDaoEnv().getCreateTime().equals(field)))
.map((field -> {
if (method.getDaoEnv().getUpdateTime().equals(field))
return "`" + field + "` = " + "now() ";
else return "`" + field + "` = " + "#{" + field + "} ";
}))
.iterator()));
updateSql.append("Where `")
.append(pk)
.append("` = ")
.append("#{")
.append(pk)
.append("}");
sql.addText(updateSql.toString());
};
}
示例9: append2XML
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public void append2XML(Element root) {
Element join = root.addElement("join");
join.addAttribute("name", getName());
NodeDef toNode = outNodes.iterator().next();
join.addAttribute("to", toNode.getName());
}
示例10: export
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public void export(ExportHelper helper) throws IOException {
String s = helper.getParameter("script");
if (s == null) throw new IllegalArgumentException("No script provided, please set the script parameter.");
Script script = ScriptDAO.getInstance().get(Long.valueOf(s));
if (script == null) throw new IllegalArgumentException("Stript " + s + " does not exist.");
helper.getSessionContext().checkPermission(Right.ScriptEdit);
helper.setup("text/xml", script.getName().replace('/', '-').replace('\\', '-').replace(':', '-') + ".xml", false);
Document document = DocumentHelper.createDocument();
Element scriptEl = document.addElement("script");
scriptEl.addAttribute("name", script.getName());
if (script.getPermission() != null)
scriptEl.addAttribute("permission", script.getPermission());
scriptEl.addAttribute("engine", script.getEngine());
if (script.getDescription() != null)
scriptEl.addElement("description").add(new DOMCDATA(script.getDescription()));
for (ScriptParameter parameter: script.getParameters()) {
Element paramEl = scriptEl.addElement("parameter");
paramEl.addAttribute("name", parameter.getName());
if (parameter.getLabel() != null)
paramEl.addAttribute("label", parameter.getLabel());
paramEl.addAttribute("type", parameter.getType());
if (parameter.getDefaultValue() != null)
paramEl.addAttribute("default", parameter.getDefaultValue());
}
if (script.getScript() != null)
scriptEl.addElement("body").add(new DOMCDATA(script.getScript()));
scriptEl.addAttribute("created", new Date().toString());
OutputStream out = helper.getOutputStream();
new XMLWriter(out, OutputFormat.createPrettyPrint()).write(document);
}
示例11: exportManagers
import org.dom4j.Element; //导入方法依赖的package包/类
protected void exportManagers(Element root, Session session) {
Element managersEl = root.addElement("managers");
for (TimetableManager m: new TreeSet<TimetableManager>((List<TimetableManager>)getHibSession().createQuery(
"select distinct m from TimetableManager m inner join m.departments d where d.session.uniqueId = :sessionId"
).setLong("sessionId", session.getUniqueId()).list())) {
Element managerEl = managersEl.addElement("manager");
managerEl.addAttribute("externalId", m.getExternalUniqueId());
if (m.getFirstName() != null)
managerEl.addAttribute("firstName", m.getFirstName());
if (m.getMiddleName() != null)
managerEl.addAttribute("middleName", m.getMiddleName());
if (m.getLastName() != null)
managerEl.addAttribute("lastName", m.getLastName());
if (m.getAcademicTitle() != null)
managerEl.addAttribute("acadTitle", m.getAcademicTitle());
if (m.getEmailAddress() != null)
managerEl.addAttribute("email", m.getEmailAddress());
if (m.getFirstName() != null)
managerEl.addAttribute("firstName", m.getFirstName());
for (Department d: m.getDepartments()) {
if (session.equals(d.getSession()))
managerEl.addElement("department").addAttribute("code", d.getDeptCode());
}
for (ManagerRole r: m.getManagerRoles()) {
Element roleEl = managerEl.addElement("role");
roleEl.addAttribute("reference", r.getRole().getReference());
if (r.getPrimary() != null && r.getPrimary().booleanValue())
roleEl.addAttribute("primary", "true");
if (r.getReceiveEmails() != null)
roleEl.addAttribute("emails", r.getReceiveEmails() ? "true" : "false");
}
}
}
示例12: exportSolverGroups
import org.dom4j.Element; //导入方法依赖的package包/类
protected void exportSolverGroups(Element root, Session session) {
Element groupsEl = root.addElement("solverGroups");
for (SolverGroup g: new TreeSet<SolverGroup>((List<SolverGroup>)getHibSession().createQuery(
"from SolverGroup where session = :sessionId").setLong("sessionId", session.getUniqueId()).list())) {
Element groupEl = groupsEl.addElement("solverGroup");
groupEl.addAttribute("abbreviation", g.getAbbv());
if (g.getName() != null)
groupEl.addAttribute("name", g.getName());
for (TimetableManager m: g.getTimetableManagers())
groupEl.addElement("manager").addAttribute("externalId", m.getExternalUniqueId());
for (Department d: g.getDepartments())
groupEl.addElement("department").addAttribute("code", d.getDeptCode());
}
}
示例13: saveXml
import org.dom4j.Element; //导入方法依赖的package包/类
public void saveXml(Document document, Session session, Properties parameters) throws Exception {
try {
beginTransaction();
Element root = document.addElement("permissions");
root.addAttribute("created", new Date().toString());
document.addDocType("permissions", "-//UniTime//DTD University Course Timetabling/EN", "http://www.unitime.org/interface/Permissions.dtd");
for (Roles role: RolesDAO.getInstance().findAll(getHibSession(), Order.asc("abbv"))) {
Element r = root.addElement("role");
r.addAttribute("reference", role.getReference());
r.addAttribute("name", role.getAbbv());
r.addAttribute("manager", role.isManager() ? "true" : "false");
r.addAttribute("enabled", role.isEnabled() ? "true" : "false");
r.addAttribute("instructor", role.isInstructor() ? "true" : "false");
for (Right right: Right.values()) {
if (role.hasRight(right))
r.addElement("right").setText(right.name());
}
}
commitTransaction();
} catch (Exception e) {
fatal("Exception: "+e.getMessage(),e);
rollbackTransaction();
}
}
示例14: exportClassInstructor
import org.dom4j.Element; //导入方法依赖的package包/类
public void exportClassInstructor(Element parent, ClassInstructor classInstructor) {
Element el = parent.addElement("instructor");
el.addAttribute("uniqueId", classInstructor.getInstructor().getUniqueId().toString());
el.addAttribute("isLead", classInstructor.isLead().toString());
el.addAttribute("percentShare", classInstructor.getPercentShare().toString());
el.addAttribute("puid", classInstructor.getInstructor().getExternalUniqueId());
if (classInstructor.getResponsibility() != null)
el.addAttribute("responsibility", classInstructor.getResponsibility().getReference());
}
示例15: toDsml
import org.dom4j.Element; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Element toDsml( Element root )
{
Element element = super.toDsml( root );
CompareRequest request = getDecorated();
// Dn
if ( request.getName() != null )
{
element.addAttribute( "dn", request.getName().getName() );
}
// Assertion
Element assertionElement = element.addElement( "assertion" );
if ( request.getAttributeId() != null )
{
assertionElement.addAttribute( "name", request.getAttributeId() );
}
if ( request.getAssertionValue() != null )
{
assertionElement.addElement( "value" ).setText( request.getAssertionValue().getValue() );
}
return element;
}