本文整理了Java中nu.xom.Element.getChildElements()
方法的一些代码示例,展示了Element.getChildElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getChildElements()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:getChildElements
暂无
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected int getChildCount() {
return currentElement.getChildElements().size();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected Object getChild(int index) {
return currentElement.getChildElements().get(index);
}
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
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);
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public String peekNextChild() {
Elements children = currentElement.getChildElements();
if (null == children || children.size() == 0) {
return null;
}
return decodeNode(children.get(0).getLocalName());
}
}
代码示例来源:origin: wiztools/rest-client
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();
}
}
代码示例来源:origin: wiztools/rest-client
if(e.getChildElements("fields").size() > 0) {
eFields = e.getChildElements("fields").get(0).getChildElements("field");
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: stanfordnlp/CoreNLP
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);
代码示例来源:origin: wiztools/rest-client
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);
}
}
}
代码示例来源:origin: wiztools/rest-client
ReqEntity getReqEntity(Element eEntity) {
Elements eChildren = eEntity.getChildElements();
for(int i=0; i<eChildren.size(); i++) {
Element e = eChildren.get(i);
代码示例来源:origin: wiztools/rest-client
RequestBean requestBean = new RequestBean();
for (int i = 0; i < requestNode.getChildElements().size(); i++) {
Element tNode = requestNode.getChildElements().get(i);
String nodeName = tNode.getQualifiedName();
if ("http-version".equals(nodeName)) {
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
if (rootNode.getChildElements().size() != 1) {
throw new XMLException("There can be only one child node for root node: <response>");
for (int i = 0; i < responseNode.getChildElements().size(); i++) {
tNode = responseNode.getChildElements().get(i);
String nodeName = tNode.getQualifiedName();
代码示例来源:origin: wiztools/rest-client
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;
}
代码示例来源:origin: wiztools/rest-client
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);
}
代码示例来源:origin: wiztools/rest-client
static SSLReq getSslReq(Element eSsl) {
SSLReqBean out = new SSLReqBean();
Elements eChildren = eSsl.getChildElements();
for(int i=0; i<eChildren.size(); i++) {
Element e = eChildren.get(i);
内容来源于网络,如有侵权,请联系作者删除!