當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.getChild方法代碼示例

本文整理匯總了Java中org.jdom.Element.getChild方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getChild方法的具體用法?Java Element.getChild怎麽用?Java Element.getChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom.Element的用法示例。


在下文中一共展示了Element.getChild方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getITunesAttribute

import org.jdom.Element; //導入方法依賴的package包/類
private String getITunesAttribute(Element element, String childName, String attributeName) {
    for (Namespace ns : ITUNES_NAMESPACES) {
        Element elem = element.getChild(childName, ns);
        if (elem != null) {
            return StringUtils.trimToNull(elem.getAttributeValue(attributeName));
        }
    }
    return null;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:10,代碼來源:PodcastService.java

示例2: parseImage

import org.jdom.Element; //導入方法依賴的package包/類
/**
 * Parses the root element of an RSS document looking for  image information.
 * <p/>
 * It first invokes super.parseImage and then parses and injects the following
 * properties if present: url, link, width, height and description.
 * <p/>
 *
 * @param rssRoot the root element of the RSS document to parse for image information.
 * @return the parsed RSSImage bean.
 */
protected Image parseImage(Element rssRoot) {
    Image image = super.parseImage(rssRoot);
    if (image!=null) {
        Element eImage = getImage(rssRoot);
        Element e = eImage.getChild("width",getRSSNamespace());
        if (e!=null) {
            image.setWidth(Integer.parseInt(e.getText()));
        }
        e = eImage.getChild("height",getRSSNamespace());
        if (e!=null) {
            image.setHeight(Integer.parseInt(e.getText()));
        }
        e = eImage.getChild("description",getRSSNamespace());
        if (e!=null) {
            image.setDescription(e.getText());
        }
    }
    return image;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:RSS091UserlandParser.java

示例3: doGet

import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("nls")
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
	resp.setContentType("application/x-java-jnlp-file");
	resp.setHeader("Cache-Control", "private, max-age=5, must-revalidate");
	Document locJnlpDocument = (Document) this.jnlpDocument.clone();
	Element jnlpElem = locJnlpDocument.getRootElement();
	String instUrl = institutionService.getInstitutionUrl().toString();
	jnlpElem.setAttribute("codebase", instUrl);
	Element resources = jnlpElem.getChild("resources");

	String token = userService.getGeneratedToken(Constants.APPLET_SECRET_ID, CurrentUser.getUsername());

	String tokenEncoded = Base64.encodeBase64String(token.getBytes("UTF-8")).replace("\r", "").replace("\n", "");
	resources.addContent(createJar(resourcesService.getUrl("com.tle.web.adminconsole", "adminconsole.jar")));
	resources.addContent(createProperty(Bootstrap.TOKEN_PARAMETER, tokenEncoded));
	resources.addContent(createProperty(Bootstrap.ENDPOINT_PARAMETER, instUrl));
	resources.addContent(createProperty(Bootstrap.LOCALE_PARAMETER, CurrentLocale.getLocale().toString()));
	resources.addContent(createProperty(Bootstrap.INSTITUTION_NAME_PARAMETER, CurrentInstitution.get().getName()));
	xmlOut.output(locJnlpDocument, resp.getWriter());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:TleJnlpDownloadServlet.java

示例4: readFrom

import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void readFrom(Element rootElement)
/* Is passed an Element by TC, and is expected to persist it to the settings object.
 * Old settings should be overwritten.
 */
{
    if(msteamsNotificationMainConfig.getConfigFileExists()){
        // The MainConfigProcessor approach has been deprecated.
        // Instead we will use our own config file so we have better control over when it is persisted
        return;
    }
	Loggers.SERVER.info("MsTeamsNotificationMainSettings: re-reading main settings using old-style MainConfigProcessor. From now on we will use the msteams/msteams-config.xml file instead of main-config.xml");
	Loggers.SERVER.debug(NAME + ":readFrom :: " + rootElement.toString());
	MsTeamsNotificationMainConfig tempConfig = new MsTeamsNotificationMainConfig(serverPaths);
	Element msteamsNotificationsElement = rootElement.getChild("msteamsnotifications");
    tempConfig.readConfigurationFromXmlElement(msteamsNotificationsElement);
    this.msteamsNotificationMainConfig = tempConfig;
    tempConfig.save();
}
 
開發者ID:spyder007,項目名稱:teamcity-msteams-notifier,代碼行數:21,代碼來源:MsTeamsNotificationMainSettings.java

示例5: parsePerson

import org.jdom.Element; //導入方法依賴的package包/類
private Person parsePerson(URL baseURI, Element ePerson) {
    Person person = new Person();
    Element e = ePerson.getChild("name",getAtomNamespace());
    if (e!=null) {
        person.setName(e.getText());
    }
    e = ePerson.getChild("uri",getAtomNamespace());
    if (e!=null) {
        person.setUri(resolveURI(baseURI, ePerson, e.getText()));
    }
    e = ePerson.getChild("email",getAtomNamespace());
    if (e!=null) {
        person.setEmail(e.getText());
    }
    return person;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:17,代碼來源:Atom10Parser.java

示例6: updateElement

import org.jdom.Element; //導入方法依賴的package包/類
/**
 * Method updateElement.
 * 
 * @param counter
 * @param shouldExist
 * @param name
 * @param parent
 * @return Element
 */
protected Element updateElement(Counter counter, Element parent, String name, boolean shouldExist)
{
    Element element =  parent.getChild(name, parent.getNamespace());
    if (element != null && shouldExist) {
        counter.increaseCount();
    }
    if (element == null && shouldExist) {
        element = factory.element(name, parent.getNamespace());
        insertAtPreferredLocation(parent, element, counter);
        counter.increaseCount();
    }
    if (!shouldExist && element != null) {
        int index = parent.indexOf(element);
        if (index > 0) {
            Content previous = parent.getContent(index - 1);
            if (previous instanceof Text) {
                Text txt = (Text)previous;
                if (txt.getTextTrim().length() == 0) {
                    parent.removeContent(txt);
                }
            }
        }
        parent.removeContent(element);
    }
    return element;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:NetbeansBuildActionJDOMWriter.java

示例7: checkLength

import org.jdom.Element; //導入方法依賴的package包/類
protected void checkLength(Element parent, String childName, int minLen, int maxLen) throws FeedException {
    Element  child = parent.getChild(childName,getFeedNamespace());
    if (child != null) {
        if (minLen>0 && child.getText().length()<minLen) {
            throw new FeedException("Invalid "+getType()+" feed, "+parent.getName()+" "+childName + "short of "+minLen+" length");
        }
        if (maxLen>-1 && child.getText().length()>maxLen) {
            throw new FeedException("Invalid "+getType()+" feed, "+parent.getName()+" "+childName + "exceeds "+maxLen+" length");
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:12,代碼來源:RSS090Generator.java

示例8: getChannelImageUrl

import org.jdom.Element; //導入方法依賴的package包/類
private String getChannelImageUrl(Element channelElement) {
    String result = getITunesAttribute(channelElement, "image", "href");
    if (result == null) {
        Element imageElement = channelElement.getChild("image");
        if (imageElement != null) {
            result = imageElement.getChildTextTrim("url");
        }
    }
    return result;
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:11,代碼來源:PodcastService.java

示例9: getChildList

import org.jdom.Element; //導入方法依賴的package包/類
public static List<Element> getChildList(Element parent, String name, boolean optional) throws StudyUnrecognizedFormatException {
  Element listParent = getChildWithName(parent, name, optional);
  if (listParent != null) {
    Element list = listParent.getChild(LIST);
    if (list != null) {
      return list.getChildren();
    }
  }
  return Collections.emptyList();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:11,代碼來源:StudySerializationUtils.java

示例10: processInheritableResourceData

import org.jdom.Element; //導入方法依賴的package包/類
/**
 * Recursive method to process the {@link CreoleResource} elements that can be
 * inherited from superclasses and interfaces (everything except the PRIVATE
 * and MAIN_VIEWER flags, the NAME and the AUTOINSTANCEs). Once data has been
 * extracted from the current class the method calls itself recursively for
 * the superclass and any implemented interfaces. For any given attribute, the
 * first value specified wins (i.e. the one on the most specific class).
 * 
 * @param clazz
 *          the class to process
 * @param element
 *          the RESOURCE element to which data should be added.
 */
private void processInheritableResourceData(Class<?> clazz, Element element) {
  CreoleResource cr = clazz.getAnnotation(CreoleResource.class);
  if(cr != null) {
    addElement(element, cr.comment(), "COMMENT");
    addElement(element, cr.helpURL(), "HELPURL");
    addElement(element, cr.interfaceName(), "INTERFACE");
    addElement(element, cr.icon(), "ICON");
    if(cr.guiType() != GuiType.NONE && element.getChild("GUI") == null) {
      Element guiElement =
          new Element("GUI").setAttribute("TYPE", cr.guiType().toString());
      element.addContent(guiElement);
      addElement(guiElement, cr.resourceDisplayed(), "RESOURCE_DISPLAYED");
    }
    addElement(element, cr.annotationTypeDisplayed(),
        "ANNOTATION_TYPE_DISPLAYED");
  }

  Class<?> superclass = clazz.getSuperclass();
  if(superclass != null) {
    processInheritableResourceData(superclass, element);
  }

  for(Class<?> intf : clazz.getInterfaces()) {
    processInheritableResourceData(intf, element);
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:40,代碼來源:CreoleAnnotationHandler.java

示例11: parseItem

import org.jdom.Element; //導入方法依賴的package包/類
protected Item parseItem(Element rssRoot,Element eItem) {
    Item item = super.parseItem(rssRoot,eItem);
    item.setExpirationDate(null);

    Element e = eItem.getChild("author",getRSSNamespace());
    if (e!=null) {
        item.setAuthor(e.getText());
    }

    e = eItem.getChild("guid",getRSSNamespace());
    if (e!=null) {
        Guid guid = new Guid();
        String att = e.getAttributeValue("isPermaLink");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            guid.setPermaLink(att.equalsIgnoreCase("true"));
        }
        guid.setValue(e.getText());
        item.setGuid(guid);
    }

    e = eItem.getChild("comments",getRSSNamespace());
    if (e!=null) {
        item.setComments(e.getText());
    }

    return item;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:RSS094Parser.java

示例12: test_WebookConfig

import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void test_WebookConfig() throws JDOMException, IOException{
	SAXBuilder builder = new SAXBuilder();
	List<MsTeamsNotificationConfig> configs = new ArrayList<MsTeamsNotificationConfig>();
	builder.setIgnoringElementContentWhitespace(true);
		Document doc = builder.build("src/test/resources/testdoc2.xml");
		Element root = doc.getRootElement();
		if(root.getChild("msteamsNotifications") != null){
			Element child = root.getChild("msteamsNotifications");
			if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
				List<Element> namedChildren = child.getChildren("msteamsNotification");
				for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
	            {
					Element e = i.next();
					MsTeamsNotificationConfig whConfig = new MsTeamsNotificationConfig(e);
					configs.add(whConfig);
	            }
			}
		}

	
	for (MsTeamsNotificationConfig c : configs){
		MsTeamsNotification wh = new MsTeamsNotificationImpl();
		wh.setEnabled(c.getEnabled());
		//msteamsNotification.addParams(c.getParams());
		System.out.println(wh.isEnabled().toString());

	}
}
 
開發者ID:spyder007,項目名稱:teamcity-msteams-notifier,代碼行數:31,代碼來源:MsTeamsNotificationSettingsTest.java

示例13: parseChannel

import org.jdom.Element; //導入方法依賴的package包/類
protected WireFeed parseChannel(Element rssRoot)  {
    Channel channel = (Channel) super.parseChannel(rssRoot);

    Element eChannel = rssRoot.getChild("channel",getRSSNamespace());
    Element eCloud = eChannel.getChild("cloud",getRSSNamespace());
    if (eCloud!=null) {
        Cloud cloud = new Cloud();
        String att = eCloud.getAttributeValue("domain");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            cloud.setDomain(att);
        }
        att = eCloud.getAttributeValue("port");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            cloud.setPort(Integer.parseInt(att));
        }
        att = eCloud.getAttributeValue("path");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            cloud.setPath(att);
        }
        att = eCloud.getAttributeValue("registerProcedure");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            cloud.setRegisterProcedure(att);
        }
        att = eCloud.getAttributeValue("protocol");//getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
        if (att!=null) {
            cloud.setProtocol(att);
        }
        channel.setCloud(cloud);
    }
    return channel;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:RSS092Parser.java

示例14: readComponent

import org.jdom.Element; //導入方法依賴的package包/類
@Nullable
private static Element readComponent(@NotNull SAXBuilder parser, @NotNull String projectPath) {
  Element component = null;
  try {
    String studyProjectXML = projectPath + STUDY_PROJECT_XML_PATH;
    Document xmlDoc = parser.build(new File(studyProjectXML));
    Element root = xmlDoc.getRootElement();
    component = root.getChild("component");
  }
  catch (JDOMException | IOException ignored) {
  }

  return component;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:15,代碼來源:EduBuiltInServerUtils.java

示例15: readColors

import org.jdom.Element; //導入方法依賴的package包/類
private void readColors(Element element) {
    if (namedTextAttrs == null) {
        namedTextAttrs = new ArrayList<>();
    }

    final Element colorListTag = element.getChild(COLOR_LIST_TAG);
    if (colorListTag != null) {
        for (Element colorTag : colorListTag.getChildren(COLOR_TAG)) {
            namedTextAttrs.add(new NamedTextAttr(colorTag));
        }
    }
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:13,代碼來源:MultiHighlightConfig.java


注:本文中的org.jdom.Element.getChild方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。