本文整理汇总了Java中org.dom4j.Element.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.addAttribute方法的具体用法?Java Element.addAttribute怎么用?Java Element.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRemove
import org.dom4j.Element; //导入方法依赖的package包/类
private Consumer<String> addRemove(DaoGen daoGen, String key, MapperMethod method, Element root) {
return (prefix) -> {
Element sql = root.addElement("delete");
sql.addComment(COMMENT);
sql.addAttribute("id", key);
String left = key.replaceFirst(prefix, "");
List<String> params = split(left, daoGen.separator());
if (params.isEmpty()) throw new Error("Remove method needs at least one param");
StringBuilder select = new StringBuilder(50);
select.append("delete from ")
.append(method.getDaoEnv().getTableName());
int len = params.size();
if (!params.isEmpty()) select.append(" where ");
int cur = 0;
appendParams(params, select, len, cur);
sql.addText(select.toString());
};
}
示例2: 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;
}
示例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: exportTimePatterns
import org.dom4j.Element; //导入方法依赖的package包/类
protected void exportTimePatterns(Element root, Session session) {
Element patternsEl = root.addElement("timePatterns");
for (TimePattern tp: new TreeSet<TimePattern>((List<TimePattern>)getHibSession().createQuery(
"from TimePattern where session = :sessionId").setLong("sessionId", session.getUniqueId()).list())) {
Element patternEl = patternsEl.addElement("timePattern");
patternEl.addAttribute("name", tp.getName());
patternEl.addAttribute("nbrMeetings", tp.getNrMeetings().toString());
patternEl.addAttribute("minsPerMeeting", tp.getMinPerMtg().toString());
patternEl.addAttribute("type", TimePattern.sTypes[tp.getType()]);
patternEl.addAttribute("visible", tp.getVisible() != null && tp.getVisible().booleanValue() ? "true" : "false");
patternEl.addAttribute("nbrSlotsPerMeeting", tp.getSlotsPerMtg().toString());
patternEl.addAttribute("breakTime", tp.getBreakTime() == null ? "0" : tp.getBreakTime().toString());
for (Department d: tp.getDepartments())
patternEl.addElement("department").addAttribute("code", d.getDeptCode());
for (TimePatternDays days: new TreeSet<TimePatternDays>(tp.getDays())) {
patternEl.addElement("days").addAttribute("code", dayCode2days(days.getDayCode()));
}
for (TimePatternTime time: new TreeSet<TimePatternTime>(tp.getTimes())) {
patternEl.addElement("time").addAttribute("start", startSlot2startTime(time.getStartSlot()));
}
}
}
示例5: 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;
}
示例6: createReferencePropertyDef
import org.dom4j.Element; //导入方法依赖的package包/类
private Element createReferencePropertyDef(Entity entity,RuleSet ruleSet,boolean isSelf){
String nodeName=Reference.class.getSimpleName();
Rule rule=ruleSet.getRule(nodeName);
Element referenceDefElement=new BaseElement(rule.getNodeName());
referenceDefElement.addAttribute("name", entity.getName());
//创建dataType与dataProvider属性
Element dataTypeElement=createPropertyElement("dataType",null);
if(isSelf){
dataTypeElement.setText("[SELF]");
}else{
dataTypeElement.setText("["+ entity.getName()+"]");
}
referenceDefElement.add(dataTypeElement);
String entityName=entity.getName();
Element dataProviderElement=createPropertyElement("dataProvider","dataProvider"+entityName.substring(0,1).toUpperCase()+entityName.substring(1,entityName.length()));
if(entity.getPageSize()>0){
Element pageSizeElement=createPropertyElement("pageSize",String.valueOf(entity.getPageSize()));
referenceDefElement.add(pageSizeElement);
}
referenceDefElement.add(dataProviderElement);
referenceDefElement.add(createReferenceParameterElement(entity));
return referenceDefElement;
}
示例7: exportRoomGroupPref
import org.dom4j.Element; //导入方法依赖的package包/类
public void exportRoomGroupPref(Element parent, RoomGroupPref roomGroupPref) {
Element el = parent.addElement("roomGroupPref");
el.addAttribute("uniqueId", roomGroupPref.getUniqueId().toString());
el.addAttribute("level", roomGroupPref.getPrefLevel().getPrefProlog());
el.addAttribute("group", roomGroupPref.getRoomGroup().getName());
}
示例8: append2XML
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public void append2XML(Element root) {
Element fork = root.addElement("fork");
fork.addAttribute("name", getName());
for (NodeDef node : outNodes) {
Element path = fork.addElement("path");
path.addAttribute("start", node.getName());
}
}
示例9: append2XML
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public void append2XML(Element root) {
Element kill = root.addElement("kill");
Element msg = kill.addElement("message");
msg.addText("Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]");
kill.addAttribute("name", "fail");
Element end = root.addElement("end");
end.addAttribute("name", getName());
}
示例10: openTag
import org.dom4j.Element; //导入方法依赖的package包/类
public void openTag(String tagName, XMLAttributeList attributeList) {
Branch top = stack.getLast();
Element element = top.addElement(tagName);
stack.addLast(element);
for (Iterator<XMLAttributeList.NameValuePair> i= attributeList.iterator();
i.hasNext(); ) {
XMLAttributeList.NameValuePair pair = i.next();
element.addAttribute(pair.getName(), pair.getValue());
}
}
示例11: exportTimeLocation
import org.dom4j.Element; //导入方法依赖的package包/类
protected void exportTimeLocation(Element classElement, Assignment assignment, Session session) {
TimeLocation time = assignment.getTimeLocation();
if (time!=null) {
Element timeElement = classElement.addElement("time");
timeElement.addAttribute("days", dayCode2days(time.getDayCode()));
timeElement.addAttribute("startTime", startSlot2startTime(time.getStartSlot()));
timeElement.addAttribute("endTime", timeLocation2endTime(time));
DatePattern dp = assignment.getDatePattern();
if (dp != null && (!dp.isDefault() || ApplicationProperty.DataExchangeIncludeDefaultDatePattern.isTrue()))
timeElement.addAttribute("datePattern", dp.getName());
if (assignment.getTimePattern() != null)
timeElement.addAttribute("timePattern", assignment.getTimePattern().getName());
}
}
示例12: exportEvent
import org.dom4j.Element; //导入方法依赖的package包/类
protected void exportEvent(Element classElement, Event event, Session session) {
if (event == null) return;
List<Meeting> meetings = new ArrayList<Meeting>(event.getMeetings());
Collections.sort(meetings, new Comparator<Meeting>() {
@Override
public int compare(Meeting m1, Meeting m2) {
if (m1.equals(m2)) return 0;
int cmp = m1.getMeetingDate().compareTo(m2.getMeetingDate());
if (cmp != 0) return cmp;
cmp = m1.getStartPeriod().compareTo(m2.getStartPeriod());
if (cmp != 0) return cmp;
Location l1 = (m1.getLocationPermanentId() == null ? null : iMeetingLocations.get(m1.getLocationPermanentId()));
Location l2 = (m2.getLocationPermanentId() == null ? null : iMeetingLocations.get(m2.getLocationPermanentId()));
cmp = (l1 == null ? "" : l1.getLabel()).compareTo(l2 == null ? "" : l2.getLabel());
if (cmp != 0) return cmp;
return m1.getUniqueId().compareTo(m2.getUniqueId());
}
});
for (Meeting meeting: meetings) {
if (meeting.getStatus() != Meeting.Status.APPROVED) continue;
Element meetingElement = classElement.addElement("meeting");
meetingElement.addAttribute("startDate", sDateFormat.format(meeting.getMeetingDate()));
meetingElement.addAttribute("endDate", sDateFormat.format(meeting.getMeetingDate()));
meetingElement.addAttribute("startTime", sTimeFormat.format(meeting.getStartTime()));
meetingElement.addAttribute("endTime", sTimeFormat.format(meeting.getStopTime()));
Calendar c = Calendar.getInstance(Locale.US); c.setTime(meeting.getMeetingDate());
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY : meetingElement.addAttribute("days","M"); break;
case Calendar.TUESDAY : meetingElement.addAttribute("days","T"); break;
case Calendar.WEDNESDAY : meetingElement.addAttribute("days","W"); break;
case Calendar.THURSDAY : meetingElement.addAttribute("days","R"); break;
case Calendar.FRIDAY : meetingElement.addAttribute("days","F"); break;
case Calendar.SATURDAY : meetingElement.addAttribute("days","S"); break;
case Calendar.SUNDAY : meetingElement.addAttribute("days","U"); break;
}
Location location = (meeting.getLocationPermanentId() == null ? null : iMeetingLocations.get(meeting.getLocationPermanentId()));
if (location==null) {
} else if (location instanceof Room) {
meetingElement.addAttribute("building", ((Room)location).getBuildingAbbv());
meetingElement.addAttribute("room", ((Room)location).getRoomNumber());
} else {
meetingElement.addAttribute("location", location.getLabel());
}
}
}
示例13: save
import org.dom4j.Element; //导入方法依赖的package包/类
public void save(Element root) {
root.addAttribute("version", String.valueOf(sVersion));
if (iName!=null)
root.addElement("name").setText(iName);
root.addElement("pref").setText(iPreference);
if (iType!=null)
root.addElement("type").setText(iType);
root.addElement("isSatisfied").setText(String.valueOf(iIsSatisfied));
}
示例14: render_edit_mode
import org.dom4j.Element; //导入方法依赖的package包/类
/** Renders a managed standards field, unless this collection does not allow the suggestion
service, in which case the field is rendered as a repeating simple type */
protected void render_edit_mode() {
Element parentExists = rhelper.parentNodeExistsTest(xpath);
parent.add(parentExists);
insertDisplaySetup(parentExists);
// LABEL - use a complex label so we can make it
// collapsible. Otherwise, use simpleTypeLabel
Label label = renderer.getMultiBoxLabel(xpath);
// add a controller to delete this element
Element deleteController = renderer.getDeleteController(xpath, "field");
((SimpleTypeLabel) label).control = deleteController;
// create box
Element box = df.createElement("div")
.addAttribute("id", "${id}_box");
embedDebugInfo(box, "simpleType");
// attach box
parentExists.add(box);
// create fieldElement (containing input element)
Element fieldElement = df.createElement("div");
fieldElement.addAttribute("id", "${id}");
Element inputElement = null;
try {
prtln("rendering as managedStandards_MultiBox (" + normalizedXPath + ")");
Element helperChoice = df.createElement("c__choose");
Element helperPresent = df.createElement ("c__when")
.addAttribute("test", "${not empty "+this.formBeanName+".suggestionServiceHelper}");
Element otherwise = df.createElement ("c__otherwise");
helperChoice.add (helperPresent);
helperChoice.add (otherwise);
prtln("rendering as managedStandards_MultiBox (" + normalizedXPath + ")");
Element standardsTag = df.createElement("std__" + standardsManager.getRendererTag())
.addAttribute("elementPath", "enumerationValuesOf(" + XPathUtils.getSiblingXPath(xpath) + ")")
.addAttribute("pathArg", XPathUtils.getSiblingXPath(xpath));
helperPresent.add (standardsTag);
// render this xpath as a repeatingSimpleType, attached to the "otherwise" clause
RendererImpl newRenderer = (RendererImpl)newRenderer(xpath, otherwise);
MdeRepeatingSimpleType s = new MdeRepeatingSimpleType(newRenderer);
s.render();
fieldElement.add(helperChoice);
} catch (Throwable t) {
prtln("WARNING: getMultiBoxInput() standards error: " + t.getMessage());
t.printStackTrace();
}
box.add(getRenderedField(label, fieldElement));
}
示例15: render_edit_mode
import org.dom4j.Element; //导入方法依赖的package包/类
/** Render editing field for this complex element */
private void render_edit_mode() {
prtln ("reder_edit_mode with: " + xpath);
if (getLevel() != 0) {
insertDisplaySetup(parent);
}
else {
Element elementPath = df.createElement("c__set")
.addAttribute("var", "elementPath")
.addAttribute("value", xpath);
parent.add(elementPath);
Element setId = df.createElement("c__set")
.addAttribute("var", "id")
.addAttribute("value", "${sf__pathToId(elementPath)}");
parent.add(setId);
}
Label label = renderer.getComplexTypeLabel(xpath);
Element controlElement = null;
Element containerBox = getComplexTypeBox();
containerBox.addAttribute("id", "${id}_box");
parent.add(containerBox);
// test for the existence of a parent, unless we are at the 0th level of the page
Element parentExists = null;
if (getLevel() == 0) {
parentExists = df.createElement("div");
attachElementId (parentExists);
}
else {
parentExists = rhelper.parentNodeExistsTest(xpath);
}
containerBox.add(parentExists);
controlElement = df.createElement("div");
attachControl(controlElement);
/* prtln ("---------- Control Element --------------");
prtln (Dom4jUtils.prettyPrint(controlElement)); */
parent = parentExists;
Element inputHelper = this.renderer.getInputHelperElement(this.xpath);
parent.add(getRenderedNoInputField(label, controlElement, inputHelper));
// make collapsible subElementBox
Element subElementsBox = parent.addElement("div");
// this.attachElementDebugInfo(subElementsBox, "MdeComplexType - subElementsBox - ${id}");
// add id to subElement Box so it can be collapsed
subElementsBox.addAttribute("id", "${id}");
if (getLevel() > 0 && isEditMode()) {
subElementsBox.addAttribute("style", "display:${" + formBeanName + ".collapseBean.displayState};");
}
// new attach point becomes subElementsBox
parent = subElementsBox;
renderSubElements();
}