aboutsummaryrefslogtreecommitdiff
path: root/basebuilder-3.6.2/org.eclipse.releng.basebuilder/plugins/org.eclipse.build.tools/src_rss/org/eclipse/releng/generators/rss/RSSFeedGetPropertyTask.java
blob: b8f485547832d7526969151e3897d305288d74a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.releng.generators.rss;

import java.io.File;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import org.eclipse.releng.util.rss.Messages;
import org.eclipse.releng.util.rss.RSSFeedUtil;

/**
 * Parameters: 
 *   debug - more output to console - eg., 0|1|2
 *   
 *   file - path to the XML file that will be read - eg., /path/to/file.to.read.xml
 *   xpath - xpath string representing the object to read
 * 
 * @author nickb
 *
 */
public class RSSFeedGetPropertyTask extends Task {

  private int debug = 0;

  //required fields
  private File file;

  private String xpath;

  //optional
  public void setDebug(int debug) { this.debug = debug; }

  //required fields
  public void setFile(String file) { 
    if (isNullString(file))
    { System.err.println(Messages.getString("RSSFeedCommon.FileError")); } //$NON-NLS-1$
    else
    { this.file = new File(file); } 
  }
  public void setXpath(String xpath) { 
    if (isNullString(xpath))
    { System.err.println(Messages.getString("RSSFeedCommon.XpathError")); } //$NON-NLS-1$
    else
    { this.xpath = xpath; } 
  }

  // The method executing the task
  public void execute() throws BuildException {
    RSSFeedUpdateEntryTask updater = new RSSFeedUpdateEntryTask();
    updater.setFile(file.toString());
    updater.setXpath(xpath);
    updater.setDebug(debug);
    updater.execute();
  }

  private static boolean isNullString(String str)
  {
    return RSSFeedUtil.isNullString(str);
  }

}