当前位置: 首页>>代码示例>>Java>>正文


Java HashAttributeSet类代码示例

本文整理汇总了Java中javax.print.attribute.HashAttributeSet的典型用法代码示例。如果您正苦于以下问题:Java HashAttributeSet类的具体用法?Java HashAttributeSet怎么用?Java HashAttributeSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HashAttributeSet类属于javax.print.attribute包,在下文中一共展示了HashAttributeSet类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
@Override
public void create(String filename) {
	// find the printing service
	//http://www.coderanch.com/t/385989/java/java/send-raw-data-printer
	AttributeSet attributeSet = new HashAttributeSet();  
	attributeSet.add(new PrinterName(filename, null));
	PrintService[] services = PrintServiceLookup.lookupPrintServices(null, attributeSet);
	if(services.length > 0){
		if(printFile != null){
			printFile.deleteOnExit();
			printFile = null;
		}
		try {
			printFile = File.createTempFile("printer_"+name,".redirect");
		} catch (IOException e) {
			e.printStackTrace();
		}
		printService = services[0];
	}
	
}
 
开发者ID:thshdw,项目名称:lixia-javardp,代码行数:22,代码来源:Printer.java

示例2: getUnsupportedAttributes

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(final DocFlavor flavor,
                final AttributeSet attributes) {
    checkFlavor(flavor);

    if (attributes == null) {
        return null;
    }

    final AttributeSet result = new HashAttributeSet();

    for (Attribute attr : attributes.toArray()) {
        if (!isAttributeValueSupported(attr, flavor, attributes)) {
            result.add(attr);
        }
    }

    return result.size() > 0 ? result : null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:WinPrintService.java

示例3: 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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:DefaultPrintService.java

示例4: 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));
    }
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:MediaTest.java

示例5: getUnsupportedAttributes

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes) {

    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor +
                                           "is not supported");
    }

    if (attributes == null) {
        return null;
    }

    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute[] attrs = attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor,
                                                  attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:PSStreamPrintService.java

示例6: getUnsupportedAttributes

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes) {

    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor +
                                           "is not supported");
    }

    if (attributes == null) {
        return null;
    }

    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute []attrs = attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            }
            else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Win32PrintService.java

示例7: getUnsupportedAttributes

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes) {

    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor +
                                           "is not supported");
    }

    if (attributes == null) {
        return null;
    }

    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute []attrs = attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor,
                                                  attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:UnixPrintService.java

示例8: lookupByName

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
private static PrintService lookupByName(String name) {
  AttributeSet attributes = new HashAttributeSet();
  attributes.add(new PrinterName(name, null));
  for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
    return service;
  }
  return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:GetPrintServices.java

示例9: getUnsupportedAttributes

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
                                             AttributeSet attributes) {

    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor +
                                           " is not supported");
    }

    if (attributes == null) {
        return null;
    }

    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute []attrs = attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            }
            else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Win32PrintService.java

示例10: lookupByName

import javax.print.attribute.HashAttributeSet; //导入依赖的package包/类
private static PrintService lookupByName(String name) {
    AttributeSet attributes = new HashAttributeSet();
    attributes.add(new PrinterName(name, null));
    for (PrintService service :
         PrintServiceLookup.lookupPrintServices(null, attributes)) {
        return service;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GetPrintServices.java


注:本文中的javax.print.attribute.HashAttributeSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。