Source code: com/aendvari/common/model/ModelTree.java
1 /*
2 * ModelTree.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.common.model;
11
12 import java.util.List;
13
14 import java.io.InputStream;
15
16
17 /**
18 * <p>The <code>ModelTree</code> interface represents a XML DOM or OSM implementation.
19 * Typically the implementation would include a reference to the OSM or DOM (XML) object,</p>
20 *
21 * @author Scott Milne
22 *
23 */
24
25 public interface ModelTree
26 {
27 /**
28 * Creates a {@link ModelNode} object.
29 *
30 * @param name The node's name.
31 *
32 * @return A new {@link ModelNode} object.
33 *
34 */
35
36 public ModelNode createNode(String name);
37
38 /**
39 * Creates a {@link ModelNode} object with the supplied value.
40 *
41 * @param name The node's name.
42 * @param value The node's value.
43 *
44 * @return A new {@link ModelNode} object.
45 *
46 */
47
48 public ModelNode createNode(String name, String value);
49
50 /**
51 * Creates a new {@link ModelTree} object.
52 *
53 * @return A new {@link ModelTree} object.
54 *
55 */
56
57 public ModelTree createTree();
58
59 /**
60 * Returns the {@link ModelNode} using the path provided.
61 *
62 * @param node The starting position for the search.
63 * @param path The query expression.
64 *
65 * @return A {@link ModelNode} using the path provided.
66 *
67 * @exception ModelException The search could not be performed.
68 *
69 */
70
71 public ModelNode getNode( ModelNode node, String path ) throws ModelException;
72
73 /**
74 * Returns an <code>List</code> of {@link ModelNode}'s using the path provided.
75 *
76 * @param node The starting position for the search.
77 * @param path The query expression.
78 *
79 * @return A <code>List</code> of {@link ModelNode}'s using the path provided.
80 *
81 * @exception ModelException The search could not be performed.
82 *
83 */
84
85 public List getNodes( ModelNode node, String path ) throws ModelException;
86
87 /**
88 * Returns the {@link ModelNode} of the DOM/OSM model space.
89 *
90 * @return A {@link ModelNode} representing the Document
91 * of a DOM or the root node for an OSM.
92 *
93 */
94
95 public ModelNode getRootNode();
96
97 /**
98 * Replaces the current <code>ModelTree</code> with data prodivided by the file.
99 *
100 * @param file A path to the file.
101 *
102 * @exception ModelException The operation could not be performed.
103 *
104 */
105
106 public void loadFromFile( String file ) throws ModelParserException;
107
108 /**
109 * Replaces the current <code>ModelTree</code> with the given XML stream.
110 *
111 * @param xmlFile An {@link java.io.InputStream} instance.
112 *
113 * @exception ModelException The operation could not be performed.
114 *
115 */
116
117 public void loadFromStream( InputStream stream ) throws ModelParserException;
118 }
119