nu.xom.Element.getChildElements()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(376)

本文整理了Java中nu.xom.Element.getChildElements()方法的一些代码示例,展示了Element.getChildElements()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getChildElements()方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:getChildElements

Element.getChildElements介绍

暂无

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

  1. protected int getChildCount() {
  2. return currentElement.getChildElements().size();
  3. }

代码示例来源:origin: com.thoughtworks.xstream/xstream

  1. protected Object getChild(int index) {
  2. return currentElement.getChildElements().get(index);
  3. }

代码示例来源:origin: wiztools/rest-client

  1. private List<ReqEntityPart> getMultipartParts(Element e) {
  2. List<ReqEntityPart> parts = new ArrayList<>();
  3. Elements children = e.getChildElements();
  4. for(int i=0; i<children.size(); i++) {
  5. ReqEntityPart part = getMultipartPart(children.get(i));
  6. parts.add(part);
  7. }
  8. return parts;
  9. }

代码示例来源:origin: wiztools/rest-client

  1. private Map<String, String> getHeadersFromHeaderNode(final Element node)
  2. throws XMLException {
  3. Map<String, String> m = new LinkedHashMap<>();
  4. for (int i = 0; i < node.getChildElements().size(); i++) {
  5. Element headerElement = node.getChildElements().get(i);
  6. if (!"header".equals(headerElement.getQualifiedName())) {
  7. throw new XMLException("<headers> element should contain only <header> elements");
  8. }
  9. m.put(headerElement.getAttributeValue("key"),
  10. headerElement.getAttributeValue("value"));
  11. }
  12. return m;
  13. }

代码示例来源:origin: wiztools/rest-client

  1. private void addFields(Elements eFields, ReqEntityBasePart part) {
  2. if(eFields == null) {
  3. return;
  4. }
  5. for(int i=0; i<eFields.size(); i++) {
  6. Element eField = eFields.get(i);
  7. String name = eField.getChildElements("name").get(0).getValue();
  8. String value = eField.getChildElements("value").get(0).getValue();
  9. part.addField(name, value);
  10. }
  11. }

代码示例来源:origin: com.thoughtworks.xstream/xstream

  1. public String peekNextChild() {
  2. Elements children = currentElement.getChildElements();
  3. if (null == children || children.size() == 0) {
  4. return null;
  5. }
  6. return decodeNode(children.get(0).getLocalName());
  7. }
  8. }

代码示例来源:origin: wiztools/rest-client

  1. private String getPartValue(Element e) {
  2. if(readVersion.isLessThan(VERSION_SINCE_PART_CONTENT)) {
  3. return e.getValue();
  4. }
  5. else {
  6. Element eContent = e.getChildElements("content").get(0);
  7. return eContent.getValue();
  8. }
  9. }

