List of usage examples for org.dom4j Element attributeValue
String attributeValue(QName qName);
From source file:com.amalto.workbench.utils.LocalTreeObjectRepository.java
License:Open Source License
private List<String> parseXpathForElement(Element elem, Element subRoot) { List<String> list = new ArrayList<String>(); while (elem != subRoot) { if (elem.attributeValue("name") != null) { list.add(elem.attributeValue("name"));//$NON-NLS-1$ } else {//from w w w . jav a 2 s . co m list.add(elem.getName()); } elem = elem.getParent(); } Collections.reverse(list); return list; }
From source file:com.android.uiautomator.UiAutomatorModel.java
License:Apache License
public UiAutomatorModel(File xmlDumpFile) { mSearchKeySet.add("text"); mSearchKeySet.add("content-desc"); Const.document = null;//from w w w .j a v a 2s . c o m UiHierarchyXmlLoader loader = new UiHierarchyXmlLoader(); // System.out.println(xmlDumpFile.getAbsolutePath()); Const.document = loader.getDocument(xmlDumpFile.getAbsolutePath()); List<Element> list = Const.document.selectNodes("//node"); for (int i = 0; i < list.size(); i++) { Element e = list.get(i); // System.out.println(e.attributeValue("class")); e.setName(e.attributeValue("class")); } BasicTreeNode rootNode = loader.parseXml(xmlDumpFile.getAbsolutePath()); if (rootNode == null) { System.err.println("null rootnode after parsing."); throw new IllegalArgumentException("Invalid ui automator hierarchy file."); } mNafNodes = loader.getNafNodes(); if (mRootNode != null) { mRootNode.clearAllChildren(); } mRootNode = rootNode; mExploreMode = true; mNodelist = loader.getAllNodes(); }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
public static Config loadXml(InputStream input) { Config config = new Config(); if (input == null) { return null; }/*from w w w . ja va 2s .c o m*/ Document document = null; try { document = XMLUtil.loadXmlFile(input); if (input != null) { input.close(); } } catch (DocumentException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } Element rootElement = document.getRootElement(); String id = rootElement.attributeValue("id"); String version = rootElement.attributeValue("version"); config.setId(id); config.setVersion(version); parseGenral(rootElement, config); List<Element> preferenceElementList = rootElement.elements("preference"); List<Preference> preferences = parsePreference(preferenceElementList); config.getPreferences().addAll(preferences); List<Element> accessElementList = rootElement.elements("access"); List<Access> accesses = parseAccess(accessElementList); config.getAccesses().addAll(accesses); List<Element> permissionElementList = rootElement.elements("permission"); List<Permission> permissions = parsePermission(permissionElementList); config.getPermissions().addAll(permissions); List<Element> featureElementList = rootElement.elements("feature"); List<Feature> features = parseFeature(featureElementList); config.getFeatures().addAll(features); return config; }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static void parseGenral(Element rootElement, Config config) { Element nameElement = rootElement.element("name"); String name = nameElement.getText(); config.setName(name);/*w ww .j a v a2 s . c om*/ Element descriptionElement = rootElement.element("description"); String description = descriptionElement.getText(); config.setDesc(description); Element authorElement = rootElement.element("author"); String authorName = authorElement.getText(); String authorEmail = authorElement.attributeValue("email"); String authorHref = authorElement.attributeValue("href"); config.setAuthorHref(authorHref); config.setAuthorEmail(authorEmail); config.setAuthorName(authorName); Element contentElement = rootElement.element("content"); String content = contentElement.attributeValue("src"); config.setContentSrc(content); }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static List<Preference> parsePreference(List<Element> preferenceElementList) { List<Preference> preferences = new ArrayList<Preference>(); for (Element pref : preferenceElementList) { Preference preference = new Preference(); String name = pref.attributeValue("name"); String value = pref.attributeValue("value"); preference.setName(name);//w w w .j a v a 2 s. com preference.setValue(value); preferences.add(preference); } return preferences; }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static List<Access> parseAccess(List<Element> accessElementList) { List<Access> accesses = new ArrayList<Access>(); for (Element acs : accessElementList) { Access access = new Access(); String origin = acs.attributeValue("origin"); access.setOrigin(origin);//from ww w .ja va 2 s . c o m accesses.add(access); } return accesses; }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static List<Permission> parsePermission(List<Element> permissionElementList) { List<Permission> permissions = new ArrayList<Permission>(); for (Element pref : permissionElementList) { Permission permission = new Permission(); String name = pref.attributeValue("name"); permission.setName(name);/* www . j ava 2 s . c o m*/ permissions.add(permission); } return permissions; }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static List<Feature> parseFeature(List<Element> featureElementList) { List<Feature> features = new ArrayList<Feature>(); for (Element pref : featureElementList) { Feature feature = new Feature(); String name = pref.attributeValue("name"); feature.setName(name);// ww w. j ava 2 s . c o m features.add(feature); List<Element> paramElementList = pref.elements("param"); parseParam(paramElementList, feature); } return features; }
From source file:com.apicloud.commons.model.Config.java
License:Open Source License
private static void parseParam(List<Element> paramElementList, Feature feature) { List<Param> params = new ArrayList<Param>(); for (Element param : paramElementList) { Param pa = new Param(); String name = param.attributeValue("name"); String value = param.attributeValue("value"); pa.setName(name);/* ww w . java2s . c o m*/ pa.setValue(value); params.add(pa); } feature.getParams().addAll(params); }
From source file:com.apicloud.commons.model.Feature.java
License:Open Source License
private static List<Feature> parseFeature(List<Element> featureElementList) { List<Feature> features = new ArrayList<Feature>(); for (Element pref : featureElementList) { Feature feature = new Feature(); String name = pref.attributeValue("name"); String desc = pref.attributeValue("desc"); String isAndroid = pref.attributeValue("isAndroid"); String isIos = pref.attributeValue("isIOS"); String type = pref.attributeValue("type"); feature.setName(name);/* ww w. j a va2 s. c om*/ feature.setDesc(desc); feature.setAndroid(Boolean.parseBoolean(isAndroid)); feature.setIos(Boolean.parseBoolean(isIos)); feature.setType(type); features.add(feature); } return features; }