protected Object getChild(int index) { return currentElement.getChildElements().get(index); }
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; }
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 Map<String, String> getHeadersFromHeaderNode(final Element node) throws XMLException { Map<String, String> m = new LinkedHashMap<>(); for (int i = 0; i < node.getChildElements().size(); i++) { Element headerElement = node.getChildElements().get(i); if (!"header".equals(headerElement.getQualifiedName())) { throw new XMLException("<headers> element should contain only <header> elements"); } m.put(headerElement.getAttributeValue("key"), headerElement.getAttributeValue("value")); } return m; }
public String peekNextChild() { Elements children = currentElement.getChildElements(); if (null == children || children.size() == 0) { return null; } return decodeNode(children.get(0).getLocalName()); } }
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(); } }
static Auth getAuth(Element eAuth) { Elements eChildren = eAuth.getChildElements(); for(int i=0; i<eChildren.size(); i++) { Element e = eChildren.get(i); final String name = e.getLocalName(); if(name.equals("basic")) { return getBasicAuth(e); } else if(name.equals("digest")) { return getDigestAuth(e); } else if(name.equals("ntlm")) { return getNtlmAuth(e); } else if(name.equals("oauth2-bearer")) { return getOAuth2BearerAuth(e); } else { throw new XMLException("Invalid auth element encountered: " + name); } } return null; }
static OAuth2BearerAuth getOAuth2BearerAuth(Element eAuth) { OAuth2BearerAuthBean out = new OAuth2BearerAuthBean(); Elements eChildren = eAuth.getChildElements(); for(int i=0; i<eChildren.size(); i++) { Element e = eChildren.get(i); final String name = e.getLocalName(); if(name.equals("token")) { out.setOAuth2BearerToken(e.getValue()); } else { throw new XMLException("Unknown element in oauth2-bearer auth: " + name); } } return out; }
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);
static void populateBasicDigestAuth(BasicDigestAuthBaseBean bean, Element eAuth) { Elements eChildren = eAuth.getChildElements(); for(int i=0; i<eChildren.size(); i++) { Element e = eChildren.get(i); final String name = e.getLocalName(); if(name.equals("host")) { bean.setHost(e.getValue()); } else if(name.equals("realm")) { bean.setRealm(e.getValue()); } else if(name.equals("username")) { bean.setUsername(e.getValue()); } else if(name.equals("password")) { bean.setPassword(getPassword(e)); } else if(name.equals("preemptive")) { bean.setPreemptive(true); } else { throw new XMLException("Unknown element in basic/digest auth: " + name); } } }
private List<HttpCookie> getCookiesFromCookiesNode(final Element node) throws XMLException { List<HttpCookie> out = new ArrayList<>(); for (int i = 0; i < node.getChildElements().size(); i++) { Element e = node.getChildElements().get(i); if(!"cookie".equals(e.getQualifiedName())) { throw new XMLException("<cookies> element should contain only <cookie> elements"); } HttpCookie cookie = new HttpCookie(e.getAttributeValue("name"), e.getAttributeValue("value")); final String cookieVerStr = e.getAttributeValue("version"); if(StringUtil.isNotEmpty(cookieVerStr)) { cookie.setVersion(Integer.parseInt(cookieVerStr)); } else { cookie.setVersion(CookieVersion.DEFAULT_VERSION.getIntValue()); } out.add(cookie); } return out; }
ReqEntity getReqEntity(Element eEntity) { Elements eChildren = eEntity.getChildElements(); for(int i=0; i<eChildren.size(); i++) { Element e = eChildren.get(i); final String name = e.getLocalName(); if("string".equals(name)) {
static NtlmAuth getNtlmAuth(Element eNtlmAuth) { NtlmAuthBean out = new NtlmAuthBean(); Elements eChildren = eNtlmAuth.getChildElements(); for(int i=0; i<eChildren.size(); i++) { Element e = eChildren.get(i); final String name = e.getLocalName(); if(name.equals("domain")) { out.setDomain(e.getValue()); } else if(name.equals("workstation")) { out.setWorkstation(e.getValue()); } else if(name.equals("username")) { out.setUsername(e.getValue()); } else if(name.equals("password")) { out.setPassword(getPassword(e)); } else { throw new XMLException("Unknown element in ntlm auth: " + name); } } return out; }
eFields = e.getChildElements("fields").get(0).getChildElements("field");
Element tNode = requestNode.getChildElements().get(i); String nodeName = tNode.getQualifiedName(); if ("http-version".equals(nodeName)) {
public static List<Request> getRequestCollectionFromXMLFile(final File f) throws IOException, XMLException { XmlPersistenceRead xUtlRead = new XmlPersistenceRead(); List<Request> out = new ArrayList<>(); Document doc = xUtlRead.getDocumentFromFile(f); Element eRoot = doc.getRootElement(); if(!"request-collection".equals(eRoot.getLocalName())) { throw new XMLException("Expecting root element <request-collection>, but found: " + eRoot.getLocalName()); } final String version = eRoot.getAttributeValue("version"); try { Versions.versionValidCheck(version); } catch(Versions.VersionValidationException ex) { throw new XMLException(ex); } xUtlRead.setReadVersion(version); Elements eRequests = doc.getRootElement().getChildElements(); for(int i=0; i<eRequests.size(); i++) { Element eRequest = eRequests.get(i); Request req = xUtlRead.getRequestBean(eRequest); out.add(req); } return out; }
tNode = responseNode.getChildElements().get(i); String nodeName = tNode.getQualifiedName();
Element e = eChildren.get(i); final String name = e.getLocalName(); if(null != name) switch (name) {
private List<CMLLength> makeLengthList(CMLElement element) { Elements lengthElements = element.getChildCMLElements(CMLLength.TAG); List<CMLLength> lengthList = new ArrayList<CMLLength>(); for (int i = 0; i < lengthElements.size(); i++) { lengthList.add((CMLLength)lengthElements.get(i)); } if (lengthList.size() == 0) { throw new RuntimeException("no length elements in ZMatrix"); } return lengthList; }
@Override public String peekNextChild() { final Elements children = currentElement.getChildElements(); if (null == children || children.size() == 0) { return null; } return decodeNode(children.get(0).getLocalName()); } }