當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.addElement方法代碼示例

本文整理匯總了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();
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:27,代碼來源:StudentExport.java

示例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;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:30,代碼來源:EditorRenderer.java

示例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;
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:24,代碼來源:XmlUtil.java

示例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;
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:25,代碼來源:XmlUtil.java

示例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;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:26,代碼來源:User.java

示例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;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:24,代碼來源:AbstractRequestDsml.java

示例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;
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:25,代碼來源:XmlUtil.java

示例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());
    };
}
 
開發者ID:frankelau,項目名稱:pndao,代碼行數:36,代碼來源:DaoGenHelper.java

示例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());
}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:9,代碼來源:JoinNodeDef.java

示例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);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:36,代碼來源:ScriptExportXML.java

示例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");
		}
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:34,代碼來源:AcademicSessionSetupExport.java

示例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());
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:15,代碼來源:AcademicSessionSetupExport.java

示例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();
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:29,代碼來源:PermissionsExport.java

示例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());
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:10,代碼來源:ExportPreferences.java

示例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;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:30,代碼來源:CompareRequestDsml.java


注:本文中的org.dom4j.Element.addElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。