Java Reference
In-Depth Information
this
.features
#
features;
}
public
String name() {
return
name; }
public
String value(String featureName){
// iterates over the features to find the value of the
// given one
for
(
int
i
#
0; i<features.length;
!!
i){
if
(featureName.equals(features[i].name())){
return
features[i].value();
}
}
return null
;
}
public
void setValue(String featureName, String newValue){
for
(
int
i
#
0; i<features.length;
!!
i){
if
(featureName.equals(features[i].name())){
features[i].value(newValue);
return
;
}
}
}
}
The structure of the decision tree is described by means of the classes
Node
and
Arc
. Class
Node
has a read-only attribute (
label
) and is involved in
the one-to-many association children. Since the number of objects is not
known
a priori
it is not possible to use an array. We can implement the
association applying the transformation shown in Figure 4.8. The trans-
formed association can be easily implemented with a reference in the class
One plus a reference in the Many class: in total one attribute per class. This
is a standard way of implementing such associations and can be coded into
an idiom. This transformation is made during the implementation phase
Node
Node
label : String
label : String
0 .. 1
firstArc
0 .. n
+children
Arc
Arc
next
0 .. 1
label : String
label : String
Figure 4.8
One-to-many association transformation