本文整理匯總了Java中org.jdom.Element.getChildren方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getChildren方法的具體用法?Java Element.getChildren怎麽用?Java Element.getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom.Element
的用法示例。
在下文中一共展示了Element.getChildren方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addJarsToClassLoader
import org.jdom.Element; //導入方法依賴的package包/類
/**
* Recursively search the given element for JAR entries and add these jars to
* the GateClassLoader
*
* @param jdomElt
* JDOM element representing a creole.xml file
*/
@SuppressWarnings("unchecked")
private void addJarsToClassLoader(GateClassLoader gcl, Element jdomElt)
throws MalformedURLException {
if("JAR".equals(jdomElt.getName())) {
URL url = new URL(plugin.getBaseURL(), jdomElt.getTextTrim());
try {
java.io.InputStream s = url.openStream();
s.close();
gcl.addURL(url);
} catch(IOException e) {
log.debug("Unable to add JAR "
+ url
+ " specified in creole file "
+ " to class loader, hopefully the required classes are already on the classpath.");
}
} else {
for(Element child : (List<Element>)jdomElt.getChildren()) {
addJarsToClassLoader(gcl, child);
}
}
}
示例2: loadState
import org.jdom.Element; //導入方法依賴的package包/類
@Override
public void loadState(final Element state) {
synchronized (lock) {
queue.clear();
for (Element element : state.getChildren(TAG_ENTITY)) {
final String actionName = element.getAttributeValue(ATTR_ACTION);
final String dateStr = element.getAttributeValue(ATTR_DATE);
final String parameters = element.getAttributeValue(ATTR_NAME);
if (actionName != null && dateStr != null) {
try {
final ACTIONS action = ACTIONS.valueOf(actionName);
queue.add(new Entity(action, parameters, dateStr));
} catch (IllegalArgumentException ignored) {
}
}
}
lock.notifyAll();
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:22,代碼來源:DefaultStatsCollector.java
示例3: parse
import org.jdom.Element; //導入方法依賴的package包/類
public Module parse(Element dcRoot) {
boolean foundSomething = false;
SampleModule fm = new SampleModuleImpl();
Element e = dcRoot.getChild("bar", SAMPLE_NS);
if (e != null) {
foundSomething = true;
fm.setBar(e.getText());
}
List eList = dcRoot.getChildren("foo", SAMPLE_NS);
if (eList.size() > 0) {
foundSomething = true;
fm.setFoos(parseFoos(eList));
}
e = dcRoot.getChild("date", SAMPLE_NS);
if (e != null) {
foundSomething = true;
fm.setDate(DateParser.parseDate(e.getText()));
}
return (foundSomething) ? fm : null;
}
示例4: getChildMap
import org.jdom.Element; //導入方法依賴的package包/類
public static <K, V> Map<K, V> getChildMap(Element element, String name, boolean optional) throws StudyUnrecognizedFormatException {
Element mapParent = getChildWithName(element, name, optional);
if (mapParent != null) {
Element map = mapParent.getChild(MAP);
if (map != null) {
HashMap result = new HashMap();
for (Element entry : map.getChildren()) {
Object key = entry.getAttribute(KEY) == null ? entry.getChild(KEY).getChildren().get(0) : entry.getAttributeValue(KEY);
Object value = entry.getAttribute(VALUE) == null ? entry.getChild(VALUE).getChildren().get(0) : entry.getAttributeValue(VALUE);
result.put(key, value);
}
return result;
}
}
return Collections.emptyMap();
}
示例5: parseChannel
import org.jdom.Element; //導入方法依賴的package包/類
protected WireFeed parseChannel(Element rssRoot) {
Channel channel = (Channel) super.parseChannel(rssRoot);
Element eChannel = rssRoot.getChild("channel",getRSSNamespace());
List eCats = eChannel.getChildren("category",getRSSNamespace());
channel.setCategories(parseCategories(eCats));
Element eTtl = eChannel.getChild("ttl",getRSSNamespace());
if (eTtl!=null) {
Integer ttlValue = new Integer(eTtl.getText());
if (ttlValue != null) {
channel.setTtl(ttlValue.intValue());
}
}
return channel;
}
示例6: addImagePlanning
import org.jdom.Element; //導入方法依賴的package包/類
public static void addImagePlanning(String dbname, File planningFile) throws Exception {
// create xml reader
SAXBuilder builder = new SAXBuilder();
Document doc;
doc = builder.build(planningFile);
Element atts = doc.getRootElement();
// check format first
if (atts.getName().equalsIgnoreCase("imageplanning")) {
// connect to database
Connection conn = DriverManager.getConnection("jdbc:h2:~/.sumo/" + dbname + ";AUTO_SERVER=TRUE", "sa", "");
Statement stat = conn.createStatement();
String sql = "create table if not exists IMAGEPLAN (IMAGE VARCHAR(255), URL VARCHAR(1024), STARTDATE VARCHAR(255), ENDDATE VARCHAR(255), AREA VARCHAR(1024), ACTION VARCHAR(2048))";
stat.execute(sql);
// clear table before filling it in
stat.execute("DELETE FROM IMAGEPLAN");
// scan through images
for (Object o : atts.getChildren("Image")) {
Element element = (Element) o;
// create sql statement
sql = "INSERT INTO IMAGEPLAN VALUES('" + element.getChildText("name") + "', '" + element.getChildText("url") + "', '" + element.getChildText("startDate") + "', '" + element.getChildText("endDate") + "', '" + element.getChildText("area") + "', '" + element.getChildText("action") + "');";
stat.execute(sql);
}
stat.close();
conn.close();
} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Format not supported", "Error", JOptionPane.ERROR_MESSAGE);
}
});
}
}
示例7: doesNamespaceHavePermissions
import org.jdom.Element; //導入方法依賴的package包/類
private boolean doesNamespaceHavePermissions(Element procElement, String namespace) {
if (namespace == null || namespace.length() == 0) {
return false;
}
List<Element> nspaces = (List<Element>) procElement.getChildren("namespace");
for (Element nsElem : nspaces) {
if (namespace.equalsIgnoreCase(nsElem.getAttributeValue("name"))) {
return true; // the namespace is in the list, so it has at least one permission
}
}
return false;
}
示例8: isVersioningEnabled
import org.jdom.Element; //導入方法依賴的package包/類
private boolean isVersioningEnabled(Element procElement, String namespace) {
if (namespace == null || namespace.length() == 0) {
return false;
}
List<Element> nspaces = (List<Element>) procElement.getChildren("namespace");
for (Element nsElem : nspaces) {
if (namespace.equalsIgnoreCase(nsElem.getAttributeValue("name"))) {
return Boolean.valueOf(nsElem.getAttributeValue("versioningEnabled"));
}
}
return false;
}
示例9: findResourceElements
import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void findResourceElements(Map<String, Element> map, Element elt) {
if(elt.getName().equals("RESOURCE")) {
String className = elt.getChildTextTrim("CLASS");
if(className != null) {
map.put(className, elt);
}
} else {
for(Element child : (List<Element>)elt.getChildren()) {
findResourceElements(map, child);
}
}
}
示例10: processAnnotations
import org.jdom.Element; //導入方法依賴的package包/類
/**
* Process annotations for the given element. If the element is a RESOURCE it
* is processed, otherwise the method calls itself recursively for all the
* children of the given element.
*
* @param element
* the element to process.
*/
@SuppressWarnings("unchecked")
private void processAnnotations(Element element) throws GateException {
if("RESOURCE".equals(element.getName())) {
processAnnotationsForResource(element);
} else {
for(Element child : (List<Element>)element.getChildren()) {
processAnnotations(child);
}
}
}
示例11: readFrom
import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void readFrom(Element rootElement)
/* Is passed an Element by TC, and is expected to load it into the in memory settings object.
* Old settings should be overwritten.
*/
{
Loggers.SERVER.debug("readFrom :: " + rootElement.toString());
CopyOnWriteArrayList<MsTeamsNotificationConfig> configs = new CopyOnWriteArrayList<MsTeamsNotificationConfig>();
if (rootElement.getAttribute(ENABLED) != null){
this.msTeamsNotificationsEnabled = Boolean.parseBoolean(rootElement.getAttributeValue(ENABLED));
}
List<Element> namedChildren = rootElement.getChildren("msteamsNotification");
if(namedChildren.isEmpty())
{
this.msteamsNotificationsConfigs = null;
} else {
for(Element e : namedChildren)
{
MsTeamsNotificationConfig whConfig = new MsTeamsNotificationConfig(e);
Loggers.SERVER.debug(e.toString());
configs.add(whConfig);
Loggers.SERVER.debug(NAME + ":readFrom :: enabled " + String.valueOf(whConfig.getEnabled()));
}
this.msteamsNotificationsConfigs = configs;
}
}
示例12: 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));
}
}
}
示例13: test_ReadXml
import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void test_ReadXml() throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
//builder.setValidation(true);
builder.setIgnoringElementContentWhitespace(true);
Document doc = builder.build("src/test/resources/testdoc1.xml");
Element root = doc.getRootElement();
System.out.println(root.toString());
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();
System.out.println(e.toString() + e.getAttributeValue("url"));
//assertTrue(e.getAttributeValue("url").equals("http://something"));
if(e.getChild("parameters") != null){
Element eParams = e.getChild("parameters");
List<Element> paramsList = eParams.getChildren("param");
for(Iterator<Element> j = paramsList.iterator(); j.hasNext();)
{
Element eParam = j.next();
System.out.println(eParam.toString() + eParam.getAttributeValue("name"));
System.out.println(eParam.toString() + eParam.getAttributeValue("value"));
}
}
}
}
}
}
示例14: checkChannelConstraints
import org.jdom.Element; //導入方法依賴的package包/類
protected void checkChannelConstraints(Element eChannel) throws FeedException {
checkNotNullAndLength(eChannel,"title", 1, 100);
checkNotNullAndLength(eChannel,"description", 1, 500);
checkNotNullAndLength(eChannel,"link", 1, 500);
checkNotNullAndLength(eChannel,"language", 2, 5);
checkLength(eChannel,"rating", 20, 500);
checkLength(eChannel,"copyright", 1, 100);
checkLength(eChannel,"pubDate", 1, 100);
checkLength(eChannel,"lastBuildDate", 1, 100);
checkLength(eChannel,"docs", 1, 500);
checkLength(eChannel,"managingEditor", 1, 100);
checkLength(eChannel,"webMaster", 1, 100);
Element skipHours = eChannel.getChild("skipHours");
if (skipHours!=null) {
List hours = skipHours.getChildren();
for (int i=0;i<hours.size();i++) {
Element hour = (Element) hours.get(i);
int value = Integer.parseInt(hour.getText());
if (isHourFormat24()) {
if (value<1 || value>24) {
throw new FeedException("Invalid hour value "+value+", it must be between 1 and 24");
}
}
else {
if (value<0 || value>23) {
throw new FeedException("Invalid hour value "+value+", it must be between 0 and 23");
}
}
}
}
}
示例15: 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();
}