1 /******************************************************************************* 2 * Copyright (c) 2005, 2006 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.releng.generators.rss; 12 13 import java.io.File; 14 15 import org.apache.tools.ant.BuildException; 16 import org.apache.tools.ant.Task; 17 18 import org.eclipse.releng.util.rss.Messages; 19 import org.eclipse.releng.util.rss.RSSFeedUtil; 20 21 /** 22 * Parameters: 23 * debug - more output to console - eg., 0|1|2 24 * 25 * file - path to the XML file that will be read - eg., /path/to/file.to.read.xml 26 * xpath - xpath string representing the object to read 27 * 28 * @author nickb 29 * 30 */ 31 public class RSSFeedGetPropertyTask extends Task { 32 33 private int debug = 0; 34 35 //required fields 36 private File file; 37 38 private String xpath; 39 40 //optional setDebug(int debug)41 public void setDebug(int debug) { this.debug = debug; } 42 43 //required fields setFile(String file)44 public void setFile(String file) { 45 if (isNullString(file)) 46 { System.err.println(Messages.getString("RSSFeedCommon.FileError")); } //$NON-NLS-1$ 47 else 48 { this.file = new File(file); } 49 } setXpath(String xpath)50 public void setXpath(String xpath) { 51 if (isNullString(xpath)) 52 { System.err.println(Messages.getString("RSSFeedCommon.XpathError")); } //$NON-NLS-1$ 53 else 54 { this.xpath = xpath; } 55 } 56 57 // The method executing the task execute()58 public void execute() throws BuildException { 59 RSSFeedUpdateEntryTask updater = new RSSFeedUpdateEntryTask(); 60 updater.setFile(file.toString()); 61 updater.setXpath(xpath); 62 updater.setDebug(debug); 63 updater.execute(); 64 } 65 isNullString(String str)66 private static boolean isNullString(String str) 67 { 68 return RSSFeedUtil.isNullString(str); 69 } 70 71 }