KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > node > OtterNodeFactory


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22 package org.enhydra.kelp.common.node;
23
24 // Kelp imports
25
import org.enhydra.kelp.common.importer.ImportTool;
26 import org.enhydra.kelp.common.importer.ImportPaths;
27
28 // Standard imports
29
import java.io.File JavaDoc;
30
31 /**
32  * Interface declaration
33  *
34  *
35  * @author Paul Mahar
36  */

37 public abstract class OtterNodeFactory {
38
39     /**
40      * Method declaration
41      *
42      *
43      * @param node
44      * @param name
45      *
46      * @return
47      *
48      */

49     abstract public OtterFolderNode createFolderNode(OtterNode node,
50             String JavaDoc name);
51
52     /**
53      * Method declaration
54      *
55      *
56      * @param node
57      * @param file
58      *
59      * @return
60      */

61     abstract public OtterDocumentNode createDocumentNode(OtterNode node,
62             String JavaDoc file);
63
64     /**
65      * Method declaration
66      *
67      *
68      * @param node
69      * @param file
70      *
71      * @return
72      */

73     abstract public OtterImageFileNode createImageFileNode(OtterNode node,
74             String JavaDoc file);
75
76     /**
77      * Method declaration
78      *
79      *
80      * @param node
81      * @param file
82      *
83      * @return
84      */

85     abstract public OtterJavaFileNode createJavaFileNode(OtterNode node,
86             String JavaDoc file);
87
88     /**
89      * Method declaration
90      *
91      *
92      * @param node
93      * @param file
94      *
95      * @return
96      */

97     abstract public OtterTextFileNode createTextFileNode(OtterNode node,
98             String JavaDoc file);
99
100     /**
101      * Method declaration
102      *
103      *
104      * @param node
105      * @param file
106      *
107      * @return
108      */

109     abstract public OtterTemplateNode createTemplateNode(OtterNode node,
110             String JavaDoc file);
111
112     abstract public OtterTemplateNode getTemplateNode(OtterNode node);
113
114
115     /**
116      * Method declaration
117      *
118      *
119      * @param project
120      * @param node
121      * @param file
122      *
123      * @return
124      */

125     abstract public OtterJavaFileNode[] replaceGeneratedSource(OtterProject project,
126             OtterNode node, String JavaDoc[] files);
127
128     //
129
//
130
public void importFile(OtterProject project, File JavaDoc newFile) {
131         File JavaDoc source = null;
132         File JavaDoc[] files = new File JavaDoc[1];
133         ImportPaths paths = null;
134         ImportTool tool = null;
135
136         files[0] = newFile;
137         source = new File JavaDoc(project.getSourcePathArray()[0]);
138         if (!source.exists()) {
139             source = new File JavaDoc(project.getRootPath());
140         }
141         paths = new ImportPaths();
142         tool = new ImportTool();
143         try {
144             paths.setSourcePath(source.getAbsolutePath());
145         } catch (Exception JavaDoc e) {
146             e.printStackTrace();
147         }
148         paths.setDeployRootPath(project.getDeployRootPath());
149         paths.setProject(project);
150         tool.setPaths(paths);
151         tool.addFiles(files);
152     }
153
154 }
155
Popular Tags