Refine search
private List<File> parseFiles(Element filesElement, String fileType) { List files = filesElement.getChild(fileType).getChildren("file"); List<File> modifiedFiles = new ArrayList<>(); for (Iterator iterator = files.iterator(); iterator.hasNext();) { Element node = (Element) iterator.next(); modifiedFiles.add(new File(org.apache.commons.lang3.StringEscapeUtils.unescapeXml(node.getText()))); } return modifiedFiles; }
private Modification parseLogEntry(Element logEntry, String path) throws ParseException { Element logEntryPaths = logEntry.getChild("paths"); if (logEntryPaths == null) { /* Path-based access control forbids us from learning * details of this log entry, so skip it. */ return null; } Date modifiedTime = convertDate(logEntry.getChildText("date")); String author = logEntry.getChildText("author"); String comment = logEntry.getChildText("msg"); String revision = logEntry.getAttributeValue("revision"); Modification modification = new Modification(author, comment, null, modifiedTime, revision); List paths = logEntryPaths.getChildren("path"); for (Iterator iterator = paths.iterator(); iterator.hasNext();) { Element node = (Element) iterator.next(); if (underPath(path, node.getText())) { ModifiedAction action = convertAction(node.getAttributeValue("action")); modification.createModifiedFile(node.getText(), null, action); } } return modification; }
/** * Returns the textual content of the named child element, or null if * there's no such child. This method is a convenience because calling * <code>getChild().getText()</code> can throw a NullPointerException. * * @param cname the name of the child * @return text content for the named child, or null if * no such child */ public String getChildText(final String cname) { final Element child = getChild(cname); if (child == null) { return null; } return child.getText(); }
public StringArrayValue fromXmlElement( final PwmSetting pwmSetting, final Element settingElement, final PwmSecurityKey key ) { final List valueElements = settingElement.getChildren( "value" ); final List<String> values = new ArrayList<>(); for ( final Object loopValue : valueElements ) { final Element loopValueElement = ( Element ) loopValue; final String value = loopValueElement.getText(); values.add( value ); } return new StringArrayValue( values ); } };
protected void parseCollectionElement(final Element element) throws ProponoException { setHref(element.getAttribute("href").getValue()); final Element titleElem = element.getChild("title", AtomService.ATOM_FORMAT); if (titleElem != null) { setTitle(titleElem.getText()); if (titleElem.getAttribute("type", AtomService.ATOM_FORMAT) != null) { setTitleType(titleElem.getAttribute("type", AtomService.ATOM_FORMAT).getValue()); } } final List<Element> acceptElems = element.getChildren("accept", AtomService.ATOM_PROTOCOL); if (acceptElems != null && !acceptElems.isEmpty()) { for (final Element acceptElem : acceptElems) { addAccept(acceptElem.getTextTrim()); } } // Loop to parse <app:categories> element to Categories objects final List<Element> catsElems = element.getChildren("categories", AtomService.ATOM_PROTOCOL); for (final Element catsElem : catsElems) { final Categories cats = new Categories(catsElem, baseURI); addCategories(cats); } }
private Element mergeRecursive(Element rootElement, XPath xpath) throws OfxInternalProcessingException { try { List<?> list = xpath.selectNodes(rootElement); logger.debug(list.size()+" sections"); for (Iterator<?> iter = list.iterator(); iter.hasNext();) { Element e = (Element) iter.next(); boolean noChilds = (e.getChildren().size()==0); boolean noContent = (e.getText().length()==0); logger.trace(e.getName()+" "+e.getChildren().size()+" "+e.getText().length()); if(noChilds && noContent){e.detach();} else{e.setText(e.getTextTrim());} } } catch (JDOMException e) {logger.error("",e);} return rootElement; }
/** * Parses a JDOM Element as defined in * <a href="http://jpos.org/minigl.dtd">minigl.dtd</a> */ public void fromXML (Element elem) throws ParseException { setDetail (elem.getChildTextTrim ("detail")); setTags (new Tags(elem.getChildTextTrim ("tags"))); setCredit ("credit".equals (elem.getAttributeValue("type"))); setLayer(toShort(elem.getAttributeValue("layer"))); setAmount(new BigDecimal (elem.getChild ("amount").getText())); } /**
/** * Returns the textual content of the named child element, or null if * there's no such child. * * @param cname * the name of the child * @param ns * the namespace of the child. A null implies Namespace.NO_NAMESPACE. * @return text content for the named child, or null if no such child */ public String getChildText(final String cname, final Namespace ns) { final Element child = getChild(cname, ns); if (child == null) { return null; } return child.getText(); }
private void addAttributeIfExists(Element elem, String name, Variable v, boolean isDoubleArray) { Element child = elem.getChild(name); if (child == null) return; if (isDoubleArray) { List<Element> vElems = child.getChildren(); List<Double> values = new ArrayList<Double>(); for (Element ve : vElems) { String valueS = ve.getText().trim(); try { values.add(Double.parseDouble(valueS)); } catch (NumberFormatException e) { } } Attribute att = new Attribute(name, values); v.addAttribute(att); } else { String value = child.getText().trim(); Attribute att = new Attribute(name, value); v.addAttribute(att); } }
public NumericArrayValue fromXmlElement( final PwmSetting pwmSetting, final Element settingElement, final PwmSecurityKey input ) { final List<Long> returnList = new ArrayList<>( ); final List<Element> valueElements = settingElement.getChildren( "value" ); for ( final Element element : valueElements ) { final String strValue = element.getText(); final Long longValue = Long.parseLong( strValue ); returnList.add( longValue ); } return new NumericArrayValue( returnList ); } };
private void addAttributeIfExists(Element elem, String name, Variable v, boolean isDoubleArray) { Element child = elem.getChild(name); if (child == null) return; if (isDoubleArray) { List<Element> vElems = child.getChildren(); List<Double> values = new ArrayList<Double>(); for (Element ve : vElems) { String valueS = ve.getText(); try { values.add(Double.parseDouble(valueS)); } catch (NumberFormatException e) { } } Attribute att = new Attribute(name, values); v.addAttribute(att); } else { String value = child.getText(); Attribute att = new Attribute(name, value); v.addAttribute(att); } }
public OptionListValue fromXmlElement( final PwmSetting pwmSetting, final Element settingElement, final PwmSecurityKey key ) throws PwmOperationalException { final List valueElements = settingElement.getChildren( "value" ); final Set<String> values = new TreeSet<>(); for ( final Object loopValue : valueElements ) { final Element loopValueElement = ( Element ) loopValue; final String value = loopValueElement.getText(); if ( value != null && !value.trim().isEmpty() ) { values.add( value ); } } return new OptionListValue( values ); } };
public static String getElementText(Element parent, String localName, Namespace ns) { if (parent == null) { throw new IllegalArgumentException("parent element not found"); } Element child = parent.getChild(localName, ns); if (child == null) { throw new IllegalArgumentException(String.format("child element '%s' not found", localName)); } return child.getText(); }
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel",getRSSNamespace()); List eCats = eChannel.getChildren("category",getRSSNamespace()); channel.setCategories(parseCategories(eCats)); Element eTtl = eChannel.getChild("ttl",getRSSNamespace()); if (eTtl!=null && eTtl.getText() != null ) { Integer ttlValue = null; try{ ttlValue = new Integer(eTtl.getText()); } catch(NumberFormatException nfe ){ ; //let it go by } if (ttlValue != null) { channel.setTtl(ttlValue.intValue()); } } return channel; }
/** * Returns the text of last title child of the handed element in * the current language or null, if no title child was found. * @param pElement the element we start searching from * @return null or the text of the title element */ public String getTitle(final Element pElement) { String title= null; for (final Object o : pElement.getChildren(TITLE_ELEMENT)) { Element titleElement = (Element) o; if (isSameLanguage(titleElement)) { title = titleElement.getText(); } } return title; }
private String getParam( String name) { Element elem = rootElem; if (elem == null) return null; StringTokenizer stoke = new StringTokenizer(name, "."); while (stoke.hasMoreTokens()) { String toke = stoke.nextToken(); elem = elem.getChild(toke); if (null == elem) return null; } String text = elem.getText(); return (text == null) ? null : text.trim(); }
@Override protected WireFeed parseChannel(final Element rssRoot, final Locale locale) { final Channel channel = (Channel) super.parseChannel(rssRoot, locale); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final List<Element> categories = eChannel.getChildren("category", getRSSNamespace()); channel.setCategories(parseCategories(categories)); final Element ttl = eChannel.getChild("ttl", getRSSNamespace()); if (ttl != null && ttl.getText() != null) { final Integer ttlValue = NumberParser.parseInt(ttl.getText()); if (ttlValue != null) { channel.setTtl(ttlValue); } } return channel; }
/** * Returns the text of last title child of the handed element in * the current language or null, if no title child was found. * @param pElement the element we start searching from * @return null or the text of the title element */ public static String getTitleDefaultLocale(final Element pElement) { String title= null; for (final Object o : pElement.getChildren(TITLE_ELEMENT)) { Element titleElement = (Element) o; if (isSameLanguage(titleElement, Locale.getDefault())) { title = titleElement.getText(); } } return title; }