Refine search
private void addFields(Elements eFields, ReqEntityBasePart part) { if(eFields == null) { return; } for(int i=0; i<eFields.size(); i++) { Element eField = eFields.get(i); String name = eField.getChildElements("name").get(0).getValue(); String value = eField.getChildElements("value").get(0).getValue(); part.addField(name, value); } }
private List<ReqEntityPart> getMultipartParts(Element e) { List<ReqEntityPart> parts = new ArrayList<>(); Elements children = e.getChildElements(); for(int i=0; i<children.size(); i++) { ReqEntityPart part = getMultipartPart(children.get(i)); parts.add(part); } return parts; }
Element textElem = docElem.getFirstChildElement("TEXT"); StringBuilder text = new StringBuilder(); int offset = 0; List<CoreMap> sentences = new ArrayList<>(); Elements sentenceElements = textElem.getChildElements("SENT"); for (int crtsent = 0; crtsent < sentenceElements.size(); crtsent ++){ Element sentElem = sentenceElements.get(crtsent); CoreMap sentence = new ArrayCoreMap(); sentence.set(CoreAnnotations.CharacterOffsetBeginAnnotation.class, offset); Tree tree = Tree.valueOf(sentElem.getChild(0).getValue()); // XXX ms: is this the same as sentElem.getText() in JDOM? List<CoreLabel> tokens = new ArrayList<>(); List<Tree> preTerminals = preTerminals(tree);
void updateProperty(Document pom, String propertyName, String newVersion) throws MojoExecutionException { XPathContext context = new XPathContext("mvn", "http://maven.apache.org/POM/4.0.0"); Nodes nodes = pom.query("//mvn:properties", context); if (nodes.size() > 0) { final Element propertiesElement = (Element) nodes.get(0); Elements properties = propertiesElement.getChildElements(); for (int i = 0; i < properties.size(); i++) { Element property = properties.get(i); if (property.getLocalName().equals(propertyName)) { Element newRange = new Element(propertyName, "http://maven.apache.org/POM/4.0.0"); newRange.appendChild(newVersion); propertiesElement.replaceChild(property, newRange); } } } }
/** * iterator. * * @param list */ public CMLElementsIterator(List<T> list) { this.list = list; }
if (!"rest-client".equals(rootNode.getQualifiedName())) { throw new XMLException("Root node is not <rest-client>"); Versions.versionValidCheck(rootNode.getAttributeValue("version")); if (rootNode.getChildElements().size() != 1) { throw new XMLException("There can be only one child node for root node: <response>"); responseNode = rootNode.getFirstChildElement("response"); for (int i = 0; i < responseNode.getChildElements().size(); i++) { tNode = responseNode.getChildElements().get(i); String nodeName = tNode.getQualifiedName();
protected int getChildCount() { return currentElement.getChildElements().size(); }
protected Object getChild(int index) { return currentElement.getChildElements().get(index); }
private boolean hasContentTypeMetadata(Element head) { Elements metaChildren = head.getChildElements("meta"); for (int i=0; i < metaChildren.size(); i++) { Element metaChild = metaChildren.get(i); Attribute httpEquiv = metaChild.getAttribute("http-equiv"); if (httpEquiv != null && "content-type".equalsIgnoreCase(httpEquiv.getValue())) { return true; } } return false; } }
protected Request xml2Request(final Document doc) throws MalformedURLException, XMLException { // get the rootNode Element rootNode = doc.getRootElement(); if (!"rest-client".equals(rootNode.getQualifiedName())) { throw new XMLException("Root node is not <rest-client>"); } // checking correct rest version final String rcVersion = rootNode.getAttributeValue("version"); try { Versions.versionValidCheck(rcVersion); } catch(Versions.VersionValidationException ex) { throw new XMLException(ex); } readVersion = rcVersion; // if more than two request element is present then throw the exception if (rootNode.getChildElements().size() != 1) { throw new XMLException("There can be only one child node for root node: <request>"); } // minimum one request element is present in xml if (rootNode.getFirstChildElement("request") == null) { throw new XMLException("The child node of <rest-client> should be <request>"); } Element requestNode = rootNode.getFirstChildElement("request"); return getRequestBean(requestNode); }
@Test public void cachesResult() { stubSource.addResource(PACKAGE_RESOURCE_NAME, GOOD_HTML); Element rootElement = new Element("html"); SpecificationProcessingEvent event = new SpecificationProcessingEvent(new Resource(SPEC_RESOURCE_NAME), new org.concordion.api.Element(rootElement)); renderer.afterProcessingSpecification(event); Elements bodySpans = rootElement.getChildElements("body").get(0).getChildElements("span"); assertThat(bodySpans.get(0).getChildElements("a").get(0).getValue(), is("Parent")); // Changing the package resource to bad HTML has no effect since we cached the first result stubSource.addResource(PACKAGE_RESOURCE_NAME, ERRONEOUS_HTML); rootElement = new Element("html"); event = new SpecificationProcessingEvent(new Resource(SPEC_RESOURCE_NAME), new org.concordion.api.Element(rootElement)); renderer.afterProcessingSpecification(event); bodySpans = rootElement.getChildElements("body").get(0).getChildElements("span"); assertThat(bodySpans.get(0).getChildElements("a").get(0).getValue(), is("Parent")); } }
private String getPartValue(Element e) { if(readVersion.isLessThan(VERSION_SINCE_PART_CONTENT)) { return e.getValue(); } else { Element eContent = e.getChildElements("content").get(0); return eContent.getValue(); } }
private void mergePRLists(Component prListC, Component prC) { Elements prLists = this.getChildCMLElements(prListC.name); if (prLists.size() > 1) { for (int i = 1; i < prLists.size(); i++) { CMLElement prList = (CMLElement) prLists.get(i); Elements prs = prList.getChildCMLElements(prC.name); for (int j = 0; j < prs.size(); j++) { Element pr = prs.get(j); pr.detach(); prLists.get(0).appendChild(pr); } prList.detach(); } } }
@Test public void createsBodyIfNoneExists() { stubSource.addResource(PACKAGE_RESOURCE_NAME, GOOD_HTML); Element rootElement = new Element("html"); SpecificationProcessingEvent event = new SpecificationProcessingEvent(new Resource(SPEC_RESOURCE_NAME), new org.concordion.api.Element(rootElement)); renderer.afterProcessingSpecification(event); String logMessage = systemErrRule.getLog(); assertThat(logMessage, is("")); assertThat(rootElement.getChildElements("body").size(), is(1)); }
private void processOccurences(final Element element, final Element parent, final String localName, final String nsURI) { if (parent.getChildElements(localName, nsURI).size() > 1) { element.addAttribute(new Attribute("maxOccurs", "unbounded")); } else { element.addAttribute(new Attribute("minOccurs", "0")); if (enableMaxOccursOnce) element.addAttribute(new Attribute("maxOccurs", "1")); } }
public OverissueElementException(final String elementName, final Elements childElements, final Element parent) { super("Expected one Element["+elementName+"] but found " + childElements.size() + " childs of parent Element["+parent.getLocalName()+"]."); } }
public static Elements parseChildElements(final Element sourceElement, final String childElementName, final boolean atLeastOne) throws XMLParsingException { Elements childElements = sourceElement.getChildElements(childElementName); if (atLeastOne && childElements.size() == 0) { throw new XMLParsingException("Missing at least one element[" + childElementName + "] for parent element[" + sourceElement.getQualifiedName() + "]."); } return childElements; }
public BayesIm getBayesIm(Element element) { if (!"bayesNet".equals(element.getQualifiedName())) { throw new IllegalArgumentException("Expecting 'bayesNet' element."); } Elements elements = element.getChildElements(); Element element0 = elements.get(0); Element element1 = elements.get(1); Element element2 = elements.get(2); List<Node> variables = getVariables(element0); BayesPm bayesPm = makeBayesPm(variables, element1); return makeBayesIm(bayesPm, element2); }
/** * convenience method to get Element child count. avoid having to specify * namespaces. * * @param name * local CML name * @return the count of that type or null */ public int getCMLChildCount(String name) { Elements childElements = getChildCMLElements(name); return childElements.size(); }