List of usage examples for org.dom4j Element elementText
String elementText(QName qname);
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private String parseWeekschedule(org.dom4j.Element weekSchedule) { String sConcatValue = ""; if (weekSchedule != null) { org.dom4j.Element timeBlocks = weekSchedule.element("TimeBlocks"); if (timeBlocks != null) { Iterator timeBlockIter = timeBlocks.elementIterator("TimeBlock"); String sTmpDayIdx, sTmpBeginHour, sTmpEndHour, sTmpDuration; org.dom4j.Element timeBlock; while (timeBlockIter.hasNext()) { timeBlock = (org.dom4j.Element) timeBlockIter.next(); sTmpDayIdx = checkString(timeBlock.elementText("DayIdx")); sTmpBeginHour = checkString(timeBlock.elementText("BeginHour")); sTmpEndHour = checkString(timeBlock.elementText("EndHour")); sTmpDuration = checkString(timeBlock.elementText("Duration")); sConcatValue += sTmpDayIdx + "|" + sTmpBeginHour + "|" + sTmpEndHour + "|" + sTmpDuration + "$"; }/*from ww w. j a v a 2 s . c o m*/ } } return sConcatValue; }
From source file:cc.dectinc.video.tagging.tools.MetaImporter.java
/** * Given path, load the metadata of the fiven video file * //w w w . ja va2s. c om * @param path */ private void parseFile(String path) { File file = new File(path); if (!file.exists()) { // System.out.println("File not found: " + file.getName()); return; } Document document = null; try { SAXReader reader = new SAXReader(); document = reader.read(file); Element root = document.getRootElement(); Meta meta = new Meta(); meta.set("identifier", root.elementText("identifier")); meta.set("title", root.elementText("title")); meta.set("mediatype", root.elementText("mediatype")); // meta.set("resource", root.elementText("licenseurl")); meta.set("uploader", root.elementText("uploader")); // meta.set("description", root.elementText("description")); // meta.set("year", Integer.parseInt(root.elementText("date"))); // meta.set("holder", root.elementText("")); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); meta.set("pubdate", df.parse(root.elementText("publicdate"))); meta.save(); } catch (Exception e) { e.printStackTrace(); } }
From source file:cn.buk.api.service.CtripHotelServiceImpl.java
License:LGPL
@Override public String importCityInfo(String filename) { SAXReader reader = new SAXReader(); File file = new File(filename); if (!file.exists()) return "not exist."; Document document;// ?XML try {//from w ww . j ava 2s .co m document = reader.read(file); } catch (DocumentException e) { e.printStackTrace(); return "error"; } List flightDataList = document.selectNodes("//CityDetails/*"); List<City> cities = new ArrayList<City>(); String temp; for (Iterator it = flightDataList.iterator(); it.hasNext();) { Element fltElement = (Element) it.next(); City city = new City(); cities.add(city); city.setCityCode(fltElement.element("CityCode").getText()); city.setOpenApiId(Integer.parseInt(fltElement.element("City").getText())); city.setCityName(fltElement.element("CityName").getText()); city.setCityEnglishName(fltElement.elementText("CityEName").trim()); temp = fltElement.elementText("Country").trim(); if (temp.equalsIgnoreCase("1")) city.setCountryCode("CN"); else city.setCountryCode(temp); city.setProvinceId(Integer.parseInt(fltElement.elementText("Province"))); city.setAirport(fltElement.element("Airport").getText()); } int count = 0; for (City city : cities) { if (city.getCityCode() == null || city.getCityCode().trim().length() == 0) continue; if (cityDao.create(city) == 1) count++; } return "create " + count + " record(s)."; }
From source file:cn.ict.zyq.bestConf.util.ParseXMLToYaml.java
License:Open Source License
public static HashMap parseXMLToHashmap(String filePath) { HashMap result = new HashMap(); try {/* w w w . j av a 2 s .c om*/ File f = new File(filePath); SAXReader reader = new SAXReader(); Document doc = reader.read(f); Element root = doc.getRootElement(); Element foo; for (Iterator i = root.elementIterator("property"); i.hasNext();) { foo = (Element) i.next(); String value; if (foo.elementText("value") != null) { value = foo.elementText("value"); Pattern pattern = Pattern.compile("^-?[0-9]\\d*$"); Matcher matcher = pattern.matcher(value); if (matcher.find()) { result.put(foo.elementText("name"), value); } else if (Pattern.compile("^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$").matcher(value) .find()) { result.put(foo.elementText("name"), value); } else { } } } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:com.ah.be.performance.db.TablePartitionProcessor.java
private void init() { try {/*from w ww . jav a 2 s . co m*/ File f = new File(TABLE_PARTITION_CONF_FILE); SAXReader reader = new SAXReader(); Document doc = reader.read(f); Element root = doc.getRootElement(); Element cata = null; int catalog = 1; for (Iterator<?> i = root.elementIterator(); i.hasNext();) { //for catalog cata = (Element) i.next(); String enable = cata.elementText("enable"); if (enable != null && enable.equalsIgnoreCase("false")) continue; int default_maxtime = Integer.parseInt(cata.elementTextTrim("default_maxtime")); int default_interval = Integer.parseInt(cata.elementTextTrim("default_interval")); int table_partition_number = Integer.parseInt(cata.elementTextTrim("table_partition_number")); int default_max_record = Integer.parseInt(cata.elementTextTrim("default_max_record")); int default_max_record_per_partition = Integer .parseInt(cata.elementTextTrim("default_max_record_per_partition")); int maxtime_policy = Integer.parseInt(cata.elementTextTrim("maxtime_policy")); int interval_policy = Integer.parseInt(cata.elementTextTrim("interval_policy")); int max_record_policy = Integer.parseInt(cata.elementTextTrim("max_record_policy")); addTableCatalogInfo(catalog, default_maxtime, default_interval, table_partition_number, default_max_record, default_max_record_per_partition, maxtime_policy, interval_policy, max_record_policy); List<?> tableElements = cata.elements("table"); //for table in catalog for (int j = 0; j < tableElements.size(); j++) { Element table = (Element) tableElements.get(j); String tableName = table.attributeValue("name"); String schemaName = table.elementTextTrim("schemaname"); String timeField = table.elementTextTrim("timefield"); addTableInfo(schemaName, tableName, timeField, catalog); } catalog++; } } catch (Exception e) { BeLogTools.error(HmLogConst.M_PERFORMANCE_TABLEPARTITION, "Fail to init table partition configure file", e); } }
From source file:com.aliyun.odps.ogg.handler.datahub.ConfigureReader.java
License:Apache License
public static Configure reader(String configueFileName) throws DocumentException { logger.info("Begin read configure[" + configueFileName + "]"); Configure configure = new Configure(); SAXReader reader = new SAXReader(); File file = new File(configueFileName); Document document = reader.read(file); Element root = document.getRootElement(); String elementText = root.elementTextTrim("batchSize"); if (StringUtils.isNotBlank(elementText)) { configure.setBatchSize(Integer.parseInt(elementText)); }//from w ww. ja v a2s . c om elementText = root.elementTextTrim("dirtyDataContinue"); if (StringUtils.isNotBlank(elementText)) { configure.setDirtyDataContinue(Boolean.parseBoolean(elementText)); } elementText = root.elementTextTrim("dirtyDataFile"); if (StringUtils.isNotBlank(elementText)) { configure.setDirtyDataFile(elementText); } elementText = root.elementTextTrim("dirtyDataFileMaxSize"); if (StringUtils.isNotBlank(elementText)) { configure.setDirtyDataFileMaxSize(Integer.parseInt(elementText)); } elementText = root.elementTextTrim("retryTimes"); if (StringUtils.isNotBlank(elementText)) { configure.setRetryTimes(Integer.parseInt(elementText)); } elementText = root.elementTextTrim("retryInterval"); if (StringUtils.isNotBlank(elementText)) { configure.setRetryInterval(Integer.parseInt(elementText)); } elementText = root.elementTextTrim("disableCheckPointFile"); if (StringUtils.isNotBlank(elementText)) { configure.setDisableCheckPointFile(Boolean.parseBoolean(elementText)); } elementText = root.elementTextTrim("checkPointFileName"); if (StringUtils.isNotBlank(elementText)) { configure.setCheckPointFileName(elementText); } Element element = root.element("defaultOracleConfigure"); if (element == null) { throw new RuntimeException("defaultOracleConfigure is null"); } elementText = element.elementTextTrim("sid"); if (StringUtils.isBlank(elementText)) { throw new RuntimeException("defaultOracleConfigure.sid is null"); } configure.setSid(elementText); String defaultOracleSchema = element.elementTextTrim("schema"); SimpleDateFormat defaultSimpleDateFormat; elementText = element.elementTextTrim("dateFormat"); if (StringUtils.isNotBlank(elementText)) { defaultSimpleDateFormat = new SimpleDateFormat(elementText); } else { defaultSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } element = root.element("defalutDatahubConfigure"); if (element == null) { throw new RuntimeException("defalutDatahubConfigure is null"); } String endPoint = element.elementText("endPoint"); if (StringUtils.isBlank(endPoint)) { throw new RuntimeException("defalutDatahubConfigure.endPoint is null"); } String defaultDatahubProject = element.elementText("project"); String defaultDatahubAccessID = element.elementText("accessId"); String defaultDatahubAccessKey = element.elementText("accessKey"); Field defaultCTypeField = null; String defaultCTypeColumn = element.elementText("ctypeColumn"); if (StringUtils.isNotBlank(defaultCTypeColumn)) { defaultCTypeField = new Field(defaultCTypeColumn, FieldType.STRING); } Field defaultCTimeField = null; String defaultCTimeColumn = element.elementText("ctimeColumn"); if (StringUtils.isNotBlank(defaultCTimeColumn)) { defaultCTimeField = new Field(defaultCTimeColumn, FieldType.STRING); } Field defaultCidField = null; String defaultCidColumn = element.elementText("cidColumn"); if (StringUtils.isNotBlank(defaultCidColumn)) { defaultCidField = new Field(defaultCidColumn, FieldType.STRING); } String defaultConstColumnMapStr = element.elementText("constColumnMap"); Map<String, String> defalutConstColumnMappings = Maps.newHashMap(); Map<String, Field> defaultConstColumnFieldMappings = Maps.newHashMap(); parseConstColumnMap(defaultConstColumnMapStr, defalutConstColumnMappings, defaultConstColumnFieldMappings); element = root.element("mappings"); if (element == null) { throw new RuntimeException("mappings is null"); } List<Element> mappingElements = element.elements("mapping"); if (mappingElements == null || mappingElements.size() == 0) { throw new RuntimeException("mappings.mapping is null"); } //init table mapping for (Element e : mappingElements) { String oracleSchema = e.elementTextTrim("oracleSchema"); if (StringUtils.isNotBlank(oracleSchema)) { //nothing } else if (StringUtils.isNotBlank(defaultOracleSchema)) { oracleSchema = defaultOracleSchema; } else { throw new RuntimeException( "both mappings.mapping.oracleSchema and defaultOracleConfigure.schema is null"); } String oracleTable = e.elementTextTrim("oracleTable"); if (StringUtils.isBlank(oracleTable)) { throw new RuntimeException("mappings.mapping.oracleTable is null"); } String datahubProject = e.elementTextTrim("datahubProject"); if (StringUtils.isNotBlank(datahubProject)) { //nothing } else if (StringUtils.isNotBlank(defaultOracleSchema)) { datahubProject = defaultDatahubProject; } else { throw new RuntimeException( "both mappings.mapping.datahubProject and defalutDatahubConfigure.project is null"); } String datahubAccessId = e.elementTextTrim("datahubAccessId"); if (StringUtils.isNotBlank(datahubAccessId)) { //nothing } else if (StringUtils.isNotBlank(defaultDatahubAccessID)) { datahubAccessId = defaultDatahubAccessID; } else { throw new RuntimeException( "both mappings.mapping.datahubAccessId and defalutDatahubConfigure.accessId is null"); } String datahubAccessKey = e.elementTextTrim("datahubAccessKey"); if (StringUtils.isNotBlank(datahubAccessKey)) { //nothing } else if (StringUtils.isNotBlank(defaultDatahubAccessKey)) { datahubAccessKey = defaultDatahubAccessKey; } else { throw new RuntimeException( "both mappings.mapping.datahubAccessKey and defalutDatahubConfigure.accessKey is null"); } String topicName = e.elementTextTrim("datahubTopic"); if (topicName == null) { throw new RuntimeException("mappings.mapping.datahubTopic is null"); } String ctypeColumn = e.elementText("ctypeColumn"); String ctimeColumn = e.elementText("ctimeColumn"); String cidColumn = e.elementText("cidColumn"); DatahubConfiguration datahubConfiguration = new DatahubConfiguration( new AliyunAccount(datahubAccessId, datahubAccessKey), endPoint); Project project = Project.Builder.build(datahubProject, datahubConfiguration); Topic topic = project.getTopic(topicName); if (topic == null) { throw new RuntimeException("Can not find datahub topic[" + topicName + "]"); } else { logger.info( "topic name: " + topicName + ", topic schema: " + topic.getRecordSchema().toJsonString()); } TableMapping tableMapping = new TableMapping(); tableMapping.setTopic(topic); tableMapping.setOracleSchema(oracleSchema.toLowerCase()); tableMapping.setOracleTableName(oracleTable.toLowerCase()); tableMapping.setOracleFullTableName( tableMapping.getOracleSchema() + "." + tableMapping.getOracleTableName()); tableMapping .setCtypeField(StringUtils.isNotBlank(ctypeColumn) ? new Field(ctypeColumn, FieldType.STRING) : defaultCTypeField); tableMapping .setCtimeField(StringUtils.isNotBlank(ctimeColumn) ? new Field(ctimeColumn, FieldType.STRING) : defaultCTimeField); tableMapping.setCidField( StringUtils.isNotBlank(cidColumn) ? new Field(cidColumn, FieldType.STRING) : defaultCidField); String constColumnMapStr = e.elementText("constColumnMap"); Map<String, String> constColumnMappings = Maps.newHashMap(); Map<String, Field> constColumnFieldMappings = Maps.newHashMap(); parseConstColumnMap(constColumnMapStr, constColumnMappings, constColumnFieldMappings); tableMapping.setConstColumnMappings( constColumnMappings.isEmpty() ? defalutConstColumnMappings : constColumnMappings); tableMapping.setConstFieldMappings(constColumnFieldMappings.isEmpty() ? defaultConstColumnFieldMappings : constColumnFieldMappings); Map<String, ColumnMapping> columnMappings = Maps.newHashMap(); tableMapping.setColumnMappings(columnMappings); elementText = e.elementTextTrim("shardId"); if (StringUtils.isNotBlank(elementText)) { tableMapping.setShardId(elementText); } configure.addTableMapping(tableMapping); RecordSchema recordSchema = topic.getRecordSchema(); Element columnMappingElement = e.element("columnMapping"); List<Element> columns = columnMappingElement.elements("column"); for (Element columnElement : columns) { String oracleColumnName = columnElement.attributeValue("src"); if (StringUtils.isBlank(oracleColumnName)) { throw new RuntimeException("Topic[" + topicName + "] src attribute is null"); } oracleColumnName = oracleColumnName.toLowerCase(); ColumnMapping columnMapping = new ColumnMapping(); columnMappings.put(oracleColumnName, columnMapping); columnMapping.setOracleColumnName(oracleColumnName); String datahubFieldName = columnElement.attributeValue("dest"); if (datahubFieldName == null) { throw new RuntimeException("Topic[" + topicName + "] dest attribute is null"); } Field field = recordSchema.getField(datahubFieldName.toLowerCase()); if (field == null) { throw new RuntimeException( "Topic[" + topicName + "] Field[" + datahubFieldName + "] is not exist"); } columnMapping.setField(field); String datahubOldFieldName = columnElement.attributeValue("destOld"); if (StringUtils.isNotBlank(datahubOldFieldName)) { Field oldField = recordSchema.getField(datahubOldFieldName); if (field == null) { throw new RuntimeException( "Topic[" + topicName + "] Field[" + datahubOldFieldName + "] is not exist"); } columnMapping.setOldFiled(oldField); } String isShardColumn = columnElement.attributeValue("isShardColumn"); if (StringUtils.isNotBlank(isShardColumn) && Boolean.TRUE.equals(Boolean.valueOf(isShardColumn))) { tableMapping.setIsShardHash(true); columnMapping.setIsShardColumn(true); } else { columnMapping.setIsShardColumn(false); } String isKeyColumn = columnElement.attributeValue("isKeyColumn"); if (StringUtils.isNotBlank(isKeyColumn) && Boolean.TRUE.equals(Boolean.valueOf(isKeyColumn))) { columnMapping.setIsKeyColumn(true); } else { columnMapping.setIsKeyColumn(false); } String dateFormat = columnElement.attributeValue("dateFormat"); if (StringUtils.isNotBlank(dateFormat)) { columnMapping.setSimpleDateFormat(new SimpleDateFormat(dateFormat)); } else { columnMapping.setSimpleDateFormat(defaultSimpleDateFormat); } String isDateFormat = columnElement.attributeValue("isDateFormat"); if (StringUtils.isNotBlank(isDateFormat) && Boolean.FALSE.equals(Boolean.valueOf(isDateFormat))) { columnMapping.setIsDateFormat(false); } else { columnMapping.setIsDateFormat(true); } } } logger.info("Read configure success: " + JsonHelper.beanToJson(configure)); return configure; }
From source file:com.allinfinance.common.grid.GridConfigUtil.java
License:Open Source License
/** * ??/* w w w . java2 s . c om*/ * @param context * @throws Exception */ @SuppressWarnings("unchecked") public static void initGirdConfig(ServletContext context) throws Exception { SAXReader reader = new SAXReader(); Document document = null; document = reader.read(context.getResourceAsStream(Constants.GRID_CONFIG_CONTEXTPATH)); Element root = document.getRootElement(); List<Element> gridInfoList = root.elements(GridConfigConstants.NODE_GRID); for (Element gridNode : gridInfoList) { String gridId = gridNode.attributeValue(GridConfigConstants.GRID_ID); String gridConfigType = gridNode.attributeValue(GridConfigConstants.GRID_TYPE); //? GridModel gridModel = new GridModel(); gridModel.setId(gridId); gridModel.setType(gridConfigType); gridModel.setColumns(gridNode.elementText(GridConfigConstants.COLUMNS).trim()); if (GridConfigConstants.TYPE_SQL.equals(gridConfigType)) { SqlMode sqlMode = new SqlMode(); //SQL? Element sqlModeNode = gridNode.element(GridConfigConstants.TYPE_SQLMODE); //? Element wheresNode = sqlModeNode.element(GridConfigConstants.WHERES); List<Element> whereList = wheresNode.elements(GridConfigConstants.WHERE); sqlMode.setSql(sqlModeNode.elementText(GridConfigConstants.SQL).trim()); sqlMode.setDao(sqlModeNode.elementText(GridConfigConstants.QUERY_DAO).trim()); //? if (whereList != null && whereList.size() > 0) { WheresModel wheresModel = new WheresModel(); List<WhereModel> whereModelList = new ArrayList<WhereModel>(); for (Element whereNode : whereList) { WhereModel whereModel = new WhereModel(); whereModel.setType(whereNode.attributeValue(GridConfigConstants.WHERE_TYPE)); whereModel.setOperator(whereNode.attributeValue(GridConfigConstants.WHERE_OPERATOR)); whereModel.setLogic(whereNode.attributeValue(GridConfigConstants.WHERE_LOGIC)); whereModel.setDataBaseColumn( whereNode.elementText(GridConfigConstants.WHERE_DATABASE_COLUMN).trim()); whereModel.setQueryColumn( whereNode.elementText(GridConfigConstants.WHERE_QUERY_COLUMN).trim()); whereModelList.add(whereModel); } wheresModel.setWhereModelList(whereModelList); sqlMode.setWheresModel(wheresModel); } // ??? if (sqlModeNode.element(GridConfigConstants.ORDERS) != null) { OrdersModel ordersModel = new OrdersModel(); Element orderModels = sqlModeNode.element(GridConfigConstants.ORDERS); ordersModel.setSort(orderModels.attributeValue("sort")); List<Element> orderList = orderModels.elements(GridConfigConstants.ORDER); for (Element element : orderList) { ordersModel.getOrders().add(element.getText()); } sqlMode.setOrdersModel(ordersModel); } gridModel.setSqlMode(sqlMode); } else if (GridConfigConstants.TYPE_SYNC.equals(gridConfigType)) { SyncMode syncMode = new SyncMode(); Element syncModeNode = gridNode.element(GridConfigConstants.TYPE_SYNCMODE); Element methodNode = syncModeNode.element(GridConfigConstants.SYNC_METHOD); syncMode.setMethod(methodNode.attributeValue(GridConfigConstants.SYNC_METHOD_VALUE)); gridModel.setSyncMode(syncMode); } else { throw new Exception("???[ id:" + gridId + " ]"); } gridConfigMap.put(gridId, gridModel); } }
From source file:com.appdynamics.monitors.hbase.HBaseMonitor.java
License:Apache License
private void getCredentials(final Map<String, String> args) { credentials = new ArrayList<Credential>(); Credential cred = new Credential(); cred.dbname = args.get("dbname"); cred.host = args.get("host"); cred.port = args.get("port"); cred.username = args.get("user"); cred.password = args.get("pass"); if (!isNotEmpty(cred.dbname)) { cred.dbname = "DB 1"; }// ww w . j av a2 s. c o m credentials.add(cred); String xmlPath = args.get("properties-path"); if (isNotEmpty(xmlPath)) { try { SAXReader reader = new SAXReader(); Document doc = reader.read(xmlPath); Element root = doc.getRootElement(); for (Element credElem : (List<Element>) root.elements("credentials")) { cred = new Credential(); cred.dbname = credElem.elementText("dbname"); cred.host = credElem.elementText("host"); cred.port = credElem.elementText("port"); cred.username = credElem.elementText("user"); cred.password = credElem.elementText("pass"); if (isNotEmpty(cred.host) && isNotEmpty(cred.port)) { if (!isNotEmpty(cred.dbname)) { cred.dbname = "DB " + (credentials.size() + 1); } credentials.add(cred); } } } catch (DocumentException e) { logger.error("Cannot read '" + xmlPath + "'. Monitor is running without additional credentials"); } } }
From source file:com.bay12games.df.rawedit.xml.RawsDescriptionLoader.java
License:Open Source License
/** * Parse the XML element containing token definition. * * @param e XML DOM element// w ww .j av a2 s. com * @param parentName Name of the parent element (currently unused - 20100905) * @return Parsed token. If the token existed before, returns the same (possibly * altered) instance. */ private Argument parseArgument(Element e, String parentName) { String type = e.attributeValue("type"); if (type == null) { return null; } boolean required = Boolean.parseBoolean(e.attributeValue("required")); Argument argument = null; if ("enum".equals(type)) { Set<String> items = new HashSet<String>(); for (Element ee : e.elements()) { if ("e".equals(ee.getName())) { items.add(ee.attributeValue("name")); } } argument = new Argument(type, items); } else if ("range".equals(type)) { int min = 0; int max = 0; try { min = Integer.parseInt(e.attributeValue("min")); max = Integer.parseInt(e.attributeValue("max")); argument = new Argument(type, min, max); } catch (NumberFormatException ex) { return null; } } else if ("int".equals(type)) { argument = new Argument(type); } else if ("string".equals(type)) { String id = e.attributeValue("id"); String ref = e.attributeValue("ref"); if (id != null) { // [NOTE] inline "default" id can only be a flat list. if (!ids.containsKey(id)) { Id idObject = new Id(id); ids.put(id, idObject); // we might load a description later... } } argument = new Argument(type, id, ref); } String desc = e.elementText("d"); if (desc != null && argument != null) { argument.setDescription(desc); } argument.setLabel(e.attributeValue(Constants.XML_ARGUMENT_LABLE)); return argument; }
From source file:com.bay12games.df.rawedit.xml.RawsDescriptionLoader.java
License:Open Source License
/** * Parse the XML element containing id definition. * * @param e XML DOM element/*from w w w.j a va2 s . c o m*/ * @return Parsed id. If the id existed before, returns the same (possibly * altered) instance. */ private Id parseId(Element e) { String name = e.attributeValue("name"); if (name == null) { return null; } Id id; if (ids.containsKey(name)) { id = ids.get(name); } else { id = new Id(name); ids.put(name, id); } String description = e.elementText("d"); String from = e.attributeValue("from"); String to = e.attributeValue("to"); String superidName = e.attributeValue("id"); id.setDescription(description); if (from != null && to != null) { if (id.getFromToMap() != null && id.getFromToMap().containsKey(from)) { log.warn("From-to map on id " + id.getName() + " already contains key " + from); } id.addFromTo(from, to); } // else... // If from or to are null, the list is flat, so we don't have to set anything if (superidName != null) { Id superid; if (ids.containsKey(superidName)) { superid = ids.get(superidName); } else { superid = new Id(superidName); ids.put(superidName, superid); } // [NOTE] supercategory is always flat!! superid.addItem(to); id.setParentName(superidName); } return id; }