本文整理汇总了Java中javax.print.attribute.HashAttributeSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java HashAttributeSet.add方法的具体用法?Java HashAttributeSet.add怎么用?Java HashAttributeSet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.HashAttributeSet
的用法示例。
在下文中一共展示了HashAttributeSet.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnsupportedAttributes
import javax.print.attribute.HashAttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (attributes == null) {
return null;
}
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("Flavor " + flavor.getMimeType()
+ " is not supported by print service");
}
Attribute[] attrs = attributes.toArray();
HashAttributeSet unsupported = new HashAttributeSet();
for (int i = 0; i < attrs.length; i++) {
if (!isAttributeValueSupported(attrs[i], flavor, attributes)) {
unsupported.add(attrs[i]);
}
}
if (unsupported.size() > 0) {
return unsupported;
}
return null;
}
示例2: testMediaCategory
import javax.print.attribute.HashAttributeSet; //导入方法依赖的package包/类
public final void testMediaCategory() {
HashAttributeSet aset = new HashAttributeSet();
MediaSizeName msn = MediaSizeName.ISO_A3;
aset.add(msn);
assertEquals(msn, aset.get(Media.class));
assertNull(aset.get(MediaSizeName.class));
MediaTray mt = MediaTray.BOTTOM;
aset.add(mt);
assertEquals(mt, aset.get(Media.class));
assertNull(aset.get(MediaTray.class));
MediaName mn = MediaName.ISO_A4_WHITE;
aset.add(mn);
assertEquals(mn, aset.get(Media.class));
assertNull(aset.get(MediaName.class));
}
示例3: testGetSupportedAttributeValues
import javax.print.attribute.HashAttributeSet; //导入方法依赖的package包/类
public void testGetSupportedAttributeValues() {
System.out
.println("============= START testGetSupportedAttributeValues ================");
PrintService[] services;
DocFlavor[] flavors = new DocFlavor[] { DocFlavor.INPUT_STREAM.GIF,
DocFlavor.INPUT_STREAM.POSTSCRIPT,
DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII };
services = PrintServiceLookup.lookupPrintServices(null, null);
TestUtil.checkServices(services);
for (int i = 0, ii = services.length; i < ii; i++) {
System.out.println("\n----------- " + services[i].getName()
+ "----------");
Class[] cats = services[i].getSupportedAttributeCategories();
HashAttributeSet aset = new HashAttributeSet();
aset.add(MediaSizeName.ISO_A0);
aset.add(OrientationRequested.LANDSCAPE);
aset.add(Finishings.SADDLE_STITCH);
for (int l = 0, ll = flavors.length; l < ll; l++) {
if (services[i].isDocFlavorSupported(flavors[l])) {
System.out.println(" " + flavors[l]);
for (int j = 0, jj = cats.length; j < jj; j++) {
System.out.println(" " + cats[j]);
Object obj = services[i].getSupportedAttributeValues(
cats[j], flavors[l], aset);
if (obj != null && obj.getClass().isArray()) {
Object[] a = (Object[]) obj;
for (int k = 0, kk = a.length; k < kk; k++) {
System.out.println(" " + a[k]);
}
} else {
System.out.println(" " + obj);
}
}
}
}
}
System.out
.println("============= END testGetSupportedAttributeValues ================");
}