Here you can find the source of getAttribute( PrintService ps, Class
public static <T extends PrintServiceAttribute> T getAttribute( PrintService ps, Class<T> category)
//package com.java2s; /*/*from w ww . j a va2s.com*/ * Copyright (C) 2015 University of Oregon * * You may distribute under the terms of either the GNU General Public * License or the Apache License, as specified in the LICENSE file. * * For more information, see the LICENSE file. */ import javax.print.*; import javax.print.attribute.*; public class Main { public static <T extends PrintServiceAttribute> T getAttribute( PrintService ps, Class<T> category) { if (ps == null || !isGoodPrinterName(ps.getName())) return null; return ps.getAttribute(category); } public static boolean isGoodPrinterName(String name) { if (name == null) return false; if (name.equals("jeff_pl") || name.equals("jeff_pr")) return false; if (name.equals("steve_pl") || name.equals("steve_pr")) return false; return true; } }