import
java.util.Collection;
import
java.util.List;
import
javax.management.Attribute;
import
javax.management.AttributeList;
public
class
AttributeListImpl {
private
AttributeList attributeList;
public
AttributeListImpl()
{
attributeList =
new
AttributeList();
}
public
AttributeListImpl(AttributeList list)
{
attributeList =
new
AttributeList();
}
public
AttributeListImpl(
int
initialCapacity)
{
attributeList =
new
AttributeList(initialCapacity);
}
public
AttributeListImpl(List<Attribute> list)
{
attributeList =
new
AttributeList();
}
public
void
add(Attribute object)
{
attributeList.add(object);
}
public
void
add(
int
index, Attribute object)
{
attributeList.add(index, object);
}
public
void
add(
int
index, Object element)
{
attributeList.add(index, element);
}
public
boolean
add(Object element)
{
return
attributeList.add(element);
}
public
boolean
addAll(AttributeList list)
{
return
attributeList.addAll(list);
}
public
boolean
addAll(Collection<?> c)
{
return
attributeList.addAll(c);
}
public
boolean
addAll(
int
index, AttributeList list)
{
return
attributeList.addAll(index, list);
}
public
boolean
addAll(
int
index, Collection<?> c)
{
return
attributeList.addAll(index, c);
}
public
List<Attribute> asList()
{
return
attributeList.asList();
}
public
void
set(
int
index, Attribute element)
{
attributeList.set(index, element);
}
public
Object set(
int
index, Object element)
{
return
attributeList.set(index, element);
}
public
static
void
main(String[] arg)
{
AttributeListImpl attributeList
=
new
AttributeListImpl();
attributeList.add(
new
Attribute(
"rose"
,
1
));
attributeList.add(
new
Attribute(
"sun-flower"
,
2
));
attributeList.add(
new
Attribute(
"tulip"
,
3
));
attributeList.add(
new
Attribute(
"orchid"
,
4
));
attributeList.add(
new
Attribute(
"marie-gold"
,
5
));
attributeList.add(
new
Attribute(
"hibiscus"
,
0
));
System.out.println(
"The elements of the attributelist are"
);
List<Attribute> flowerlist = attributeList.asList();
int
ind =
0
;
while
(ind < flowerlist.size()) {
System.out.print(flowerlist.get(ind++) +
" "
);
}
System.out.println();
attributeList.set(
5
,
new
Attribute(
"hibiscus"
,
6
));
System.out.println();
System.out.println(
"after setting index 5"
);
System.out.println(
"the elements of the attributelist are"
);
flowerlist = attributeList.asList();
ind =
0
;
while
(ind < flowerlist.size()) {
System.out.print(flowerlist.get(ind++) +
" "
);
}
}
}