代码示例来源:origin: wiztools/rest-client

  1. if(e.getChildElements("fields").size() > 0) {
  2. eFields = e.getChildElements("fields").get(0).getChildElements("field");

代码示例来源:origin: wiztools/rest-client

  1. static Auth getAuth(Element eAuth) {
  2. Elements eChildren = eAuth.getChildElements();
  3. for(int i=0; i<eChildren.size(); i++) {
  4. Element e = eChildren.get(i);
  5. final String name = e.getLocalName();
  6. if(name.equals("basic")) {
  7. return getBasicAuth(e);
  8. }
  9. else if(name.equals("digest")) {
  10. return getDigestAuth(e);
  11. }
  12. else if(name.equals("ntlm")) {
  13. return getNtlmAuth(e);
  14. }
  15. else if(name.equals("oauth2-bearer")) {
  16. return getOAuth2BearerAuth(e);
  17. }
  18. else {
  19. throw new XMLException("Invalid auth element encountered: " + name);
  20. }
  21. }
  22. return null;
  23. }

代码示例来源:origin: wiztools/rest-client

  1. private List<HttpCookie> getCookiesFromCookiesNode(final Element node)
  2. throws XMLException {
  3. List<HttpCookie> out = new ArrayList<>();
  4. for (int i = 0; i < node.getChildElements().size(); i++) {
  5. Element e = node.getChildElements().get(i);
  6. if(!"cookie".equals(e.getQualifiedName())) {
  7. throw new XMLException("<cookies> element should contain only <cookie> elements");
  8. }
  9. HttpCookie cookie = new HttpCookie(e.getAttributeValue("name"),
  10. e.getAttributeValue("value"));
  11. final String cookieVerStr = e.getAttributeValue("version");
  12. if(StringUtil.isNotEmpty(cookieVerStr)) {
  13. cookie.setVersion(Integer.parseInt(cookieVerStr));
  14. }
  15. else {
  16. cookie.setVersion(CookieVersion.DEFAULT_VERSION.getIntValue());
  17. }
  18. out.add(cookie);
  19. }
  20. return out;
  21. }

代码示例来源:origin: wiztools/rest-client

  1. static OAuth2BearerAuth getOAuth2BearerAuth(Element eAuth) {
  2. OAuth2BearerAuthBean out = new OAuth2BearerAuthBean();
  3. Elements eChildren = eAuth.getChildElements();
  4. for(int i=0; i<eChildren.size(); i++) {
  5. Element e = eChildren.get(i);
  6. final String name = e.getLocalName();
  7. if(name.equals("token")) {
  8. out.setOAuth2BearerToken(e.getValue());
  9. }
  10. else {
  11. throw new XMLException("Unknown element in oauth2-bearer auth: " + name);
  12. }
  13. }
  14. return out;
  15. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. int offset = 0;
  2. List<CoreMap> sentences = new ArrayList<>();
  3. Elements sentenceElements = textElem.getChildElements("SENT");
  4. for (int crtsent = 0; crtsent < sentenceElements.size(); crtsent ++){
  5. Element sentElem = sentenceElements.get(crtsent);

代码示例来源:origin: wiztools/rest-client

  1. static void populateBasicDigestAuth(BasicDigestAuthBaseBean bean, Element eAuth) {
  2. Elements eChildren = eAuth.getChildElements();
  3. for(int i=0; i<eChildren.size(); i++) {
  4. Element e = eChildren.get(i);
  5. final String name = e.getLocalName();
  6. if(name.equals("host")) {
  7. bean.setHost(e.getValue());
  8. }
  9. else if(name.equals("realm")) {
  10. bean.setRealm(e.getValue());
  11. }
  12. else if(name.equals("username")) {
  13. bean.setUsername(e.getValue());
  14. }
  15. else if(name.equals("password")) {
  16. bean.setPassword(getPassword(e));
  17. }
  18. else if(name.equals("preemptive")) {
  19. bean.setPreemptive(true);
  20. }
  21. else {
  22. throw new XMLException("Unknown element in basic/digest auth: " + name);
  23. }
  24. }
  25. }

代码示例来源:origin: wiztools/rest-client

  1. ReqEntity getReqEntity(Element eEntity) {
  2. Elements eChildren = eEntity.getChildElements();
  3. for(int i=0; i<eChildren.size(); i++) {
  4. Element e = eChildren.get(i);

代码示例来源:origin: wiztools/rest-client

  1. RequestBean requestBean = new RequestBean();
  2. for (int i = 0; i < requestNode.getChildElements().size(); i++) {
  3. Element tNode = requestNode.getChildElements().get(i);
  4. String nodeName = tNode.getQualifiedName();
  5. if ("http-version".equals(nodeName)) {

代码示例来源:origin: wiztools/rest-client

  1. static NtlmAuth getNtlmAuth(Element eNtlmAuth) {
  2. NtlmAuthBean out = new NtlmAuthBean();
  3. Elements eChildren = eNtlmAuth.getChildElements();
  4. for(int i=0; i<eChildren.size(); i++) {
  5. Element e = eChildren.get(i);
  6. final String name = e.getLocalName();
  7. if(name.equals("domain")) {
  8. out.setDomain(e.getValue());
  9. }
  10. else if(name.equals("workstation")) {
  11. out.setWorkstation(e.getValue());
  12. }
  13. else if(name.equals("username")) {
  14. out.setUsername(e.getValue());
  15. }
  16. else if(name.equals("password")) {
  17. out.setPassword(getPassword(e));
  18. }
  19. else {
  20. throw new XMLException("Unknown element in ntlm auth: " + name);
  21. }
  22. }
  23. return out;
  24. }

代码示例来源:origin: wiztools/rest-client

  1. if (rootNode.getChildElements().size() != 1) {
  2. throw new XMLException("There can be only one child node for root node: <response>");
  3. for (int i = 0; i < responseNode.getChildElements().size(); i++) {
  4. tNode = responseNode.getChildElements().get(i);
  5. String nodeName = tNode.getQualifiedName();

代码示例来源:origin: wiztools/rest-client

  1. public static List<Request> getRequestCollectionFromXMLFile(final File f)
  2. throws IOException, XMLException {
  3. XmlPersistenceRead xUtlRead = new XmlPersistenceRead();
  4. List<Request> out = new ArrayList<>();
  5. Document doc = xUtlRead.getDocumentFromFile(f);
  6. Element eRoot = doc.getRootElement();
  7. if(!"request-collection".equals(eRoot.getLocalName())) {
  8. throw new XMLException("Expecting root element <request-collection>, but found: "
  9. + eRoot.getLocalName());
  10. }
  11. final String version = eRoot.getAttributeValue("version");
  12. try {
  13. Versions.versionValidCheck(version);
  14. }
  15. catch(Versions.VersionValidationException ex) {
  16. throw new XMLException(ex);
  17. }
  18. xUtlRead.setReadVersion(version);
  19. Elements eRequests = doc.getRootElement().getChildElements();
  20. for(int i=0; i<eRequests.size(); i++) {
  21. Element eRequest = eRequests.get(i);
  22. Request req = xUtlRead.getRequestBean(eRequest);
  23. out.add(req);
  24. }
  25. return out;
  26. }

代码示例来源:origin: wiztools/rest-client

  1. protected Request xml2Request(final Document doc)
  2. throws MalformedURLException, XMLException {
  3. // get the rootNode
  4. Element rootNode = doc.getRootElement();
  5. if (!"rest-client".equals(rootNode.getQualifiedName())) {
  6. throw new XMLException("Root node is not <rest-client>");
  7. }
  8. // checking correct rest version
  9. final String rcVersion = rootNode.getAttributeValue("version");
  10. try {
  11. Versions.versionValidCheck(rcVersion);
  12. }
  13. catch(Versions.VersionValidationException ex) {
  14. throw new XMLException(ex);
  15. }
  16. readVersion = rcVersion;
  17. // if more than two request element is present then throw the exception
  18. if (rootNode.getChildElements().size() != 1) {
  19. throw new XMLException("There can be only one child node for root node: <request>");
  20. }
  21. // minimum one request element is present in xml
  22. if (rootNode.getFirstChildElement("request") == null) {
  23. throw new XMLException("The child node of <rest-client> should be <request>");
  24. }
  25. Element requestNode = rootNode.getFirstChildElement("request");
  26. return getRequestBean(requestNode);
  27. }

代码示例来源:origin: wiztools/rest-client

  1. static SSLReq getSslReq(Element eSsl) {
  2. SSLReqBean out = new SSLReqBean();
  3. Elements eChildren = eSsl.getChildElements();
  4. for(int i=0; i<eChildren.size(); i++) {
  5. Element e = eChildren.get(i);

相关文章