com.ibm.sbt.playground.assets.RootNode Maven / Gradle / Ivy
/*
* Copyright IBM Corp. 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.ibm.sbt.playground.assets;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.ibm.commons.util.StringUtil;
import com.ibm.sbt.playground.dojo.JsonTreeRenderer;
import com.ibm.sbt.playground.vfs.VFSFile;
/**
* Definition of a root node.
*/
public class RootNode extends CategoryNode {
public RootNode() {
super(null,"");
}
public Asset loadAsset(VFSFile root, String unid) throws IOException {
AssetNode n = findAsset(this, unid);
if(n!=null) {
return n.load(root);
}
return null;
}
private AssetNode findAsset(Node parent, String unid) {
if(parent instanceof AssetNode) {
AssetNode sn = (AssetNode)parent;
if(StringUtil.equals(sn.getUnid(), unid)) {
return sn;
}
} else if(parent instanceof CategoryNode) {
CategoryNode cn = (CategoryNode)parent;
List children = cn.getChildren();
for(int i=0; i getAllChildrenFlat() {
ArrayList nodes = new ArrayList();
List children = getChildren();
for(int i=0; i nodes, Node node) {
nodes.add(node);
if(node instanceof CategoryNode) {
CategoryNode cn = (CategoryNode)node;
List children = cn.getChildren();
for(int i=0; i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy