List of usage examples for org.w3c.dom Element getTagName
public String getTagName();
From source file:marytts.tools.voiceimport.HTKLabeler.java
private String collectTranscriptionAndWord(NodeList tokens) { // TODO: make delims argument // String Tokenizer devides transcriptions into syllables // syllable delimiters and stress symbols are retained String delims = "',-"; // String storing the original transcription begins with a pause String orig = " pau "; String word, HTKWORD;/* www . j a va 2s. co m*/ boolean first_word_phone = true; // get original phone String for (int tNr = 0; tNr < tokens.getLength(); tNr++) { Element token = (Element) tokens.item(tNr); // only look at it if there is a sampa to change if (token.hasAttribute("ph")) { word = token.getTextContent().trim(); HTKWORD = word.toUpperCase(); first_word_phone = true; String sampa = token.getAttribute("ph"); List<String> sylsAndDelims = new ArrayList<String>(); StringTokenizer sTok = new StringTokenizer(sampa, delims, true); while (sTok.hasMoreElements()) { String currTok = sTok.nextToken(); if (delims.indexOf(currTok) == -1) { // current Token is no delimiter for (Allophone ph : allophoneSet.splitIntoAllophones(currTok)) { // orig += ph.name() + " "; if (ph.name().trim().equals("_")) continue; orig += replaceTrickyPhones(ph.name().trim()); if (first_word_phone) { orig += "-" + HTKWORD + " "; first_word_phone = false; } else orig += " "; } // ... for each phone } // ... if no delimiter } // ... while there are more tokens } // TODO: simplify if (token.getTagName().equals("t")) { // if the following element is no boundary, insert a non-pause delimiter if (tNr == tokens.getLength() - 1 || !((Element) tokens.item(tNr + 1)).getTagName().equals("boundary")) { orig += "vssil "; // word boundary } } else if (token.getTagName().equals("boundary")) { orig += "ssil "; // phrase boundary } else { // should be "t" or "boundary" elements assert (false); } } // ... for each t-Element orig += "pau"; return orig; }
From source file:kml.feature.Placemark.java
public void setPlacemarkElement(Element element) { try {//from w w w . ja v a2s . co m this.setParent(element.getParentNode().getNodeName()); } catch (Exception ex) { this.setParent("UNKNOWN"); } // id attribute if (element.getAttribute("id").length() > 0) { String id = element.getAttribute("id"); this.setId(id); } // id // name element if (element.getElementsByTagNameNS("*", "name").getLength() > 0) { String name = element.getElementsByTagNameNS("*", "name").item(0).getTextContent(); this.setName(name); } // name if (element.getElementsByTagNameNS("*", "description").getLength() > 0) { String description = element.getElementsByTagNameNS("*", "description").item(0).getTextContent(); this.setDescription(description); } // description if (element.getElementsByTagNameNS("*", "Style").getLength() > 0) { this.style.setStyleElement(element); } // Style if (element.getElementsByTagNameNS("*", "StyleMap").getLength() > 0) { this.styleMap.setElement(element); } // StyleMap int suKnt = element.getElementsByTagNameNS("*", "styleUrl").getLength(); if (element.getElementsByTagNameNS("*", "styleUrl").getLength() > 0) { //String styleUrl = element.getElementsByTagNameNS("*","styleUrl").item(0).getTextContent(); //pm.append("styleUrl: ").append(styleUrl).append("\n"); for (int knt = 0; knt < suKnt; knt++) { String styleUrl = element.getElementsByTagNameNS("*", "styleUrl").item(knt).getTextContent(); this.setStyleUrl(styleUrl); } //System.out.println("element styleUrl : " + element.getElementsByTagNameNS("*","styleUrl").item(0).getTextContent()); } // styleUrl // IGNORE MultiGeometry because the child elements are geometris that are parsed anyway // if (element.getElementsByTagNameNS("*","MultiGeometry").getLength() > 0) { // //TODO // }// MultiGeometry int polyKnt = element.getElementsByTagNameNS("*", "Polygon").getLength(); if (polyKnt > 0) { NodeList polyNodes = element.getElementsByTagNameNS("*", "Polygon"); //NodeList if (polyNodes != null) { for (int i = 0; i < polyNodes.getLength(); i++) { if (polyNodes.item(i).getNodeType() == Node.ELEMENT_NODE) { Element polyElement = (Element) polyNodes.item(i); Polygon polygon = new Polygon(polyElement); //System.out.println("Adding Polygon[" + i + "] id:" + polygon.getId()); this.addGeometry(polygon.getId(), polygon); } } } // for (int knt = 0; knt < polyKnt; knt++) { // Element polyElement = (Element) element.getElementsByTagNameNS("*","Polygon").item(knt); // Polygon polygon = new Polygon(polyElement); // System.out.println("Adding Polygon[" + knt + "] id:" + polygon.getId() + " " + polygon.toString()); // this.addGeometry(polygon.getId(), polygon); // // } } // Polygon ==================================================== //System.out.println(" Placemark.setPlacemarkElement element.getTagName() " + element.getTagName()); if (element.getTagName().equals("Polygon")) { Polygon polygon = new Polygon(element); System.out.println("Adding Polygon[ORPHAN] id:" + polygon.getId()); this.addGeometry(polygon.getId(), polygon); } // Polygon Orphan ==================================================== int pointKnt = element.getElementsByTagNameNS("*", "Point").getLength(); if (pointKnt > 0) { for (int knt = 0; knt < pointKnt; knt++) { Point point = new Point(element); //System.out.println("Adding LineString[" + knt + "] id:" + lineString.getId() + "\n" + lineString.getCoordinates()); this.addGeometry(point.getId(), point); } } // Point ====================================================== if (element.getTagName().equals("Point")) { Point point = new Point(element); System.out.println("Adding Point[ORPHAN] id:" + point.getId()); this.addGeometry(point.getId(), point); } // Point Orphan ==================================================== int lsKnt = element.getElementsByTagNameNS("*", "LineString").getLength(); if (lsKnt > 0) { for (int knt = 0; knt < lsKnt; knt++) { LineString lineString = new LineString(element); //System.out.println("Adding LineString[" + knt + "] id:" + lineString.getId() + "\n" + lineString.getCoordinates()); this.addGeometry(lineString.getId(), lineString); } } // LineString ================================================= // if (lsKnt > 0) { // NodeList lsNodes = element.getElementsByTagNameNS("*","LineString"); //NodeList // if (lsNodes != null) { // for (int knt = 0; knt < lsKnt; knt++) { // if (lsNodes.item(knt).getNodeType() == Node.ELEMENT_NODE) { // LineString lineString = new LineString((Element) lsNodes.item(knt)); // //System.out.println("Adding LineString[" + knt + "] id:" + lineString.getId() + "\n" + lineString.getCoordinates()); // this.addGeometry(lineString.getId(), lineString); // } // } // } // } if (element.getTagName().equals("LineString")) { LineString lineString = new LineString(element); System.out.println("Adding LineString[ORPHAN] id:" + lineString.getId()); this.addGeometry(lineString.getId(), lineString); } // LineString Orphan ==================================================== // Is this necessary since it is part of a Polygon? // int lrKnt = element.getElementsByTagNameNS("*","LinearRing").getLength(); // if (element.getElementsByTagNameNS("*","LinearRing").getLength() > 0) { // for (int knt = 0; knt < lrKnt; knt++) { // System.out.println("Adding LinearRing[" + knt + "] "); // LinearRing linearRing = new LinearRing(element); // this.addGeometry(linearRing.getId(), linearRing); // } // }// LinearRing ================================================= }
From source file:com.buaa.cfs.conf.Configuration.java
private Resource loadResource(Properties properties, Resource wrapper, boolean quiet) { String name = UNKNOWN_RESOURCE; try {/*from w ww . ja va2 s.com*/ Object resource = wrapper.getResource(); name = wrapper.getName(); DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); //ignore all comments inside the xml file docBuilderFactory.setIgnoringComments(true); //allow includes in the xml file docBuilderFactory.setNamespaceAware(true); try { docBuilderFactory.setXIncludeAware(true); } catch (UnsupportedOperationException e) { LOG.error("Failed to set setXIncludeAware(true) for parser " + docBuilderFactory + ":" + e, e); } DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); Document doc = null; Element root = null; boolean returnCachedProperties = false; if (resource instanceof URL) { // an URL resource doc = parse(builder, (URL) resource); } else if (resource instanceof String) { // a CLASSPATH resource URL url = getResource((String) resource); doc = parse(builder, url); } else if (resource instanceof Path) { // a file resource // Can't use FileSystem API or we get an infinite loop // since FileSystem uses Configuration API. Use java.io.File instead. File file = new File(((Path) resource).toUri().getPath()).getAbsoluteFile(); if (file.exists()) { if (!quiet) { LOG.debug("parsing File " + file); } doc = parse(builder, new BufferedInputStream(new FileInputStream(file)), ((Path) resource).toString()); } } else if (resource instanceof InputStream) { doc = parse(builder, (InputStream) resource, null); returnCachedProperties = true; } else if (resource instanceof Properties) { overlay(properties, (Properties) resource); } else if (resource instanceof Element) { root = (Element) resource; } if (root == null) { if (doc == null) { if (quiet) { return null; } throw new RuntimeException(resource + " not found"); } root = doc.getDocumentElement(); } Properties toAddTo = properties; if (returnCachedProperties) { toAddTo = new Properties(); } if (!"configuration".equals(root.getTagName())) LOG.fatal("bad conf file: top-level element not <configuration>"); NodeList props = root.getChildNodes(); DeprecationContext deprecations = deprecationContext.get(); for (int i = 0; i < props.getLength(); i++) { Node propNode = props.item(i); if (!(propNode instanceof Element)) continue; Element prop = (Element) propNode; if ("configuration".equals(prop.getTagName())) { loadResource(toAddTo, new Resource(prop, name), quiet); continue; } if (!"property".equals(prop.getTagName())) LOG.warn("bad conf file: element not <property>"); NodeList fields = prop.getChildNodes(); String attr = null; String value = null; boolean finalParameter = false; LinkedList<String> source = new LinkedList<String>(); for (int j = 0; j < fields.getLength(); j++) { Node fieldNode = fields.item(j); if (!(fieldNode instanceof Element)) continue; Element field = (Element) fieldNode; if ("name".equals(field.getTagName()) && field.hasChildNodes()) attr = StringInterner.weakIntern(((Text) field.getFirstChild()).getData().trim()); if ("value".equals(field.getTagName()) && field.hasChildNodes()) value = StringInterner.weakIntern(((Text) field.getFirstChild()).getData()); if ("final".equals(field.getTagName()) && field.hasChildNodes()) finalParameter = "true".equals(((Text) field.getFirstChild()).getData()); if ("source".equals(field.getTagName()) && field.hasChildNodes()) source.add(StringInterner.weakIntern(((Text) field.getFirstChild()).getData())); } source.add(name); // Ignore this parameter if it has already been marked as 'final' if (attr != null) { if (deprecations.getDeprecatedKeyMap().containsKey(attr)) { DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(attr); keyInfo.clearAccessed(); for (String key : keyInfo.newKeys) { // update new keys with deprecated key's value loadProperty(toAddTo, name, key, value, finalParameter, source.toArray(new String[source.size()])); } } else { loadProperty(toAddTo, name, attr, value, finalParameter, source.toArray(new String[source.size()])); } } } if (returnCachedProperties) { overlay(properties, toAddTo); return new Resource(toAddTo, name); } return null; } catch (IOException e) { LOG.fatal("error parsing conf " + name, e); throw new RuntimeException(e); } catch (DOMException e) { LOG.fatal("error parsing conf " + name, e); throw new RuntimeException(e); } catch (SAXException e) { LOG.fatal("error parsing conf " + name, e); throw new RuntimeException(e); } catch (ParserConfigurationException e) { LOG.fatal("error parsing conf " + name, e); throw new RuntimeException(e); } }
From source file:marytts.tools.voiceimport.HTKLabeler.java
/** * /*from www. j a va 2s . c om*/ * This computes a string of words out of an prompt allophones mary xml: * - standard phones are taken from "ph" attribute * @param tokens * @return */ private String collectWordTranscription(NodeList tokens) { // TODO: make delims argument // String Tokenizer devides transcriptions into syllables // syllable delimiters and stress symbols are retained String delims = "',-"; // String storing the original transcription begins with a pause String orig = " pau "; String HTKWORD_xml_transcription; String mary_transcription; String HTKWORD, word; // get original phone String for (int tNr = 0; tNr < tokens.getLength(); tNr++) { Element token = (Element) tokens.item(tNr); // only look at it if there is a sampa to change if (token.hasAttribute("ph")) { HTKWORD_xml_transcription = ""; mary_transcription = ""; String sampa = token.getAttribute("ph"); mary_transcription = sampa.trim().replace(" ", ""); List<String> sylsAndDelims = new ArrayList<String>(); StringTokenizer sTok = new StringTokenizer(sampa, delims, true); while (sTok.hasMoreElements()) { String currTok = sTok.nextToken(); if (delims.indexOf(currTok) == -1) { // current Token is no delimiter for (Allophone ph : allophoneSet.splitIntoAllophones(currTok)) { // orig += ph.name() + " "; if (ph.name().trim().equals("_")) continue; HTKWORD_xml_transcription += replaceTrickyPhones(ph.name().trim()) + " "; //globalwordlexicon += HTKWORD + " " + HTKWORD_xml_transcription; } // ... for each phone } // ... if no delimiter } // ... while there are more tokens word = token.getTextContent().trim(); HTKWORD = word.toUpperCase(); HTKWORD_xml_transcription = HTKWORD_xml_transcription.trim(); if ((token.hasAttribute("g2p_method") && token.getAttribute("g2p_method").equals("privatedict")) // this is for rawxml entry with token with ph attribute || !token.hasAttribute("g2p_method")) { HTKWORD = HTKWORD + "_" + HTKWORD_xml_transcription.replaceAll(" ", ""); //System.out.println("HTKWORD private lexicon or rawxml ph: " + HTKWORD); } // dictionary //System.out.println("HTKWORD: " + HTKWORD + " HTKWORD_xml_transcription: " + HTKWORD_xml_transcription); HTKdictionary.add(HTKWORD + " " + HTKWORD_xml_transcription); Totaldictionary .add(HTKWORD + " " + HTKWORD_xml_transcription.replace(" ", "") + " " + mary_transcription); String[] entries; entries = lexicon.lookup(word); //insert here all the different possible transcriptions for (int i = 0; i < entries.length; i++) { String HTKTranscription = entries[i]; mary_transcription = HTKTranscription.replace(" ", ""); HTKTranscription = HTKTranscription.replace("' ", ""); HTKTranscription = HTKTranscription.replace("- ", ""); //TODO: replaceTrickyPhones HTKTranscription HTKdictionary.add(HTKWORD + " " + HTKTranscription); Totaldictionary .add(HTKWORD + " " + HTKTranscription.replace(" ", "") + " " + mary_transcription); } orig += HTKWORD + " "; } // TODO: simplify if (token.getTagName().equals("t")) { // if the following element is no boundary, insert a non-pause delimiter if (tNr == tokens.getLength() - 1 || !((Element) tokens.item(tNr + 1)).getTagName().equals("boundary")) { orig += "vssil "; // word boundary } } else if (token.getTagName().equals("boundary")) { orig += "ssil "; // phrase boundary } else { // should be "t" or "boundary" elements assert (false); } } // ... for each t-Element orig += "pau"; return orig; }
From source file:com.android.tools.lint.checks.AndroidAutoDetector.java
@Override public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String tagName = element.getTagName(); if (NODE_METADATA.equals(tagName) && !mDoAutomotiveAppCheck) { checkAutoMetadataTag(element);//from ww w .j a va 2s . c o m } else if (TAG_AUTOMOTIVE_APP.equals(tagName)) { checkAutomotiveAppElement(context, element); } else if (NODE_APPLICATION.equals(tagName)) { // Disable reporting the error if the Issue was suppressed at // the application level. if (context.getMainProject() == context.getProject() && !context.getProject().isLibrary()) { mMainApplicationHandle = context.createLocationHandle(element); mMainApplicationHandle.setClientData(element); } } else if (TAG_SERVICE.equals(tagName)) { checkServiceForBrowserServiceIntentFilter(element); } else if (TAG_INTENT_FILTER.equals(tagName)) { checkForMediaSearchIntentFilter(element); } }
From source file:com.android.tools.lint.checks.AndroidAutoDetector.java
private void checkAutomotiveAppElement(XmlContext context, Element element) { // Indicates whether the current file matches the resource that was registered // in AndroidManifest.xml. boolean isMetadataResource = mAutomotiveResourceFileName != null && mAutomotiveResourceFileName.equals(context.file.getName()); for (Element child : LintUtils.getChildren(element)) { if (TAG_USES.equals(child.getTagName())) { String attrValue = child.getAttribute(ATTR_NAME); if (VAL_NAME_MEDIA.equals(attrValue)) { mIsAutomotiveMediaApp |= isMetadataResource; } else if (!VAL_NAME_NOTIFICATION.equals(attrValue) && context.isEnabled(INVALID_USES_TAG_ISSUE)) { // Error invalid value for attribute. Attr node = child.getAttributeNode(ATTR_NAME); if (node == null) { // no name specified continue; }/* www .ja v a 2 s . co m*/ context.report(INVALID_USES_TAG_ISSUE, node, context.getLocation(node), "Expecting one of `" + VAL_NAME_MEDIA + "` or `" + VAL_NAME_NOTIFICATION + "` for the name " + "attribute in " + TAG_USES + " tag."); } } } // Report any errors that we have collected that can be shown to the user // once we determine that this is an Automotive Media App. if (mIsAutomotiveMediaApp && !context.getProject().isLibrary() && mMainApplicationHandle != null && mDoAutomotiveAppCheck) { Element node = (Element) mMainApplicationHandle.getClientData(); if (!mMediaIntentFilterFound && context.isEnabled(MISSING_MEDIA_BROWSER_SERVICE_ACTION_ISSUE)) { context.report(MISSING_MEDIA_BROWSER_SERVICE_ACTION_ISSUE, node, mMainApplicationHandle.resolve(), "Missing `intent-filter` for action " + "`android.media.browse.MediaBrowserService` that is required for " + "android auto support"); } if (!mMediaSearchIntentFilterFound && context.isEnabled(MISSING_INTENT_FILTER_FOR_MEDIA_SEARCH)) { context.report(MISSING_INTENT_FILTER_FOR_MEDIA_SEARCH, node, mMainApplicationHandle.resolve(), "Missing `intent-filter` for action " + "`android.media.action.MEDIA_PLAY_FROM_SEARCH`."); } } }
From source file:com.android.tools.lint.checks.AndroidAutoDetector.java
private void checkServiceForBrowserServiceIntentFilter(Element element) { if (TAG_SERVICE.equals(element.getTagName()) && !mMediaIntentFilterFound) { for (Element child : LintUtils.getChildren(element)) { String tagName = child.getTagName(); if (TAG_INTENT_FILTER.equals(tagName)) { for (Element filterChild : LintUtils.getChildren(child)) { if (NODE_ACTION.equals(filterChild.getTagName())) { String actionValue = filterChild.getAttributeNS(ANDROID_URI, ATTR_NAME); if (ACTION_MEDIA_BROWSER_SERVICE.equals(actionValue)) { mMediaIntentFilterFound = true; return; }/*from w ww . j av a2s . c o m*/ } } } } } }
From source file:com.android.tools.lint.checks.AndroidAutoDetector.java
private void checkForMediaSearchIntentFilter(Element element) { if (!mMediaSearchIntentFilterFound) { for (Element filterChild : LintUtils.getChildren(element)) { if (NODE_ACTION.equals(filterChild.getTagName())) { String actionValue = filterChild.getAttributeNS(ANDROID_URI, ATTR_NAME); if (ACTION_MEDIA_PLAY_FROM_SEARCH.equals(actionValue)) { mMediaSearchIntentFilterFound = true; break; }//from w ww .j a va 2 s . c om } } } }
From source file:com.codename1.android.AndroidLayoutImporter.java
private List<Element> getSelectorElementsForDrawable(String resourceName) throws SAXException, IOException { File drawable = findDrawableResource(resourceName); if (drawable != null && drawable.getName().endsWith(".xml")) { try {/* w w w.j a va 2 s . c o m*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document includedDOM = builder.parse(drawable); Element root = includedDOM.getDocumentElement(); if (root.getTagName().equals("selector")) { NodeList items = root.getElementsByTagName("item"); int len = items.getLength(); List<Element> out = new ArrayList<Element>(); for (int i = 0; i < len; i++) { out.add((Element) items.item(i)); } return out; } } catch (ParserConfigurationException ex) { Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex); } } else if (drawable != null && (drawable.getName().endsWith(".png") || drawable.getName().endsWith(".jpg"))) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document includedDOM = builder.newDocument(); Element root = includedDOM.createElement("selector"); Element item = includedDOM.createElement("item"); item.setAttributeNS(NS_ANDROID, "drawable", resourceName); root.appendChild(item); includedDOM.appendChild(root); List<Element> out = new ArrayList<Element>(); out.add(item); return out; } catch (ParserConfigurationException ex) { Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex); } } return null; }
From source file:com.codename1.android.AndroidLayoutImporter.java
protected void convertElement(Element inputSrcElement, Element out) throws UnsupportedElementException { String id = inputSrcElement.getAttributeNS(NS_ANDROID, "id"); if (id != null) { id = id.substring(id.indexOf("/") + 1); out.setAttribute("name", id.replaceAll("[^a-zA-Z0-9]", "")); }//from w w w. j a v a2 s . c om //out.setAttribute("uiid", "android."+inputSrcElement.getTagName()); out.setAttribute("type", "Container"); out.setAttribute("layout", "FlowLayout"); Node inputParentNode = inputSrcElement.getParentNode(); if (inputParentNode != null && inputParentNode instanceof Element) { Element inputParent = (Element) inputParentNode; if ("FrameLayout".equals(inputParent.getTagName())) { out.setAttribute("layout", "BorderLayout"); String gravity = inputSrcElement.getAttributeNS(NS_ANDROID, "layout_gravity"); String layoutConstraint = "CENTER"; switch (gravity) { case "top": layoutConstraint = "NORTH"; break; case "left": layoutConstraint = "WEST"; break; case "right": layoutConstraint = "EAST"; break; case "bottom": layoutConstraint = "SOUTH"; break; case "fill_vertical": case "center_vertical": case "center_horizontal": case "fill_horizontal": case "center": case "fill": layoutConstraint = "CENTER"; break; default: layoutConstraint = "CENTER"; } Element layoutConstraintEl = out.getOwnerDocument().createElement("layoutConstraint"); layoutConstraintEl.setAttribute("value", layoutConstraint); out.appendChild(layoutConstraintEl); } } switch (inputSrcElement.getTagName()) { case "LinearLayout": convertLinearLayout(inputSrcElement, out); break; case "android.support.v7.widget.RecyclerView": convertRecyclerView(inputSrcElement, out); break; case "FrameLayout": convertFrameLayout(inputSrcElement, out); break; case "android.support.design.widget.CoordinatorLayout": convertCoordinatorLayout(inputSrcElement, out); break; case "android.support.design.widget.CollapsingToolbarLayout": convertCollapsingToolbarLayout(inputSrcElement, out); break; case "android.support.design.widget.AppBarLayout": convertAppBarLayout(inputSrcElement, out); break; case "android.support.v7.widget.Toolbar": convertToolbar(inputSrcElement, out); break; case "android.support.design.widget.FloatingActionButton": convertFloatingActionButton(inputSrcElement, out); break; case "include": { try { convertInclude(inputSrcElement, out); } catch (IOException ex) { Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex); } catch (SAXException ex) { Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex); } } break; case "android.support.v4.widget.NestedScrollView": convertNestedScrollView(inputSrcElement, out); break; case "ListView": convertListView(inputSrcElement, out); break; case "ProgressBar": convertProgressBar(inputSrcElement, out); break; case "TextView": convertTextView(inputSrcElement, out); break; case "Button": convertButton(inputSrcElement, out); break; case "ScrollView": convertScrollView(inputSrcElement, out); break; case "EditText": convertEditText(inputSrcElement, out); break; case "CheckBox": convertCheckBox(inputSrcElement, out); break; case "View": convertView(inputSrcElement, out); break; case "merge": convertMerge(inputSrcElement, out); break; case "RadioGroup": convertRadioGroup(inputSrcElement, out); break; case "RadioButton": convertRadioButton(inputSrcElement, out); break; case "Spinner": convertSpinner(inputSrcElement, out); break; case "RelativeLayout": convertRelativeLayout(inputSrcElement, out); break; case "ImageButton": convertImageButton(inputSrcElement, out); break; case "ImageView": convertImageView(inputSrcElement, out); break; case "SeekBar": convertSeekBar(inputSrcElement, out); break; case "QuickContactBadge": convertQuickContactBadge(inputSrcElement, out); break; case "ViewAnimator": convertViewAnimator(inputSrcElement, out); break; case "ViewStub": convertViewStub(inputSrcElement, out); break; case "Space": convertSpace(inputSrcElement, out); break; default: if (suppressUnsupportedElementExceptions) { this.convertOther(inputSrcElement, out); } else { throw new UnsupportedElementException(inputSrcElement); } } convertChildren(inputSrcElement, out); if (out.hasAttribute("layout") && "BorderLayout".equals(out.getAttribute("layout"))) { // Make sure that border layout children have appropriate constraint Set<String> allowable = new HashSet<String>( Arrays.asList(new String[] { "NORTH", "SOUTH", "EAST", "WEST", "CENTER" })); Map<String, Element> childMap = new HashMap<String, Element>(); List<ElementConstraint> childList = getBorderLayoutChildren(out); Set<ElementConstraint> used = new HashSet<ElementConstraint>(); for (ElementConstraint ec : childList) { if (ec.constraint != null && allowable.contains(ec.constraint) && !childMap.containsKey(ec.constraint)) { childMap.put(ec.constraint, ec.el); used.add(ec); } } childList.removeAll(used); if (!childList.isEmpty()) { // We weren't able to place all of the elements in the border layout // this is either because we filled all of the slots, or there were two // in some slots // Let's simplify things for now by just adding all of the extras in a // BoxLayout.Y inside the CENTER Element center = out.getOwnerDocument().createElement("component"); center.setAttribute("type", "Container"); applyBoxLayoutX(center); Element centerConstraint = out.getOwnerDocument().createElement("layoutConstraint"); centerConstraint.setAttribute("value", "CENTER"); center.appendChild(centerConstraint); if (childMap.containsKey("CENTER")) { //System.out.println("Removing center from "+childMap); out.removeChild(childMap.get("CENTER")); center.appendChild(childMap.get("CENTER")); } for (ElementConstraint ec : childList) { removeLayoutConstraint(ec.el); out.removeChild(ec.el); center.appendChild(ec.el); } out.appendChild(center); } } else if (out.hasAttribute("layout")) { // Not a boxlayout. NodeList children = out.getChildNodes(); int len = children.getLength(); for (int i = 0; i < len; i++) { Node n = children.item(i); if (n instanceof Element) { removeLayoutConstraint((Element) n); } } } applyStyles(inputSrcElement, out); }