本文整理匯總了Java中nu.xom.Element.getChildElements方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getChildElements方法的具體用法?Java Element.getChildElements怎麽用?Java Element.getChildElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nu.xom.Element
的用法示例。
在下文中一共展示了Element.getChildElements方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTagList
import nu.xom.Element; //導入方法依賴的package包/類
public static String getTagList(Project pjr){
try {
String filepath = FileStorage.JN_DOCPATH + ".projects";
Builder builder = new Builder();
Document projects = builder.build(new InputStreamReader(new FileInputStream(filepath)), "UTF-8");
String taglist="";
Elements prjs = projects.getRootElement().getChildElements("project");
for (int i = 0; i < prjs.size(); i++) {
String pid = ((Element) prjs.get(i)).getAttribute("id").getValue();
if (pid.equals(pjr.getID())){
Element tags=prjs.get(i).getFirstChildElement("tags");
Elements tagli=tags.getChildElements("tag");
if (tagli.size()<=0) return "no";
for (int j = 0; j < tagli.size(); j++) {
taglist+=tagli.get(j).getAttributeValue("name")+" - ";
}
break;
}
}
return taglist;
} catch (Exception e) {
Util.error(e);
return "no";
}
}
示例2: addTag
import nu.xom.Element; //導入方法依賴的package包/類
@Override
public boolean addTag(String tag) {
Element tagsNode = _root.getFirstChildElement("tags");
// check if tag already exists
Elements tags = tagsNode.getChildElements();
for (int i = 0; i < tags.size(); i++) {
if (tags.get(i).getAttributeValue("name").equals(tag)) {
return false;
}
}
Element tagNode = new Element("tag");
tagNode.addAttribute(new Attribute("name",tag));
tagsNode.appendChild(tagNode);
return true;
}
示例3: getDay
import nu.xom.Element; //導入方法依賴的package包/類
public Element getDay(CalendarDate date, Element month) {
Element day = null;
Elements days = month.getChildElements("day");
if (days.size() == 0) {
return null;
}
else {
for (int i = 0; i < days.size(); i++) {
if (Integer.parseInt(days.get(i).getAttributeValue("day").toString()) == date.getDay()) {
day = days.get(i);
break;
}
}
}
return day;
}
示例4: getActualLocForProject
import nu.xom.Element; //導入方法依賴的package包/類
public static int getActualLocForProject(String targetid, Element rootElement) {
Elements projectElements = rootElement.getChildElements(PSP.ELEMENT_NAME);
Element projectElement = null;
Element locElement = null;
int value = 0;
if (projectElements != null) {
for (int i = 0; i < projectElements.size(); i++) {
String projectid = projectElements.get(i).getAttributeValue(PSP.ID_ATTRIBUTE);
if (projectid.equals(targetid)) {
projectElement = projectElements.get(i);
locElement = projectElement.getFirstChildElement(ELEMENT_NAME);
try {
value = Integer.valueOf(locElement.getValue());
}
catch (Exception ex) {
// do nothing here
}
}
}
}
return value;
}
示例5: buildElements
import nu.xom.Element; //導入方法依賴的package包/類
private void buildElements(Element parent) {
Elements els = parent.getChildElements("task");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
elements.put(el.getAttribute("id").getValue(), el);
buildElements(el);
}
}
示例6: getRepeatableEvents
import nu.xom.Element; //導入方法依賴的package包/類
public static Collection getRepeatableEvents() {
Vector v = new Vector();
Element rep = _root.getFirstChildElement("repeatable");
if (rep == null)
return v;
Elements els = rep.getChildElements("event");
for (int i = 0; i < els.size(); i++)
v.add(new EventImpl(els.get(i)));
return v;
}
示例7: getMimeTypeByExt
import nu.xom.Element; //導入方法依賴的package包/類
public static MimeType getMimeTypeByExt(String ext) {
Elements els = _root.getChildElements("mime-type");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
Elements exts = el.getChildElements("ext");
for (int j = 0; j < exts.size(); j++)
if (exts.get(j).getValue().toLowerCase().equals(ext.toLowerCase()))
return new MimeType(el);
}
return new MimeType();
}
示例8: getHomeElement
import nu.xom.Element; //導入方法依賴的package包/類
protected static Element getHomeElement(Element homeProject, String listElement, String idElement, String targetId) {
Element target = null;
Element homeList = homeProject.getFirstChildElement(listElement);
Elements homeYears = homeList.getChildElements();
for (int yearIndex = 0; yearIndex < homeYears.size(); yearIndex++) {
Element homeYearElement = homeYears.get(yearIndex);
String homeYear = homeYearElement.getAttributeValue("year");
Elements homeMonths = homeYearElement.getChildElements();
for (int monthIndex = 0; monthIndex < homeMonths.size(); monthIndex++) {
Element homeMonthElement = homeMonths.get(monthIndex);
String homeMonth = homeMonthElement.getAttributeValue("month");
Elements homeDays = homeMonthElement.getChildElements();
for (int dayIndex = 0; dayIndex < homeDays.size(); dayIndex++) {
Element homeDayElement = homeDays.get(dayIndex);
String homeDay = homeDayElement.getAttributeValue("day");
String homeDate = homeDayElement.getAttributeValue("date");
Elements homeLogs = homeDayElement.getChildElements();
for (int i = 0; i < homeLogs.size(); i++) {
Element homeLog = homeLogs.get(i);
String homeId = homeLog.getAttributeValue(idElement);
if (homeId.equals(targetId)) {
target = homeLog;
}
}
}
}
}
return target;
}
示例9: buildElements
import nu.xom.Element; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void buildElements(Element parent) {
Elements els = parent.getChildElements("task");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
elements.put(el.getAttribute("id").getValue(), el);
buildElements(el);
}
}
示例10: buildElements
import nu.xom.Element; //導入方法依賴的package包/類
private void buildElements(Element parent) {
Elements els = parent.getChildElements("task");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
elements.put(el.getAttribute("id").getValue(), el);
buildElements(el);
}
}
示例11: getAllSubTasks
import nu.xom.Element; //導入方法依賴的package包/類
/**
* All methods to obtain list of tasks are consolidated under getAllSubTasks and getActiveSubTasks.
* If a root task is required, just send a null taskId
*/
public Collection getAllSubTasks(String commitId) {
if ((commitId == null) || (commitId.length() == 0)) {
return getAllRootTasks();
}
else {
Element task = getTaskElement(commitId);
if (task == null)
return new Vector();
Elements subTasks = task.getChildElements("task");
return convertToTaskObjects(subTasks);
}
}
示例12: buildElements
import nu.xom.Element; //導入方法依賴的package包/類
private void buildElements(Element parent) {
Elements els = parent.getChildElements("timelog");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
elements.put(el.getAttribute("id").getValue(), el);
buildElements(el);
}
}
示例13: buildElements
import nu.xom.Element; //導入方法依賴的package包/類
private void buildElements(Element parent) {
Elements els = parent.getChildElements("commit");
for (int i = 0; i < els.size(); i++) {
Element el = els.get(i);
elements.put(el.getAttribute("id").getValue(), el);
buildElements(el);
}
}
示例14: getDaysEvents
import nu.xom.Element; //導入方法依賴的package包/類
private ArrayList<DTDEvent> getDaysEvents(CalendarDate date) {
ArrayList<DTDEvent> ret = new ArrayList<DTDEvent>();
Element tmp;
Elements tmps;
// System.out.println("goin in");
tmp = getYear(date);
if (tmp == null) {
System.out.println("getDaysEvents year");
return ret;
}
tmp = getMonth(date, tmp);
if (tmp == null) {
System.out.println("getDaysEvents month");
return ret;
}
tmp = getDay(date, tmp);
if (tmp == null) {
System.out.println("getDaysEvents day");
return ret;
}
tmps = tmp.getChildElements("event");
if (tmps == null) {
System.out.println("getDaysEvents events");
return ret;
}
try {
for (int i = 0; i < tmps.size(); i++) {
ret.add(new DTDEvent(date, Integer.parseInt(tmps.get(i).getAttributeValue("hour")),
Integer.parseInt(tmps.get(i).getAttributeValue("minute")), tmps.get(i).getAttributeValue("message"),
parseBool(tmps.get(i).getAttributeValue("reminder")), tmps.get(i).getAttributeValue("email")));
}
System.out.println("size of ret" + ret.size());
}
catch (Exception e) {
e.printStackTrace();
System.out.println("getDaysEvents Exception");
return null;
}
return ret;
}
示例15: upgrade1_1d1
import nu.xom.Element; //導入方法依賴的package包/類
private static void upgrade1_1d1(String[] projectIds) {
for (int i = 0; i < projectIds.length; i++) {
Util.debug("Upgrading project " + projectIds[i] + " from version 1.0 to version 1.1d1");
String filePath = FileStorage.JN_DOCPATH + projectIds[i] + File.separator + ".tasklist";
Document doc = FileStorage.openDocument(filePath);
Element root = doc.getRootElement();
Elements tasks = root.getChildElements("task");
for (int j = 0; j < tasks.size(); j++) {
Element task = tasks.get(j );
// Decided not to change the date format after all but I'm leaving this code here
// in case we need it later. Ryan
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//
// Attribute startDateAttr = task.getAttribute("startDate");
// Date startDate = (new CalendarDate(startDateAttr.getValue(),"/")).getDate();
// startDateAttr.setValue(sdf.format(startDate));
//
// Attribute endDateAttr = task.getAttribute("endDate");
// if (endDateAttr != null) {
// Date endDate = (new CalendarDate(endDateAttr.getValue(),"/")).getDate();
// endDateAttr.setValue(sdf.format(endDate));
// }
Attribute parentAttr = task.getAttribute("parent");
if ((parentAttr == null) || (parentAttr.getValue() == "")) {
// no parent, do nothing here
}
else {
// put the task under the parent task
String parentId = parentAttr.getValue();
for (int k = 0; k < tasks.size(); k++) {
Element potentialParent = tasks.get(k);
if(parentId.equals(potentialParent.getAttribute("id").getValue())) {
// found parent, put self under it
task.removeAttribute(parentAttr);
task.detach();
potentialParent.appendChild(task);
}
}
}
}
doc.setDocType(getCurrentDocType());
FileStorage.saveDocument(doc,filePath);
}
}