本文整理匯總了Java中org.dom4j.Element.elementIterator方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.elementIterator方法的具體用法?Java Element.elementIterator怎麽用?Java Element.elementIterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element
的用法示例。
在下文中一共展示了Element.elementIterator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseXml2Map
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* 解析XML並將其節點元素壓入Dto返回(基於節點值形式的XML格式)
*
* @param pStrXml 待解析的XML字符串
* @return outDto 返回Dto
*/
public static final Map parseXml2Map(String pStrXml) {
Map map = new HashMap();
String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
Document document = null;
try {
if (pStrXml.indexOf("<?xml") < 0) pStrXml = strTitle + pStrXml;
document = DocumentHelper.parseText(pStrXml);
} catch (DocumentException e) {
logger.error("==開發人員請注意:==\n將XML格式的字符串轉換為XML DOM對象時發生錯誤啦!" + "\n詳細錯誤信息如下:", e);
}
// 獲取根節點
Element elNode = document.getRootElement();
// 遍曆節點屬性值將其壓入Dto
for (Iterator it = elNode.elementIterator(); it.hasNext();) {
Element leaf = (Element)it.next();
map.put(leaf.getName().toLowerCase(), leaf.getData());
}
return map;
}
示例2: parseXml2Map
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* 解析XML並將其節點元素壓入Dto返回(基於節點值形式的XML格式)
*
* @param pStrXml 待解析的XML字符串
* @param pXPath 節點路徑(例如:"//paralist/row" 則表示根節點paralist下的row節點的xPath路徑)
* @return outDto 返回Dto
*/
public static final Map parseXml2Map(String pStrXml, String pXPath) {
Map map = new HashMap();
String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
Document document = null;
try {
if (pStrXml.indexOf("<?xml") < 0)
pStrXml = strTitle + pStrXml;
document = DocumentHelper.parseText(pStrXml);
} catch (DocumentException e) {
log.error("==開發人員請注意:==\n將XML格式的字符串轉換為XML DOM對象時發生錯誤啦!" + "\n詳細錯誤信息如下:", e);
}
// 獲取根節點
Element elNode = document.getRootElement();
// 遍曆節點屬性值將其壓入Dto
for (Iterator it = elNode.elementIterator(); it.hasNext();) {
Element leaf = (Element) it.next();
map.put(leaf.getName().toLowerCase(), leaf.getData());
}
return map;
}
示例3: findClassNames
import org.dom4j.Element; //導入方法依賴的package包/類
private void findClassNames(String defaultPackage, Element startNode, Set<String> names) {
// if we have some extends we need to check if those classes possibly could be inside the
// same hbm.xml file...
Iterator[] classes = new Iterator[4];
classes[0] = startNode.elementIterator( "class" );
classes[1] = startNode.elementIterator( "subclass" );
classes[2] = startNode.elementIterator( "joined-subclass" );
classes[3] = startNode.elementIterator( "union-subclass" );
Iterator classIterator = new JoinedIterator( classes );
while ( classIterator.hasNext() ) {
Element element = ( Element ) classIterator.next();
String entityName = element.attributeValue( "entity-name" );
if ( entityName == null ) {
entityName = getClassName( element.attribute( "name" ), defaultPackage );
}
names.add( entityName );
findClassNames( defaultPackage, element, names );
}
}
示例4: getBankBranchLabel
import org.dom4j.Element; //導入方法依賴的package包/類
private void getBankBranchLabel(Document document) {
Element element = null;
Element roote = document.getRootElement();
for (@SuppressWarnings("unchecked")
Iterator<Element> it = roote.elementIterator(bNode[0]); it.hasNext();) {
element = it.next();
IndexModel index = new IndexModel();
index.setId(element.attributeValue(bNode[1]));
index.setIndexStr(element.attributeValue(bNode[4]));
index.setIndexBody(element.attributeValue(bNode[4]));
index.setBankCode(element.attributeValue(bNode[2]));
index.setCityCode(element.attributeValue(bNode[3]));
branchList.add(index);
}
}
示例5: elementLocation
import org.dom4j.Element; //導入方法依賴的package包/類
private Vector<NonUniversityLocation> elementLocation(Element element, Class_ c) throws Exception {
Vector<NonUniversityLocation> locations = new Vector<NonUniversityLocation>();
String elementName = "location";
if(element.element(elementName) != null){
for (Iterator<?> it = element.elementIterator(elementName); it.hasNext();){
Element roomElement = (Element) it.next();
String name = getRequiredStringAttribute(roomElement, "name", elementName);
String id = getOptionalStringAttribute(roomElement, "id");
NonUniversityLocation location = findNonUniversityLocation(id, name, c.getManagingDept());
if (location != null){
locations.add(location);
} else {
addMissingLocation(name + " - " + c.getSchedulingSubpart().getControllingCourseOffering().getSubjectArea().getSubjectAreaAbbreviation());
}
}
}
if (locations.isEmpty()){
return(null);
} else {
return(locations);
}
}
示例6: getPageList
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Gets the pageList attribute of the FrameworkConfigReader object
*
* @return The pageList value
*/
public PageList getPageList() {
if (this.pageList == null) {
pageList = new PageList();
Node editorPagesNode = getNode("/frameworkConfigRecord/editorInfo/editorPages");
if (editorPagesNode != null) {
Element fieldInfoElement = (Element) editorPagesNode;
for (Iterator i = fieldInfoElement.elementIterator(); i.hasNext(); ) {
Element editorPage = (Element) i.next();
String pageLabel = editorPage.attributeValue("pageLabel");
String elementName = editorPage.getText();
pageList.addPage(elementName, pageLabel);
}
}
String firstPage = getNodeText("/frameworkConfigRecord/editorInfo/firstPage");
if (firstPage == null || firstPage.trim().length() == 0)
firstPage = this.getRootElementName();
pageList.setFirstPage(firstPage);
pageList.setHomePage(getXmlFormat() + ".index");
}
return pageList;
}
示例7: elementRelatedCourses
import org.dom4j.Element; //導入方法依賴的package包/類
private void elementRelatedCourses(Element element, CourseEvent event) throws Exception {
String relatedCoursesElementName = "relatedCourses";
for ( Iterator<?> it = element.elementIterator(relatedCoursesElementName); it.hasNext(); ) {
Element relatedCoursesElement = (Element) it.next();
for( Iterator<?> courseIt = relatedCoursesElement.elementIterator(courseElementName); courseIt.hasNext(); ){
elementCourse((Element)courseIt.next(), event);
}
}
// if (event.getMeetings() == null || event.getMeetings().size() == 0){
// throw(new Exception(relatedCoursesElementName + " element must contain at least one " + meetingElementName + " element"));
// }
}
示例8: ClassInfo
import org.dom4j.Element; //導入方法依賴的package包/類
public ClassInfo(Element e) {
iClassId = Long.valueOf(e.attributeValue("id"));
String configId = e.attributeValue("configId");
iConfigId = (configId == null ? null : Long.valueOf(configId));
String offeringId = e.attributeValue("offeringId");
iOfferingId = (offeringId == null ? null : Long.valueOf(offeringId));
for (Iterator i = e.elementIterator("student"); i.hasNext(); ) {
iStudents.add(new StudentInfo((Element)i.next()));
}
}
示例9: bindMapSecondPass
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Called for Maps
*/
public static void bindMapSecondPass(Element node, Map model, java.util.Map classes, Mappings mappings) throws MappingException {
bindCollectionSecondPass(node, model, classes, mappings);
Iterator iter = node.elementIterator();
while( iter.hasNext() ) {
Element subnode = (Element) iter.next();
String name = subnode.getName();
if ( "index".equals(name) ) {
SimpleValue value = new SimpleValue( model.getCollectionTable() );
bindSimpleValue(subnode, value, model.isOneToMany(), IndexedCollection.DEFAULT_INDEX_COLUMN_NAME, mappings);
model.setIndex(value);
if ( model.getIndex().getType()==null ) {
throw new MappingException( "map index element must specify a type" + model.getRole() );
}
}
else if ( "index-many-to-many".equals(name) ) {
ManyToOne mto = new ManyToOne( model.getCollectionTable() );
bindManyToOne( subnode, mto, IndexedCollection.DEFAULT_INDEX_COLUMN_NAME, model.isOneToMany(), mappings );
model.setIndex(mto);
}
else if ( "composite-index".equals(name) ) {
Component component = new Component( model.getCollectionTable() );
bindComponent(subnode, component, null, model.getRole(), "index", model.isOneToMany(), mappings);
model.setIndex(component);
}
else if ( "index-many-to-any".equals(name) ) {
Any any = new Any( model.getCollectionTable() );
bindAny( subnode, any, model.isOneToMany(), mappings );
model.setIndex(any);
}
}
}
示例10: load
import org.dom4j.Element; //導入方法依賴的package包/類
public void load(Element root) {
clear();
int version = Integer.parseInt(root.attributeValue("version"));
if (version==1) {
for (Iterator i=root.elementIterator("entry");i.hasNext();) {
Element el = (Element)i.next();
setProperty(el.attributeValue("key"),el.getText());
}
}
}
示例11: generate
import org.dom4j.Element; //導入方法依賴的package包/類
public void generate() throws IOException, DocumentException {
Document document = read(iConfig);
Element root = document.getRootElement();
Element sessionFactoryElement = root.element("session-factory");
for (Iterator<Element> i = sessionFactoryElement.elementIterator("mapping"); i.hasNext(); ) {
Element m = i.next();
String resource = m.attributeValue("resource");
if (resource == null) continue;
generate(read(resource).getRootElement(), null);
}
}
示例12: load
import org.dom4j.Element; //導入方法依賴的package包/類
public void load(Element root) {
int version = Integer.parseInt(root.attributeValue("version"));
if (version==sVersion) {
iVariables.clear();
for (Iterator i1=root.elementIterator("var");i1.hasNext();) {
CBSVariable var = new CBSVariable((Element)i1.next());
iVariables.put(new Long(var.getId()),var);
}
}
}
示例13: elementDates
import org.dom4j.Element; //導入方法依賴的package包/類
private HashMap<String, Vector<Calendar>> elementDates(Element element) throws Exception {
Vector<Calendar> startDates = new Vector<Calendar>();
Vector<Calendar> endDates = new Vector<Calendar>();
String elementName = "date";
if(element.element(elementName) != null){
for (Iterator<?> it = element.elementIterator(elementName); it.hasNext();){
Element dateElement = (Element) it.next();
Calendar startDate = null;
Calendar endDate = null;
if(dateFormat == null) {
startDate = getCalendarForDate(getRequiredStringAttribute(dateElement, "startDate", elementName));
endDate = getCalendarForDate(getRequiredStringAttribute(dateElement, "endDate", elementName));;
} else {
startDate = Calendar.getInstance();
startDate.setTime(CalendarUtils.getDate(getRequiredStringAttribute(dateElement, "startDate", elementName), dateFormat));
endDate = Calendar.getInstance();
endDate.setTime(CalendarUtils.getDate(getRequiredStringAttribute(dateElement, "endDate", elementName), dateFormat));
}
if (startDate == null){
throw new Exception("For element 'date' a 'startDate' is required, unable to parse given date");
}
if (endDate == null){
throw new Exception("For element 'date' a 'endDate' is required, unable to parse given date");
}
if (endDate.before(startDate)){
endDate.add(Calendar.YEAR, 1);
}
startDates.add(startDate);
endDates.add(endDate);
}
}
if (startDates.size() > 0){
HashMap<String, Vector<Calendar>> dates = new HashMap<String, Vector<Calendar>>();
dates.put("startDates", startDates);
dates.put("endDates", endDates);
return(dates);
} else {
return(null);
}
}
示例14: readConfiguration
import org.dom4j.Element; //導入方法依賴的package包/類
public MappingDescriptor readConfiguration(String fileAddress){
MappingDescriptor mappingDescriptor=new MappingDescriptor();
Document document = readXml(fileAddress);
Element rootElement=document.getRootElement();
for(Iterator<Element> i=rootElement.elementIterator("class");i.hasNext();){
Element classElement = i.next();
MappingDescriptor.ClassDescriptor classDescriptor=new MappingDescriptor.ClassDescriptor();
classDescriptor.setClassAttribute(readClassAttribute(classElement.attributes()));
classDescriptor.setId(readId(classElement.element("id")));
classDescriptor.setProperties(readProperties(classElement.elements("property")));
mappingDescriptor.setClassDescriptor(classDescriptor);
}
return mappingDescriptor;
}
示例15: addProperties
import org.dom4j.Element; //導入方法依賴的package包/類
private void addProperties(Element parent) {
Iterator iter = parent.elementIterator("property");
while ( iter.hasNext() ) {
Element node = (Element) iter.next();
String name = node.attributeValue("name");
String value = node.getText().trim();
log.debug(name + "=" + value);
properties.setProperty(name, value);
if ( !name.startsWith("hibernate") ) properties.setProperty("hibernate." + name, value);
}
Environment.verifyProperties(properties);
}