List of usage examples for org.dom4j Element elementIterator
Iterator<Element> elementIterator();
From source file:com.ctvit.vdp.services.sysconfiguration.user.UserService.java
public String getRightXML(Map rightIds) throws DocumentException { String baseXML = systemConfigDao.selectByPrimaryKey("Rights").getValue();//??XML Document doc = DocumentHelper.parseText(baseXML); Element baseElement = doc.getRootElement(); Iterator elementIter = baseElement.elementIterator(); //?//from www .j a v a2 s.co m while (elementIter.hasNext()) {//?? Element el01 = (Element) elementIter.next(); if (rightIds.get(el01.attributeValue("id")) == null) { baseElement.remove(el01); } Iterator elIter01 = el01.elementIterator(); while (elIter01.hasNext()) {//?? Element el02 = (Element) elIter01.next(); if (rightIds.get(el02.attributeValue("id")) == null) { el01.remove(el02); } Iterator elIter02 = el02.elementIterator(); while (elIter02.hasNext()) {//??(?) Element el03 = (Element) elIter02.next(); if (rightIds.get(el03.attributeValue("id")) == null) { el02.remove(el03); } Iterator elIter03 = el03.elementIterator(); while (elIter03.hasNext()) {//??() Element el04 = (Element) elIter03.next(); if (rightIds.get(el04.attributeValue("id")) == null) { el03.remove(el04); } Iterator elIter04 = el04.elementIterator(); while (elIter04.hasNext()) {//??() Element el05 = (Element) elIter04.next(); System.out.println(el05.attributeValue("id")); if (rightIds.get(el05.attributeValue("id")) == null) { el04.remove(el05); } } } } } } return baseElement.asXML(); }
From source file:com.devoteam.srit.xmlloader.gtppr.GtppDictionary.java
License:Open Source License
private void parseFile(InputStream stream) throws Exception { Element node = null; GtppMessage msg = null;/* w ww.j a v a 2 s . c o m*/ Tag tlv = null; String length = null; String format = null; int i = 0; SAXReader reader = new SAXReader(); Document document = reader.read(stream); //parsing des messages List listMessages = document.selectNodes("/dictionary/message"); for (i = 0; i < listMessages.size(); i++) { node = (Element) listMessages.get(i); msg = new GtppMessage(); msg.setHeader(new GtpHeaderPrime()); msg.getHeader().setName(node.attributeValue("name")); msg.getHeader().setMessageType(Integer.parseInt(node.attributeValue("messageType"))); for (Iterator it = node.elementIterator(); it.hasNext();) { Element element = (Element) it.next(); String name = element.getName(); if (name.equalsIgnoreCase("tv") || name.equalsIgnoreCase("tlv") || name.equalsIgnoreCase("tliv")) { if (name.equalsIgnoreCase("tv")) { tlv = new TagTV(); } else if (name.equalsIgnoreCase("tlv")) { tlv = new TagTLIV(); } else if (name.equalsIgnoreCase("tliv")) { tlv = new TagTLIV(); } tlv.setName(element.attributeValue("name")); String value = element.attributeValue("mandatory"); if (value != null && !value.equalsIgnoreCase("cond")) { tlv.setMandatory(Boolean.parseBoolean(value)); } else//case of cond, considered as optional { tlv.setMandatory(false); } msg.addTLV(tlv); } } messagesList.put(msg.getHeader().getName(), msg); messageTypeToNameList.put(msg.getHeader().getMessageType(), msg.getHeader().getName()); messageNameToTypeList.put(msg.getHeader().getName(), msg.getHeader().getMessageType()); } //parsing des TLV List listTLV = document.selectNodes("/dictionary/tv | /dictionary/tlv | /dictionary/tliv"); for (i = 0; i < listTLV.size(); i++) { node = (Element) listTLV.get(i); String name = node.getName(); if (name.equalsIgnoreCase("tv")) { tlv = new TagTV(); } else if (name.equalsIgnoreCase("tlv")) { tlv = new TagTLV(); } else if (name.equalsIgnoreCase("tliv")) { tlv = new TagTLIV(); } tlv.setName(node.attributeValue("name")); tlv.setTag(Integer.parseInt(node.attributeValue("tag"))); length = node.attributeValue("length"); if (length != null) { tlv.setLength(Integer.parseInt(length)); tlv.setFixedLength(true); } format = node.attributeValue("format"); if (format != null) { tlv.setFormat(format); if (format.equals("list")) { tlv.setValue(new LinkedList<GtppAttribute>()); parseAtt((Attribute) tlv, node); } } tlvList.put(tlv.getName(), tlv); tlvTagToNameList.put(tlv.getTag(), tlv.getName()); tlvNameToTagList.put(tlv.getName(), tlv.getTag()); } }
From source file:com.devoteam.srit.xmlloader.gtppr.GtppDictionary.java
License:Open Source License
private void parseAtt(Attribute att, Element node) throws Exception { String length = null;/* w w w . j a v a 2s . c om*/ String format = null; //travel through all attribute for (Iterator it = node.elementIterator(); it.hasNext();) { Element element = (Element) it.next(); GtppAttribute attribute = new GtppAttribute(); attribute.setName(element.attributeValue("name")); length = element.attributeValue("length"); if (length != null && (length.length() != 0)) attribute.setLength(Integer.parseInt(length)); format = element.attributeValue("format"); if (format != null) { attribute.setFormat(format); if (format.equals("list")) { attribute.setValue(new LinkedList<GtppAttribute>()); parseAtt((Attribute) attribute, element);//recursif call } } ((LinkedList<GtppAttribute>) att.getValue()).add(attribute); } }
From source file:com.devoteam.srit.xmlloader.smpp.SmppDictionary.java
License:Open Source License
private void parseFile(InputStream stream) throws Exception { Element messageNode = null; Element group = null;// ww w. jav a 2s .c om SmppMessage msg = null; SmppAttribute att = null; SmppAttribute att2 = null; SmppGroup attGroup = null; SmppChoice attChoice = null; Vector<SmppGroup> choiceList = null; Vector<SmppAttribute> imbricateAtt = null; SmppTLV tlv = null; int i = 0; int j = 0; long id = 0; SAXReader reader = new SAXReader(); Document document = reader.read(stream); //parsing des messages List listMessages = document.selectNodes("/dictionary/message"); for (i = 0; i < listMessages.size(); i++) { messageNode = (Element) listMessages.get(i); msg = new SmppMessage(); msg.setName(messageNode.attributeValue("name")); id = Long.parseLong(messageNode.attributeValue("id"), 16); msg.setId((int) id); for (Iterator it = messageNode.elementIterator(); it.hasNext();) { Element element = (Element) it.next(); String name = element.getName(); if (name.equalsIgnoreCase("attribute")) { att = setAttribute(element); //for simple attribute //check if attribute imbricate in attribute or choice in attribute List listAtt = element.selectNodes("//attribute[@name='" + element.attributeValue("name") + "']/attribute | //attribute[@name='" + element.attributeValue("name") + "']/choice"); if (!listAtt.isEmpty()) { ((Vector) att.getValue()).add(new Vector<SmppAttribute>());//set vector of imbricate attributes into the vector of occurence } for (j = 0; j < listAtt.size(); j++) { if (((Element) listAtt.get(j)).getName().equalsIgnoreCase("attribute")) { //add imbricate attribute to att att2 = setAttribute((Element) listAtt.get(j)); ((Vector<SmppAttribute>) ((Vector) att.getValue()).get(0)).add(att2); } else if (((Element) listAtt.get(j)).getName().equalsIgnoreCase("choice")) { List groupList = element.selectNodes( "//attribute[@name='" + element.attributeValue("name") + "']/choice/group"); attChoice = new SmppChoice(); choiceList = new Vector<SmppGroup>(); //work because last imbricate att is the last attribute set and is the att base on choice attChoice.setChoiceAttribute(att2); //parse all group of the choice, could be only an attribute or a group of attribute for (j = 0; j < groupList.size(); j++) { group = (Element) groupList.get(j); //create an attribute for each group attGroup = new SmppGroup(); attGroup.setChoiceValue(group.attributeValue("value")); imbricateAtt = new Vector<SmppAttribute>(); for (Iterator iter = group.elementIterator(); iter.hasNext();) { imbricateAtt.add(setAttribute((Element) iter.next())); } attGroup.setValue(imbricateAtt); choiceList.add(attGroup); } attChoice.setValue(choiceList); ((Vector<SmppChoice>) ((Vector) att.getValue()).get(0)).add(attChoice); } } msg.addAttribut(att); } else if (name.equalsIgnoreCase("tlv")) { tlv = setTLV(element, msg); if (tlv != null) msg.addTLV(tlv); } } messagesList.put(msg.getName(), msg); messageIdToNameList.put(msg.getId(), msg.getName()); messageNameToIdList.put(msg.getName(), msg.getId()); } // //affichage des message // Collection<SmppMessage> collecMsg = messagesList.values(); // System.out.println("\r\nnb de message dans la collection: " + collecMsg.size()); // for(Iterator<SmppMessage> iter = collecMsg.iterator(); iter.hasNext();) // { // SmppMessage msgEle = (SmppMessage)iter.next(); // if(msgEle.getName().equals("submit_multi")) // { // System.out.println(msgEle.getName()); // //affichage des attributs // System.out.println(msgEle.toString()); // } // } }
From source file:com.devoteam.srit.xmlloader.ucp.UcpDictionary.java
License:Open Source License
private void parseFile(InputStream stream) throws Exception { Element messageElement = null; Element attributeElement = null; Element group = null;/*from w w w .j a v a 2 s. c o m*/ UcpMessage msg = null; UcpAttribute att = null; UcpAttribute attImbricate = null; UcpChoice attChoice = null; UcpGroup attGroup = null; Vector<UcpGroup> choiceList = null; Vector<UcpAttribute> imbricateAtt = null; List groupList = null; int i = 0; int j = 0; int msgNumber = 0; String value = null; SAXReader reader = new SAXReader(); Document document = reader.read(stream); //parsing des messages List listMessages = document.selectNodes("/dictionary/message"); for (i = 0; i < listMessages.size(); i++) { messageElement = (Element) listMessages.get(i); msg = new UcpMessage(); msg.setName(messageElement.attributeValue("name")); msg.setOperationType(messageElement.attributeValue("id")); value = messageElement.attributeValue("type"); if (value.equals("operation")) { msg.setMessageType("O"); } else if (value.equals("response")) { msg.setMessageType("R"); } for (Iterator it = messageElement.elementIterator(); it.hasNext();) { attributeElement = (Element) it.next(); value = attributeElement.getName(); if (value.equals("attribute")) { att = setAttribute(attributeElement); //check if attribute imbricate in attribute List listAtt = attributeElement.selectNodes( "//attribute[@name='" + attributeElement.attributeValue("name") + "']/attribute"); if (listAtt.size() > 0) { att.setValue(new Vector<UcpAttribute>()); for (j = 0; j < listAtt.size(); j++) { attImbricate = setAttribute((Element) listAtt.get(j)); ((Vector<UcpAttribute>) att.getValue()).add(attImbricate); } } msg.addAttribute(att); } else if (value.equals("choice")) { msgNumber = i + 1; groupList = attributeElement.selectNodes("/dictionary/message[" + msgNumber + "]/choice/group"); choiceList = new Vector<UcpGroup>(); attChoice = new UcpChoice(); //work because att is the last attribute set and is the att base on choice attChoice.setChoiceAttribute(att); //parse all group of the choice, could be only an attribute or a group of attribute for (j = 0; j < groupList.size(); j++) { group = (Element) groupList.get(j); //create an attribute for each group attGroup = new UcpGroup(); attGroup.setChoiceValue(group.attributeValue("value")); imbricateAtt = new Vector<UcpAttribute>(); //parse attribute present in the group for (Iterator iter = group.elementIterator(); iter.hasNext();) { imbricateAtt.add(setAttribute((Element) iter.next())); } attGroup.setValue(imbricateAtt); choiceList.add(attGroup); } attChoice.setValue(choiceList); msg.addAttribute(attChoice); } } if (msg.getMessageType().equals("O"))//operation = request { requestsList.put(msg.getName(), msg); //these two hashmap are used by the response or request messageOperationTypeToNameList.put(msg.getOperationType(), msg.getName()); messageNameToOperationTypeList.put(msg.getName(), msg.getOperationType()); } else if (msg.getMessageType().equals("R"))//response { if (msg.getAttribute("ACK") != null) { positivesResponsesList.put(msg.getName(), msg); } else if (msg.getAttribute("NACK") != null) { negativesResponsesList.put(msg.getName(), msg); } } } // //affichage des message // Collection<UcpMessage> collecMsg = requestsList.values(); // System.out.println("\r\nnb de message dans la collection de requetes: " + collecMsg.size()); // for(Iterator<UcpMessage> iter = collecMsg.iterator(); iter.hasNext();) // { // UcpMessage msgEle = (UcpMessage)iter.next(); // //affichage des attributs // System.out.println(msgEle.toString()); // } // // //affichage des message // collecMsg = positivesResponsesList.values(); // System.out.println("\r\nnb de message dans la collection de reponses positives: " + collecMsg.size()); // for(Iterator<UcpMessage> iter = collecMsg.iterator(); iter.hasNext();) // { // UcpMessage msgEle = (UcpMessage)iter.next(); // //affichage des attributs // System.out.println(msgEle.toString()); // } // // //affichage des message // collecMsg = negativesResponsesList.values(); // System.out.println("\r\nnb de message dans la collection de reponses negatives: " + collecMsg.size()); // for(Iterator<UcpMessage> iter = collecMsg.iterator(); iter.hasNext();) // { // UcpMessage msgEle = (UcpMessage)iter.next(); // //affichage des attributs // System.out.println(msgEle.toString()); // } }
From source file:com.erpak.jtrackplanner3d.xml.LibraryReader.java
License:Open Source License
/** * create a new LibraryReader object with the library file name * @param fileName Name of the library file *//*from w w w .ja v a 2 s.co m*/ public LibraryReader(File libraryFile) { TrackSystem trackSystem = null; TracksTreeCellRenderer renderer = new TracksTreeCellRenderer(); try { renderer.setStraigthTrackIcon(new ImageIcon(ResourcesManager.getResource("StraigthTrackIcon"))); renderer.setCurvedTrackIcon(new ImageIcon(ResourcesManager.getResource("CurvedTrackIcon"))); renderer.setStraightTurnoutTrackIcon( new ImageIcon(ResourcesManager.getResource("StraigthTurnoutTrackIcon"))); renderer.setCrossingTrackIcon(new ImageIcon(ResourcesManager.getResource("CrossingTrackIcon"))); } catch (Exception ex) { logger.error("Unable to load tree node icons"); logger.error(ex.toString()); } try { Element trackSystemInfoNode; Element element; Element subElement; Attribute attribute; Iterator iter; DefaultMutableTreeNode treeTop; DefaultMutableTreeNode treeCategory; DefaultMutableTreeNode treeElement; // Load the xml library file InputStream in = new FileInputStream(libraryFile); EntityResolver resolver = new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) { logger.debug("Public id : " + publicId); logger.debug("System Id : " + systemId); if (publicId.equals("-//TrackPlanner//DTD track_system V 1.0//EN")) { InputStream in = getClass().getResourceAsStream("ressources/track_system.dtd"); return new InputSource(in); } return null; } }; SAXReader reader = new SAXReader(); reader.setEntityResolver(resolver); // Read the xml library file Document document = reader.read(in); Element root = document.getRootElement(); logger.debug("Root name : " + root.getName()); // Get "track_system_info" node trackSystemInfoNode = root.element("track_system_infos"); // Get track_system_info_node attributes trackSystem = new TrackSystem(trackSystemInfoNode.attribute("name").getValue(), trackSystemInfoNode.attribute("version").getValue()); trackSystem.setScale(trackSystemInfoNode.attribute("scale").getValue()); trackSystem.setManufacturer(trackSystemInfoNode.attribute("manufacturer").getValue()); // Get the "track_system_caracteristics" node element = trackSystemInfoNode.element("track_system_caracteristics"); trackSystem.setBallastWidth(Float.parseFloat(element.attribute("ballast_width").getValue())); trackSystem.setTrackWidth(Float.parseFloat(element.attribute("railway_width").getValue())); // Get the "track_system_colors" node element = trackSystemInfoNode.element("track_system_colors"); for (iter = element.elementIterator(); iter.hasNext();) { subElement = (Element) iter.next(); trackSystem.addColor(subElement.attribute("name").getValue(), subElement.attribute("r").getValue(), subElement.attribute("g").getValue(), subElement.attribute("b").getValue()); } // Set the top node of tree with tracksystem treeTop = new DefaultMutableTreeNode(trackSystem.getName()); // iterate "straight_tracks" node element = root.element("straight_tracks"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (iter = element.elementIterator("straight_track"); iter.hasNext();) { subElement = (Element) iter.next(); logger.debug("Adding reference : " + subElement.attribute("reference").getValue()); treeElement = new DefaultMutableTreeNode(new StraightTrackSymbol(trackSystem, subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), Float.parseFloat(subElement.attribute("length").getValue()), subElement.attribute("color").getValue())); treeCategory.add(treeElement); } // iterate "curved_tracks" node element = root.element("curved_tracks"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (iter = element.elementIterator("curved_track"); iter.hasNext();) { subElement = (Element) iter.next(); logger.debug("Adding reference : " + subElement.attribute("reference").getValue()); treeElement = new DefaultMutableTreeNode(new CurvedTrackSymbol(trackSystem, subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), Float.parseFloat(subElement.attribute("radius").getValue()), Float.parseFloat(subElement.attribute("angle").getValue()), subElement.attribute("color").getValue())); treeCategory.add(treeElement); } // iterate "straight_turnouts" node element = root.element("straight_turnouts"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (iter = element.elementIterator("straight_turnout"); iter.hasNext();) { subElement = (Element) iter.next(); logger.debug("Adding reference : " + subElement.attribute("reference").getValue()); treeElement = new DefaultMutableTreeNode(new StraightTurnoutSymbol(trackSystem, subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), Float.parseFloat(subElement.attribute("length").getValue()), Float.parseFloat(subElement.attribute("radius").getValue()), Float.parseFloat(subElement.attribute("angle").getValue()), subElement.attribute("direction").getValue(), subElement.attribute("color").getValue())); treeCategory.add(treeElement); } // iterate through "curved_turnouts" node element = root.element("curved_turnouts"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (Iterator i = root.elementIterator("curved_turnouts"); i.hasNext();) { element = (Element) i.next(); logger.debug("Node : " + element.getName()); } // iterate through "three_way_turnouts" node element = root.element("three_way_turnouts"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (iter = element.elementIterator("symetric_three_way_turnout"); iter.hasNext();) { subElement = (Element) iter.next(); logger.debug("Adding reference : " + subElement.attribute("reference").getValue()); treeElement = new DefaultMutableTreeNode(new SymetricThreeWayTurnoutSymbol(trackSystem, subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), subElement.attribute("reference").getValue(), Float.parseFloat(subElement.attribute("length").getValue()), Float.parseFloat(subElement.attribute("radius").getValue()), Float.parseFloat(subElement.attribute("angle").getValue()), subElement.attribute("color").getValue())); treeCategory.add(treeElement); } // iterate through "crossings" node element = root.element("crossings"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (Iterator i = root.elementIterator("crossings"); i.hasNext();) { element = (Element) i.next(); logger.debug("Node : " + element.getName()); } // iterate through "double_slip_switchs" node element = root.element("double_slip_switchs"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (Iterator i = root.elementIterator("double_slip_switchs"); i.hasNext();) { element = (Element) i.next(); logger.debug("Node : " + element.getName()); } // iterate through "special_tracks" node element = root.element("special_tracks"); treeCategory = new DefaultMutableTreeNode(element.getName()); treeTop.add(treeCategory); logger.debug("Node : " + element.getName()); for (Iterator i = root.elementIterator("special_tracks"); i.hasNext();) { element = (Element) i.next(); logger.debug("Node : " + element.getName()); } // fill the tree tree = new JTree(treeTop); } catch (Exception ex) { logger.error("Unable to load track trackSystem library", ex); // Todo : Throws an exception and display an error box instaed of displaying atree with scrap data tree = new JTree(); } logger.debug("Parsing done for trackSystem : " + trackSystem); tree.setName("Track systems"); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setCellRenderer(renderer); }
From source file:com.example.sample.pMainActivity.java
License:Apache License
public void listNodes(Element node) { System.out.println("" + node.getName()); List<Attribute> list = node.attributes(); for (Attribute attr : list) { Log.d(TAG, "listNodes: " + attr.getText() + "-----" + attr.getName() + "---" + attr.getValue()); }//from ww w .j a v a 2 s .c o m if (!(node.getTextTrim().equals(""))) { Log.d(TAG, "getText: " + node.getText()); node.setText("getText: "); saveDocument(document); Log.d(TAG, "saveDocument: " + node.getText()); } Iterator<Element> it = node.elementIterator(); while (it.hasNext()) { Element e = it.next(); listNodes(e); } }
From source file:com.fivepebbles.Backup.java
License:MIT License
public void processBackup() { //Retrieve Bucket Names and related files/folders from XML saved locally Document myDocument = null;//from www .j a v a2 s . c o m try { URL myURL = new File("target", "s3files.xml").toURI().toURL(); SAXReader myReader = new SAXReader(); myDocument = myReader.read(myURL); } catch (MalformedURLException | DocumentException e) { //***TODO*** log Msg e.printStackTrace(); } Element root = myDocument.getRootElement(); for (Iterator<Element> i1 = root.elementIterator(); i1.hasNext();) { Element bucketelem = i1.next(); if (bucketelem.getName() == "bucket") { bucketnm = bucketelem.attributeValue("name"); for (Iterator<Element> i2 = bucketelem.elementIterator(); i2.hasNext();) { Element fileelem = i2.next(); if (fileelem.getName() == "file") { bfile = fileelem.getText(); //Get list of files (bfile could be a folder name) ProcessFiles p1 = new ProcessFiles(); filelist = p1.getFiles(bfile); //Append files to arraylist if (filelist != null) { totalfilelist.addAll(filelist); } } } //Make the data good for S3 //Replace "\" with "/" for Windows for (int j = 0; j < totalfilelist.size(); j++) { if (totalfilelist.get(j).contains("\\")) { newfilelist.add(totalfilelist.get(j).replace("\\", "/")); } else { newfilelist.add(totalfilelist.get(j)); } } //Remove Driveletter from files/object list if present (Windows) for (int k = 0; k < newfilelist.size(); k++) { if (newfilelist.get(k).contains("C:")) { newfilelist2.add(newfilelist.get(k).replace("C:", "")); } else { newfilelist2.add(newfilelist.get(k)); } } //Get S3 key list corresponding to the files //This is obtained by removing the "/" in index 0 from the file list since AWS key should not have a / at position 0 for (int m = 0; m < newfilelist2.size(); m++) { keylist.add(newfilelist2.get(m).substring(1)); } //Backup files in S3 (for this bucket) //Get AWS Credentials String[] awskeys = new S3Credentials().getCredentials(); //Set AWS credentials ProcessAWS pr1 = new ProcessAWS(awskeys[0], awskeys[1]); //Check if Bucket exists in S3 if (pr1.checkBucket(bucketnm)) { //Put Objects in S3 //keylist contains S3 keys and newfilelist2 contains the files for (int l = 0; l < newfilelist2.size(); l++) { boolean r1 = pr1.putAWSObject(keylist.get(l), new File(newfilelist2.get(l)), bucketnm); if (!r1) { //***TODO*** Log message } } } else { //Create Bucket in S3 boolean r2 = pr1.createBucket(bucketnm); if (r2) { //Put Objects in S3 //keylist contains S3 keys and newfilelist2 contains the files for (int m = 0; m < newfilelist2.size(); m++) { boolean r3 = pr1.putAWSObject(keylist.get(m), new File(newfilelist2.get(m)), bucketnm); if (!r3) { //***TODO*** Log message } } } else { //***TODO*** Log message } } } //Clear arrays for the next bucket totalfilelist.clear(); newfilelist.clear(); newfilelist2.clear(); keylist.clear(); } }
From source file:com.gi.desktop.maptool.dialog.MapServiceConfDialog.java
License:Open Source License
@SuppressWarnings("unchecked") private void loadAgsSchema() { JFileChooser dialog = getJFileChooserAgsSchema(); int val = dialog.showOpenDialog(this); if (val == JFileChooser.APPROVE_OPTION) { File agsSchema = dialog.getSelectedFile(); try {/*from ww w . ja v a 2 s . c o m*/ FileInputStream in = new FileInputStream(agsSchema); SAXReader saxReader = new SAXReader(); Document document = saxReader.read(in); Element root = document.getRootElement(); Element eTileCacheInfo = root.element("TileCacheInfo"); Element eTileOrigin = eTileCacheInfo.element("TileOrigin"); this.jTextFieldOriginX.setText(eTileOrigin.elementText("X")); this.jTextFieldOriginY.setText(eTileOrigin.elementText("Y")); this.jTextFieldWidth.setText(eTileCacheInfo.elementText("TileCols")); this.jTextFieldHeight.setText(eTileCacheInfo.elementText("TileRows")); jListLevelsModel.removeAllElements(); Element eLODInfos = eTileCacheInfo.element("LODInfos"); for (Iterator iLODInfos = eLODInfos.elementIterator(); iLODInfos.hasNext();) { Element eLODInfo = (Element) iLODInfos.next(); TileLodInfo tileLodInfo = new TileLodInfo(); tileLodInfo.setLevel(Integer.valueOf(eLODInfo.elementText("LevelID"))); tileLodInfo.setScale(Double.valueOf(eLODInfo.elementText("Scale"))); tileLodInfo.setResolution(Double.valueOf(eLODInfo.elementText("Resolution"))); LodItem item = new LodItem(); item.setTileLodInfo(tileLodInfo); jListLevelsModel.addElement(item); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Load Error!"); } } }
From source file:com.glaf.activiti.extension.xml.ExtensionReader.java
License:Apache License
public List<ExtensionEntity> readActions(java.io.InputStream inputStream) { List<ExtensionEntity> extensions = new java.util.ArrayList<ExtensionEntity>(); SAXReader xmlReader = new SAXReader(); try {/*from w ww . j ava 2s .co m*/ Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); String x_type = root.attributeValue("type"); List<?> actions = root.elements("action"); Iterator<?> iter = actions.iterator(); while (iter.hasNext()) { Element element = (Element) iter.next(); ExtensionEntity extension = new ExtensionEntity(); extension.setProcessName(element.attributeValue("processName")); extension.setTaskName(element.attributeValue("taskName")); extension.setName(element.attributeValue("name")); extension.setType(x_type); extension.setDescription(element.elementTextTrim("description")); Iterator<?> it99 = element.elementIterator(); while (it99.hasNext()) { Element elem = (Element) it99.next(); String propertyName = elem.getName(); String propertyValue = elem.getTextTrim(); if (StringUtils.isNotEmpty(propertyValue)) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName(propertyName.trim()); extensionField.setValue(propertyValue.trim()); extension.addField(extensionField); } } if (element.elementText("sql") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("sql"); extensionField.setValue(element.elementTextTrim("sql")); extension.addField(extensionField); } if (element.elementText("handlers") != null) { ExtensionFieldEntity extensionField = new ExtensionFieldEntity(); extensionField.setName("handlers"); extensionField.setValue(element.elementTextTrim("handlers")); extension.addField(extensionField); } Element parametersE = element.element("parameters"); if (parametersE != null) { List<?> parameters = parametersE.elements("parameter"); Iterator<?> it = parameters.iterator(); while (it.hasNext()) { Element elem = (Element) it.next(); String propertyName = elem.attributeValue("name"); String type = elem.attributeValue("type"); String propertyValue = null; if (elem.attribute("value") != null) { propertyValue = elem.attributeValue("value"); } else { propertyValue = elem.getTextTrim(); } if (StringUtils.isNotEmpty(propertyName) && StringUtils.isNotEmpty(propertyValue)) { ExtensionParamEntity extensionParam = new ExtensionParamEntity(); extensionParam.setName(propertyName.trim()); extensionParam.setValue(propertyValue.trim()); extensionParam.setType(type); extension.addParam(extensionParam); } } } extensions.add(extension); } } catch (Exception ex) { throw new RuntimeException(ex); } return extensions; }