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


Java PrintServiceAttributeSet.get方法代码示例

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


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

示例1: getAttribute

import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
public PrintServiceAttribute getAttribute(Class category) {
    if (!PrintServiceAttribute.class.isAssignableFrom(category)) {
        throw new IllegalArgumentException();
    }
    PrintServiceAttributeSet attributes = getAttributes();
    if (attributes.containsKey(category)) {
        PrintServiceAttribute attribute = (PrintServiceAttribute) attributes
                .get(category);
        return attribute;
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:DefaultPrintService.java

示例2: getPrintServices

import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
private PrintService[]
    getPrintServices(PrintServiceAttributeSet serviceSet) {

    if (serviceSet == null || serviceSet.isEmpty()) {
        return getPrintServices();
    }

    /* Typically expect that if a service attribute is specified that
     * its a printer name and there ought to be only one match.
     * Directly retrieve that service and confirm
     * that it meets the other requirements.
     * If printer name isn't mentioned then go a slow path checking
     * all printers if they meet the reqiremements.
     */
    PrintService[] services;
    PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
    PrintService defService;
    if (name != null && (defService = getDefaultPrintService()) != null) {
        /* To avoid execing a unix command  see if the client is asking
         * for the default printer by name, since we already have that
         * initialised.
         */

        PrinterName defName =
            (PrinterName)defService.getAttribute(PrinterName.class);

        if (defName != null && name.equals(defName)) {
            if (matchesAttributes(defService, serviceSet)) {
                services = new PrintService[1];
                services[0] = defService;
                return services;
            } else {
                return new PrintService[0];
            }
        } else {
            /* Its not the default service */
            PrintService service = getServiceByName(name);
            if (service != null &&
                matchesAttributes(service, serviceSet)) {
                services = new PrintService[1];
                services[0] = service;
                return services;
            } else {
                return new PrintService[0];
            }
        }
    } else {
        /* specified service attributes don't include a name.*/
        Vector matchedServices = new Vector();
        services = getPrintServices();
        for (int i = 0; i< services.length; i++) {
            if (matchesAttributes(services[i], serviceSet)) {
                matchedServices.add(services[i]);
            }
        }
        services = new PrintService[matchedServices.size()];
        for (int i = 0; i< services.length; i++) {
            services[i] = (PrintService)matchedServices.elementAt(i);
        }
        return services;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:UnixPrintServiceLookup.java

示例3: getPrintServices

import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
private PrintService[]
    getPrintServices(PrintServiceAttributeSet serviceSet) {

    if (serviceSet == null || serviceSet.isEmpty()) {
        return getPrintServices();
    }

    /* Typically expect that if a service attribute is specified that
     * its a printer name and there ought to be only one match.
     * Directly retrieve that service and confirm
     * that it meets the other requirements.
     * If printer name isn't mentioned then go a slow path checking
     * all printers if they meet the reqiremements.
     */
    PrintService[] services;
    PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
    PrintService defService;
    if (name != null && (defService = getDefaultPrintService()) != null) {
        /* To avoid execing a unix command  see if the client is asking
         * for the default printer by name, since we already have that
         * initialised.
         */

        PrinterName defName = defService.getAttribute(PrinterName.class);

        if (defName != null && name.equals(defName)) {
            if (matchesAttributes(defService, serviceSet)) {
                services = new PrintService[1];
                services[0] = defService;
                return services;
            } else {
                return new PrintService[0];
            }
        } else {
            /* Its not the default service */
            PrintService service = getServiceByName(name);
            if (service != null &&
                matchesAttributes(service, serviceSet)) {
                services = new PrintService[1];
                services[0] = service;
                return services;
            } else {
                return new PrintService[0];
            }
        }
    } else {
        /* specified service attributes don't include a name.*/
        Vector<PrintService> matchedServices = new Vector<>();
        services = getPrintServices();
        for (int i = 0; i< services.length; i++) {
            if (matchesAttributes(services[i], serviceSet)) {
                matchedServices.add(services[i]);
            }
        }
        services = new PrintService[matchedServices.size()];
        for (int i = 0; i< services.length; i++) {
            services[i] = matchedServices.elementAt(i);
        }
        return services;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:PrintServiceLookupProvider.java


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