1
- package org . vast . stt . data ;
2
-
3
- import java . util . ArrayList ;
4
- import java . util . Hashtable ;
5
- import java . util . List ;
6
-
7
- import org . vast . cdm . common . DataComponent ;
8
- import org . vast . data . DataArray ;
9
- import org . vast . data . DataGroup ;
10
- import org . vast . data . DataValue ;
11
-
12
-
13
- /**
14
- * <p><b>Title:</b><br/>
15
- * Data Node
16
- * </p>
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
+ *
5
+ * Software distributed under the License is distributed on an "AS IS" basis,
6
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
+ * for the specific language governing rights and limitations under the License.
8
+ *
9
+ * The Initial Developer is Terravolv, Inc. Portions created by the Initial
10
+ * Developer are Copyright (C) 2014-2015 the Initial Developer. All Rights Reserved.
17
11
*
18
- * <p><b>Description:</b><br/>
19
- * TODO DataNode type description
20
- * </p>
12
+ * The Original Code is the "Space Time Toolkit".
21
13
*
22
- * <p>Copyright (c) 2007</p>
23
- * @author Alexandre Robin
24
- * @date Apr 1, 2006
25
- * @version 1.0
14
+ * The Initial Developer of the Original Code is the VAST team at the
15
+ * University of Alabama in Huntsville (UAH). <http://vast.uah.edu>
16
+ * Portions created by the Initial Developer are Copyright (C) 2007
17
+ * the Initial Developer. All Rights Reserved.
26
18
*/
27
- public class DataNode
28
- {
29
- protected List < String > possibleScalarMappings;
30
- protected List< String > possibleBlockMappings;
31
- protected Hashtable< String , BlockList > listMap;
32
- protected ArrayList< BlockList > listArray;
33
- protected boolean nodeStructureReady;
34
-
35
-
36
- public DataNode()
37
- {
38
- possibleScalarMappings = new ArrayList < String > ( ) ;
39
- possibleBlockMappings = new ArrayList < String > ( ) ;
40
- listMap = new Hashtable < String , BlockList > ( 1 ) ;
41
- listArray = new ArrayList < BlockList > ( 1 ) ;
42
- }
43
-
44
-
45
- public ArrayList< BlockList > getListArray()
46
- {
47
- return listArray ;
48
- }
49
-
50
-
51
- public BlockList createList(DataComponent component)
52
- {
53
- BlockList newList = new BlockList ( ) ;
54
- newList . setBlockStructure ( component ) ;
55
- listMap . put ( component . getName ( ) , newList ) ;
56
- listArray . add ( newList ) ;
57
- rebuildMappings ( component ) ;
58
- component . clearData ( ) ;
59
- return newList ;
60
- }
61
-
62
-
63
- public BlockList getList(String name)
64
- {
65
- return listMap . get ( name ) ;
66
- }
67
-
68
-
69
- public void removeList(String name)
70
- {
71
- BlockList list = listMap . remove ( name ) ;
72
- listArray . remove ( list ) ;
73
- }
74
-
75
-
76
- public void clearList(String name)
77
- {
78
- listMap . get ( name ) . clear ( ) ;
79
- }
80
-
81
-
82
- public void clearAll()
83
- {
84
- for ( int i = 0 ; i < listArray . size ( ) ; i ++ )
85
- listArray . get ( i ) . clear ( ) ;
86
- }
87
-
88
-
89
- public boolean hasData()
90
- {
91
- for ( int i = 0 ; i < listArray . size ( ) ; i ++ )
92
- if ( listArray . get ( i ) . getSize ( ) > 0 )
93
- return true ;
94
-
95
- return false ;
96
- }
97
-
98
-
99
- public void rebuildMappings(DataComponent component)
100
- {
101
- possibleScalarMappings . clear ( ) ;
102
- possibleBlockMappings . clear ( ) ;
103
- findPossibleMappings ( component , component . getName ( ) ) ;
104
- }
105
-
106
-
107
- private void findPossibleMappings(DataComponent component, String componentPath)
108
- {
109
- // for each array, build an array mapper
110
- if ( component instanceof DataArray )
111
- {
112
- possibleBlockMappings . add ( componentPath ) ;
113
- DataComponent childComponent = ( ( DataArray ) component ) . getArrayComponent ( ) ;
114
- String childPath = componentPath + '/' + childComponent . getName ( ) ;
115
- findPossibleMappings ( childComponent , childPath ) ;
116
- }
117
-
118
- // just descend into DataGroups
119
- else if (component instanceof DataGroup)
120
- {
121
- possibleBlockMappings . add ( componentPath ) ;
122
- for ( int i = 0 ; i < component . getComponentCount ( ) ; i ++ )
123
- {
124
- DataComponent childComponent = component . getComponent ( i ) ;
125
- String childPath = componentPath + '/' + childComponent . getName ( ) ;
126
- findPossibleMappings ( childComponent , childPath ) ;
127
- }
128
- }
129
-
130
- // handle DataValues
131
- else if ( component instanceof DataValue )
132
- {
133
- possibleScalarMappings . add ( componentPath ) ;
134
- }
135
- }
136
19
20
+ /**
21
+ * @date June 4, 2015
22
+ * @public
23
+ */
137
24
138
- public List < String > getPossibleBlockMappings()
139
- {
140
- return possibleBlockMappings ;
25
+ var DataNode = function ( ) {
26
+
27
+ // Private
28
+ var _possibleScalarMappings = [ ] ;
29
+ var _possibleBlockMappings = [ ] ;
30
+ var _listMap = { } ;
31
+ var _nodeStructureReady = false ;
32
+
33
+ this . createList = function ( component ) {
34
+ var newList = new BlockList ( ) ;
35
+ newList . setBlockStructure ( component ) ;
36
+ _listMap [ component . getName ( ) ] = newList ;
37
+ rebuildMappings ( component ) ;
38
+ component . clearData ( ) ;
39
+ return newList ;
40
+ }
41
+
42
+ this . getList = function ( name ) {
43
+ return _listMap [ name ] ;
44
+ }
45
+
46
+ this . removeList = function ( name ) {
47
+ delete _listMap [ name ] ;
48
+ }
49
+
50
+ public void clearList ( name ) {
51
+ _listMap [ name ] = null ;
52
+ }
53
+
54
+ this . hasData = function ( ) {
55
+ for ( var member in _listMap ) {
56
+ if ( null !== member ) {
57
+ return true ;
58
+ }
141
59
}
142
-
143
-
144
- public List< String > getPossibleScalarMappings()
145
- {
146
- return possibleScalarMappings ;
60
+ return false ;
61
+ }
62
+
63
+ this . rebuildMappings = function ( component ) {
64
+ possibleScalarMappings . length = 0 ;
65
+ possibleBlockMappings . length = 0 ;
66
+ findPossibleMappings ( component , component . getName ( ) ) ;
67
+ }
68
+
69
+ this . findPossibleMappings = function ( component , componentPath ) {
70
+ // for each array, build an array mapper
71
+ if ( component instanceof DataArray ) {
72
+ possibleBlockMappings . push ( componentPath ) ;
73
+ var childComponent = component . getArrayComponent ( ) ;
74
+ var childPath = componentPath + '/' + childComponent . getName ( ) ;
75
+ findPossibleMappings ( childComponent , childPath ) ;
76
+ } else if ( component instanceof DataGroup ) {
77
+ possibleBlockMappings . push ( componentPath ) ;
78
+ for ( int i = 0 ; i < component . getComponentCount ( ) ; i ++ ) {
79
+ var childComponent = component . getComponent ( i ) ;
80
+ var childPath = componentPath + '/' + childComponent . getName ( ) ;
81
+ findPossibleMappings ( childComponent , childPath ) ;
82
+ }
83
+ } else if ( component instanceof DataValue ) {
84
+ possibleScalarMappings . push ( componentPath ) ;
147
85
}
86
+ }
148
87
88
+ this . getPossibleBlockMappings = function ( ) {
89
+ return _possibleBlockMappings ;
90
+ }
149
91
150
- public boolean isNodeStructureReady()
151
- {
152
- return nodeStructureReady ;
153
- }
92
+ this . getPossibleScalarMappings = function ( ) {
93
+ return _possibleScalarMappings ;
94
+ }
154
95
96
+ public boolean isNodeStructureReady ( ) {
97
+ return _nodeStructureReady ;
98
+ }
99
+
100
+ this . setNodeStructureReady = function ( nodeStructureReady ) {
101
+ _nodeStructureReady = nodeStructureReady ;
102
+ }
155
103
156
- public void setNodeStructureReady(boolean nodeStructureReady)
157
- {
158
- this . nodeStructureReady = nodeStructureReady ;
159
- }
160
104
}
0 commit comments