001: /*
002: * Copyright (C) 2001, 2002 Robert MacGrogan
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: *
019: * $Archive: SourceJammer$
020: * $FileName: Project.java$
021: * $FileID: 4346$
022: *
023: * Last change:
024: * $AuthorName: Rob MacGrogan$
025: * $Date: 8/13/03 12:02 AM$
026: * $Comment: In buildChildrenFromStrings(), add this project's
027: * unique to parent property in generated NodeInfo objects.$
028: *
029: * $KeyWordsOff: $
030: */
031:
032: package org.sourcejammer.project.view;
033:
034: import org.sourcejammer.project.NodeList;
035: import org.sourcejammer.project.NodeIterator;
036: import org.sourcejammer.util.AppConfig;
037: import org.sourcejammer.xml.soap.NodeInfoSerializer;
038: import org.sourcejammer.project.NodeExistsException;
039: import org.sourcejammer.project.Node;
040:
041: /**
042: * Title: SourceJammer v 0.1.0
043: * Description:
044: * Copyright: Copyright (c) 2001
045: * Company:
046: * @author Robert MacGrogan
047: * @version $Revision: 1.3 $
048: */
049:
050: /**
051: * Represents of view of a project within the project hierarchy.
052: */
053: public class Project extends ViewNode {
054:
055: NodeList moChildren = null;
056: private String[] childrenLightweight = null;
057:
058: public Project() {
059: }
060:
061: /**
062: * Set child nodes using an array of NodeInfo objects. This is necesary
063: * for current version of Apache SOAP.
064: *
065: * @exception NodeExistsException if the array contains one or more nodes
066: * with the same nodeName.
067: */
068: public void setChildNodeArray(String[] nodes) {
069: childrenLightweight = nodes;
070: }
071:
072: public void buildChildrenFromStrings() throws NodeExistsException {
073: moChildren = new NodeList();
074: for (int i = 0; i < childrenLightweight.length; i++) {
075: NodeInfo nd = NodeInfoSerializer
076: .stringToNodeInfo(childrenLightweight[i]);
077: nd.setParentID(getUniqueID());
078: moChildren.addNode(nd);
079: }
080: }
081:
082: public String[] getChildNodeArray() {
083: return childrenLightweight;
084: }
085:
086: /**
087: * Make sure this is a NodeList of NodeInfo objects.
088: */
089: public void useChildNodeList(NodeList children) {
090: moChildren = children;
091: }
092:
093: public NodeList childList() {
094: return moChildren;
095: }
096:
097: public NodeIterator childNodes() {
098: return moChildren.getIterator();
099: }
100:
101: public int childCount() {
102: return moChildren.size();
103: }
104:
105: public String toString() {
106: StringBuffer str = new StringBuffer();
107: str.append("Contents of ").append(getNodeName())
108: .append(":\r\n");
109: NodeIterator iterator = moChildren.getIterator();
110: iterator = org.sourcejammer.util.StringUtil
111: .sortNodeIterator(iterator);
112: while (iterator.hasMoreNodes()) {
113: NodeInfo ndInfo = (NodeInfo) iterator.getNextNode();
114: str.append(" ").append(ndInfo.toString()).append("\r\n");
115: }
116: return str.toString();
117: }
118:
119: /**
120: * For testing.
121: */
122: /*
123: public static void main(String args[]){
124: try {
125: Project prj = new Project();
126: NodeName name1 = new NodeName();
127: name1.setName("org");
128: NodeName name2 = new NodeName();
129: name2.setName("sourcejammer");
130: name2.setParent(name1);
131: NodeName name3 = new NodeName();
132: name3.setName("project");
133: name3.setParent(name2);
134: prj.setNodeNameObj(name3);
135:
136: NodeList children = new NodeList();
137:
138: NodeInfo ndController = new NodeInfo();
139: ndController.setNodeName("controller");
140: ndController.setCreatedDate(new java.util.Date());
141: ndController.setNodeType(AppConfig.NodeTypes.PROJECT);
142: children.addNode(ndController);
143:
144: NodeInfo ndModel = new NodeInfo();
145: ndModel.setNodeName("model");
146: ndModel.setCreatedDate(new java.util.Date());
147: ndModel.setNodeType(AppConfig.NodeTypes.PROJECT);
148: children.addNode(ndModel);
149:
150: NodeInfo ndView = new NodeInfo();
151: ndView.setNodeName("view");
152: ndView.setCreatedDate(new java.util.Date());
153: ndView.setNodeType(AppConfig.NodeTypes.PROJECT);
154: children.addNode(ndView);
155:
156: NodeInfo ndArch = new NodeInfo();
157: ndArch.setNodeName("ArchiveInfo.java");
158: ndArch.setNodeType(AppConfig.NodeTypes.FILE);
159: ndArch.setCreatedDate(new java.util.Date());
160: ndArch.setCheckedOut(false);
161: ndArch.setFileType(AppConfig.FileTypes.BINARY);
162: children.addNode(ndArch);
163:
164: NodeInfo ndNode = new NodeInfo();
165: ndNode.setNodeName("Node.java");
166: ndNode.setNodeType(AppConfig.NodeTypes.FILE);
167: ndNode.setCreatedDate(new java.util.Date());
168: ndNode.setCheckedOut(true);
169: ndNode.setFileType(AppConfig.FileTypes.BINARY);
170: children.addNode(ndNode);
171:
172: NodeInfo ndNodeIt = new NodeInfo();
173: ndNodeIt.setNodeName("NodeIterator.java");
174: ndNodeIt.setNodeType(AppConfig.NodeTypes.FILE);
175: ndNodeIt.setCreatedDate(new java.util.Date());
176: ndNodeIt.setCheckedOut(false);
177: ndNodeIt.setFileType(AppConfig.FileTypes.TEXT);
178: children.addNode(ndNodeIt);
179:
180: prj.setChildNodeList(children);
181:
182: System.out.println(prj.toString());
183: }
184: catch (Exception ex){
185: ex.printStackTrace();
186: }
187: }
188: */
189: }
|