import
java.util.Collection;
import
java.util.Iterator;
import
java.util.Map;
import
java.util.Map.Entry;
import
java.util.Set;
import
javax.print.attribute.Attribute;
import
javax.print.attribute.standard.PrinterStateReason;
import
javax.print.attribute.standard.PrinterStateReasons;
import
javax.print.attribute.standard.Severity;
public
class
PrinterStateReasonsImpl {
private
PrinterStateReasons printerStateReasons;
public
PrinterStateReasonsImpl()
{
printerStateReasons =
new
PrinterStateReasons();
}
public
PrinterStateReasonsImpl(
int
initialCapacity)
{
printerStateReasons
=
new
PrinterStateReasons(initialCapacity);
}
public
PrinterStateReasonsImpl(
int
initialCapacity,
float
loadFactor)
{
printerStateReasons =
new
PrinterStateReasons(
initialCapacity, loadFactor);
}
public
PrinterStateReasonsImpl(
Map<PrinterStateReason, Severity> map)
{
printerStateReasons =
new
PrinterStateReasons(map);
}
public
void
clear() { printerStateReasons.clear(); }
public
Object clone()
{
return
printerStateReasons.clone();
}
public
boolean
containsKey(Object key)
{
return
printerStateReasons.containsKey(key);
}
public
boolean
containsValue(Object value)
{
return
printerStateReasons.containsValue(value);
}
public
Set<Entry<PrinterStateReason, Severity> >
entrySet()
{
return
printerStateReasons.entrySet();
}
public
Severity get(Object key)
{
return
printerStateReasons.get(key);
}
public
boolean
isEmpty()
{
return
printerStateReasons.isEmpty();
}
public
Set<PrinterStateReason> keySet()
{
return
printerStateReasons.keySet();
}
public
Severity put(PrinterStateReason reason,
Severity severity)
{
return
printerStateReasons.put(reason, severity);
}
public
void
putAll(Map<?
extends
PrinterStateReason, ?
extends
Severity> m)
{
printerStateReasons.putAll(m);
}
public
Severity remove(Object key)
{
return
printerStateReasons.remove(key);
}
public
int
size() {
return
printerStateReasons.size(); }
public
Collection<Severity> values()
{
return
printerStateReasons.values();
}
public
Class<?
extends
Attribute> getCategory()
{
return
printerStateReasons.getCategory();
}
public
String getName()
{
return
printerStateReasons.getName();
}
public
Set<PrinterStateReason>
printerStateReasonSet(Severity severity)
{
return
printerStateReasons.printerStateReasonSet(
severity);
}
public
static
void
main(String[] arg)
{
PrinterStateReasonsImpl printerStateReasons
=
new
PrinterStateReasonsImpl();
printerStateReasons.put(
PrinterStateReason.CONNECTING_TO_DEVICE,
Severity.ERROR);
printerStateReasons.put(
PrinterStateReason.COVER_OPEN, Severity.REPORT);
printerStateReasons.put(
PrinterStateReason.INPUT_TRAY_MISSING,
Severity.WARNING);
System.out.println(
"the key set of the printerStateReasons is "
);
Set<PrinterStateReason> keySet
= printerStateReasons.keySet();
Iterator<PrinterStateReason> itr
= keySet.iterator();
while
(itr.hasNext()) {
System.out.print(itr.next() +
"\t"
);
}
System.out.println();
System.out.println(
"the values of the printerStateReasons is "
);
Collection<Severity> collectionValues
= printerStateReasons.values();
Iterator<Severity> citr
= collectionValues.iterator();
while
(citr.hasNext()) {
System.out.print(citr.next() +
"\t"
);
}
System.out.println();
System.out.println(
"the entry set of the printerStateReasons is "
);
Iterator<Entry<PrinterStateReason, Severity> > eitr;
Set<Entry<PrinterStateReason, Severity> > entrySet
= printerStateReasons.entrySet();
eitr = entrySet.iterator();
while
(eitr.hasNext()) {
System.out.println(eitr.next() +
"\t"
);
}
System.out.println(
"the printerStateReasons contains Key CONNECTING_TO_DEVICE :"
+ printerStateReasons.containsKey(
PrinterStateReason.CONNECTING_TO_DEVICE));
System.out.println(
"the printerStateReasons contains Value ERROR :"
+ printerStateReasons.containsValue(
Severity.ERROR));
System.out.println(
"the size of the printerStateReasons is "
+ printerStateReasons.size());
printerStateReasons.clear();
if
(printerStateReasons.isEmpty())
System.out.println(
"the printerStateReasons is empty"
);
else
System.out.println(
"the printerStateReasons is not empty"
);
}
}