Back to project page sodf.
The source code is released under:
Copyright (c) 2013 Lorenz Lehmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...
If you think the Android project sodf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package lal.sodf.framework.ontology; //ww w .j a v a 2 s.co m import lal.sodf.framework.parser.SodfParser; public class SodfTree { /** The root of the tree, i.e. the object itself */ private KeyNode root; /** * Build a SODF description tree * @param serialization The textual representation of the tree */ public SodfTree(String serialization){ //generate a new tree and set this trees root to the generated trees root root = SodfParser.deserializeTree(serialization).getRoot(); } /** * Creates an empty SODF tree with the properties, functions, and metadata children */ public SodfTree(){ //create a node with no content and no parent as root root = new KeyNode(""); root.addChild(new PropertiesNode(root)); root.addChild(new FunctionsNode(root)); root.addChild(new MetadataNode(root)); } /** Return the root of this SODF tree, i.e. the realworld object */ public KeyNode getRoot(){ return root; } /** Set the root of the tree */ public void setRoot(KeyNode kn){ root = kn; } /** * Get the subtree that contains all the properties * @return The properties subtree or null if the subtree does not exist */ public PropertiesNode getPropertiesSubtree(){ for (Node n : root.getChildren()){ if (n instanceof PropertiesNode) return (PropertiesNode) n; } //if the properties subtree was not found return null return null; } /** * Get the subtree that contains all the functions * @return The functions subtree or null if the subtree does not exist */ public FunctionsNode getFunctionsSubtree(){ for (Node n : root.getChildren()){ if (n instanceof FunctionsNode) return (FunctionsNode) n; } //if the functions subtree was not found return null return null; } /** * Get the subtree that contains all the metadata * @return The metadata subtree or null if the subtree does not exist */ public MetadataNode getMetadataSubtree(){ for (Node n : root.getChildren()){ if (n instanceof MetadataNode) return (MetadataNode) n; } //if the metadata subtree was not found return null return null; } /** Get the serialized version of the SODF ontology */ public String getSerialization(){ return SodfParser.serializeTree(this); } }