本文整理匯總了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;
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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));
}
}
}