KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > ant > TwoNodesTask


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: TwoNodesTask.java 42616 2004-03-03 12:56:33Z gregor $ */
19
20 package org.apache.lenya.cms.ant;
21
22 import org.apache.lenya.cms.publication.SiteTreeException;
23 import org.apache.tools.ant.BuildException;
24
25
26 /**
27  * Abstract base class for Ant tasks, which manipulates two nodes.
28  * The first node corresponds to the document with id firstdocumentid
29  * and the area firstarea.
30  * The 2nd node corresponds to the document with id secdocumentid
31  * and the area secarea.
32  */

33 public abstract class TwoNodesTask extends PublicationTask {
34     private String JavaDoc firstarea;
35     private String JavaDoc firstdocumentid;
36     private String JavaDoc secarea;
37     private String JavaDoc secdocumentid;
38
39     /**
40      * Creates a new instance of TwoNodesTask
41      */

42     public TwoNodesTask() {
43         super();
44     }
45
46     /**
47      * @return String The area of the document of the first node.
48      */

49     public String JavaDoc getFirstarea() {
50         return firstarea;
51     }
52
53     /**
54      * @return String The document-id corresponding to the first node.
55      */

56     public String JavaDoc getFirstdocumentid() {
57         return firstdocumentid;
58     }
59
60     /**
61      * @return String The area of the document of the second node.
62      */

63     public String JavaDoc getSecarea() {
64         return secarea;
65     }
66
67     /**
68      * @return String The document-id corresponding to the second node.
69      */

70     public String JavaDoc getSecdocumentid() {
71         return secdocumentid;
72     }
73
74     /**
75      * @param string The area of the document of the first node.
76      */

77     public void setFirstarea(String JavaDoc string) {
78         firstarea = string;
79     }
80
81     /**
82      * @param string The document-id corresponding to the first node.
83      */

84     public void setFirstdocumentid(String JavaDoc string) {
85         firstdocumentid = string;
86     }
87
88     /**
89      * @param string The area of the document of the second node.
90      */

91     public void setSecarea(String JavaDoc string) {
92         secarea = string;
93     }
94
95     /**
96      * @param string The document-id corresponding to the second node.
97      */

98     public void setSecdocumentid(String JavaDoc string) {
99         secdocumentid = string;
100     }
101
102     /**
103      * To be overriden.
104      * Manipulation of two nodes .
105      * @param firstdocumentid : id of the first document
106      * @param secdocumentid : id of the second document
107      * @param firstarea : area of the tree of the first node
108      * @param secarea : area of the tree of the 2nd node
109      *
110      * @throws SiteTreeException if an error occurs
111      */

112     public abstract void manipulateTree(String JavaDoc firstdocumentid, String JavaDoc secdocumentid,
113         String JavaDoc firstarea, String JavaDoc secarea)
114         throws SiteTreeException;
115
116     /** (non-Javadoc)
117      * @see org.apache.tools.ant.Task#execute()
118      */

119     public void execute() throws BuildException {
120         try {
121             log("document-id corresponding to the first node: " + this.getFirstdocumentid());
122             log("document-id corresponding to the second node: " + this.getSecdocumentid());
123             log("area corresponding to the first node: " + this.getFirstarea());
124             log("area corresponding to the second node: " + this.getSecarea());
125             manipulateTree(getFirstdocumentid(), getSecdocumentid(), getFirstarea(), getSecarea());
126         } catch (Exception JavaDoc e) {
127             throw new BuildException(e);
128         }
129     }
130 }
131
Popular Tags