Java Code Examples for javax.print.attribute.AttributeSetUtilities#unmodifiableView()

The following examples show how to use javax.print.attribute.AttributeSetUtilities#unmodifiableView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Win32PrintService.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs =  currSet.toArray();
        for (int i=0; i<attrs.length; i++) {
            Attribute attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
Example 2
Source File: Win32PrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getAttributes() {

        PrintServiceAttributeSet attrs = new  HashPrintServiceAttributeSet();
        attrs.add(getPrinterName());
        attrs.add(getPrinterIsAcceptingJobs());
        PrinterState prnState = getPrinterState();
        if (prnState != null) {
            attrs.add(prnState);
        }
        PrinterStateReasons prnStateReasons = getPrinterStateReasons();
        if (prnStateReasons != null) {
            attrs.add(prnStateReasons);
        }
        attrs.add(getQueuedJobCount());
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            attrs.add(ColorSupported.SUPPORTED);
        } else {
            attrs.add(ColorSupported.NOT_SUPPORTED);
        }

        return AttributeSetUtilities.unmodifiableView(attrs);
    }
 
Example 3
Source File: UnixPrintService.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs = currSet.toArray();
        Attribute attr;
        for (int i=0; i<attrs.length; i++) {
            attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
Example 4
Source File: Win32PrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs =  currSet.toArray();
        for (int i=0; i<attrs.length; i++) {
            Attribute attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
Example 5
Source File: UnixPrintService.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getUpdatedAttributes() {
    PrintServiceAttributeSet currSet = getDynamicAttributes();
    if (lastSet == null) {
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(currSet);
    } else {
        PrintServiceAttributeSet updates =
            new HashPrintServiceAttributeSet();
        Attribute []attrs = currSet.toArray();
        Attribute attr;
        for (int i=0; i<attrs.length; i++) {
            attr = attrs[i];
            if (!lastSet.containsValue(attr)) {
                updates.add(attr);
            }
        }
        lastSet = currSet;
        return AttributeSetUtilities.unmodifiableView(updates);
    }
}
 
Example 6
Source File: Win32PrintService.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public PrintServiceAttributeSet getAttributes() {

        PrintServiceAttributeSet attrs = new  HashPrintServiceAttributeSet();
        attrs.add(getPrinterName());
        attrs.add(getPrinterIsAcceptingJobs());
        PrinterState prnState = getPrinterState();
        if (prnState != null) {
            attrs.add(prnState);
        }
        PrinterStateReasons prnStateReasons = getPrinterStateReasons();
        if (prnStateReasons != null) {
            attrs.add(prnStateReasons);
        }
        attrs.add(getQueuedJobCount());
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            attrs.add(ColorSupported.SUPPORTED);
        } else {
            attrs.add(ColorSupported.NOT_SUPPORTED);
        }

        return AttributeSetUtilities.unmodifiableView(attrs);
    }
 
Example 7
Source File: UnixPrintService.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public PrintServiceAttributeSet getAttributes() {
    PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
    attrs.add(getPrinterName());
    attrs.add(getPrinterIsAcceptingJobs());
    PrinterState prnState = getPrinterState();
    if (prnState != null) {
        attrs.add(prnState);
    }
    PrinterStateReasons prnStateReasons = getPrinterStateReasons();
    if (prnStateReasons != null) {
        attrs.add(prnStateReasons);
    }
    attrs.add(getQueuedJobCount());
    return AttributeSetUtilities.unmodifiableView(attrs);
}
 
Example 8
Source File: PSStreamPrintJob.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public PrintJobAttributeSet getAttributes() {
    synchronized (this) {
        if (jobAttrSet == null) {
            /* just return an empty set until the job is submitted */
            PrintJobAttributeSet jobSet = new HashPrintJobAttributeSet();
            return AttributeSetUtilities.unmodifiableView(jobSet);
        } else {
            return jobAttrSet;
        }
    }
}
 
Example 9
Source File: SimpleDoc.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@code SimpleDoc} with the specified print data, doc flavor
 * and doc attribute set.
 *
 * @param  printData the print data object
 * @param  flavor the {@code DocFlavor} object
 * @param  attributes a {@code DocAttributeSet}, which can be {@code null}
 * @throws IllegalArgumentException if {@code flavor} or {@code printData}
 *         is {@code null}, or the {@code printData} does not correspond to
 *         the specified doc flavor--for example, the data is not of the
 *         type specified as the representation in the {@code DocFlavor}
 */
public SimpleDoc(Object printData,
                 DocFlavor flavor, DocAttributeSet attributes) {

   if (flavor == null || printData == null) {
       throw new IllegalArgumentException("null argument(s)");
   }

   Class<?> repClass = null;
   try {
        String className = flavor.getRepresentationClassName();
        sun.reflect.misc.ReflectUtil.checkPackageAccess(className);
        repClass = Class.forName(className, false,
                          Thread.currentThread().getContextClassLoader());
   } catch (Throwable e) {
       throw new IllegalArgumentException("unknown representation class");
   }

   if (!repClass.isInstance(printData)) {
       throw new IllegalArgumentException("data is not of declared type");
   }

   this.flavor = flavor;
   if (attributes != null) {
       this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
   }
   this.printData = printData;
}
 
Example 10
Source File: Win32PrintJob.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public PrintJobAttributeSet getAttributes() {
    synchronized (this) {
        if (jobAttrSet == null) {
            /* just return an empty set until the job is submitted */
            PrintJobAttributeSet jobSet = new HashPrintJobAttributeSet();
            return AttributeSetUtilities.unmodifiableView(jobSet);
        } else {
          return jobAttrSet;
        }
    }
}
 
Example 11
Source File: SimpleDoc.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a <code>SimpleDoc</code> with the specified
 * print data, doc flavor and doc attribute set.
 * @param printData the print data object
 * @param flavor the <code>DocFlavor</code> object
 * @param attributes a <code>DocAttributeSet</code>, which can
 *                   be <code>null</code>
 * @throws IllegalArgumentException if <code>flavor</code> or
 *         <code>printData</code> is <code>null</code>, or the
 *         <code>printData</code> does not correspond
 *         to the specified doc flavor--for example, the data is
 *         not of the type specified as the representation in the
 *         <code>DocFlavor</code>.
 */
public SimpleDoc(Object printData,
                 DocFlavor flavor, DocAttributeSet attributes) {

   if (flavor == null || printData == null) {
       throw new IllegalArgumentException("null argument(s)");
   }

   Class repClass = null;
   try {
        String className = flavor.getRepresentationClassName();
        sun.reflect.misc.ReflectUtil.checkPackageAccess(className);
        repClass = Class.forName(className, false,
                          Thread.currentThread().getContextClassLoader());
   } catch (Throwable e) {
       throw new IllegalArgumentException("unknown representation class");
   }

   if (!repClass.isInstance(printData)) {
       throw new IllegalArgumentException("data is not of declared type");
   }

   this.flavor = flavor;
   if (attributes != null) {
       this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
   }
   this.printData = printData;
}
 
Example 12
Source File: Win32PrintJob.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public PrintJobAttributeSet getAttributes() {
    synchronized (this) {
        if (jobAttrSet == null) {
            /* just return an empty set until the job is submitted */
            PrintJobAttributeSet jobSet = new HashPrintJobAttributeSet();
            return AttributeSetUtilities.unmodifiableView(jobSet);
        } else {
          return jobAttrSet;
        }
    }
}
 
Example 13
Source File: Win32PrintJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public PrintJobAttributeSet getAttributes() {
    synchronized (this) {
        if (jobAttrSet == null) {
            /* just return an empty set until the job is submitted */
            PrintJobAttributeSet jobSet = new HashPrintJobAttributeSet();
            return AttributeSetUtilities.unmodifiableView(jobSet);
        } else {
          return jobAttrSet;
        }
    }
}
 
Example 14
Source File: SimpleDoc.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a <code>SimpleDoc</code> with the specified
 * print data, doc flavor and doc attribute set.
 * @param printData the print data object
 * @param flavor the <code>DocFlavor</code> object
 * @param attributes a <code>DocAttributeSet</code>, which can
 *                   be <code>null</code>
 * @throws IllegalArgumentException if <code>flavor</code> or
 *         <code>printData</code> is <code>null</code>, or the
 *         <code>printData</code> does not correspond
 *         to the specified doc flavor--for example, the data is
 *         not of the type specified as the representation in the
 *         <code>DocFlavor</code>.
 */
public SimpleDoc(Object printData,
                 DocFlavor flavor, DocAttributeSet attributes) {

   if (flavor == null || printData == null) {
       throw new IllegalArgumentException("null argument(s)");
   }

   Class repClass = null;
   try {
        String className = flavor.getRepresentationClassName();
        sun.reflect.misc.ReflectUtil.checkPackageAccess(className);
        repClass = Class.forName(className, false,
                          Thread.currentThread().getContextClassLoader());
   } catch (Throwable e) {
       throw new IllegalArgumentException("unknown representation class");
   }

   if (!repClass.isInstance(printData)) {
       throw new IllegalArgumentException("data is not of declared type");
   }

   this.flavor = flavor;
   if (attributes != null) {
       this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
   }
   this.printData = printData;
}
 
Example 15
Source File: PSStreamPrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public PrintServiceAttributeSet getAttributes() {
    PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
    attrs.add(ColorSupported.SUPPORTED);

    return AttributeSetUtilities.unmodifiableView(attrs);
}
 
Example 16
Source File: PSStreamPrintService.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public PrintServiceAttributeSet getAttributes() {
    PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
    attrs.add(ColorSupported.SUPPORTED);

    return AttributeSetUtilities.unmodifiableView(attrs);
}
 
Example 17
Source File: PrintJobAttributeEvent.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a {@code PrintJobAttributeEvent} object.
 *
 * @param  source the print job generating this event
 * @param  attributes the attribute changes being reported
 * @throws IllegalArgumentException if {@code source} is {@code null}
 */
public PrintJobAttributeEvent (DocPrintJob source,
                               PrintJobAttributeSet attributes)  {
    super(source);

    this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
}
 
Example 18
Source File: PrintJobAttributeEvent.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a PrintJobAttributeEvent object.
 * @param source the print job generating  this event
 * @param attributes the attribute changes being reported
 * @throws IllegalArgumentException if <code>source</code> is
 *         <code>null</code>.
 */
public PrintJobAttributeEvent (DocPrintJob source,
                               PrintJobAttributeSet attributes)  {
    super(source);

    this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
}
 
Example 19
Source File: PrintJobAttributeEvent.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Constructs a PrintJobAttributeEvent object.
 * @param source the print job generating  this event
 * @param attributes the attribute changes being reported
 * @throws IllegalArgumentException if <code>source</code> is
 *         <code>null</code>.
 */
public PrintJobAttributeEvent (DocPrintJob source,
                               PrintJobAttributeSet attributes)  {
    super(source);

    this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
}
 
Example 20
Source File: PrintServiceAttributeEvent.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a PrintServiceAttributeEvent object.
 *
 * @param source the print job generating  this event
 * @param attributes the attribute changes being reported
 * @throws IllegalArgumentException if <code>source</code> is
 *         <code>null</code>.
 */
public PrintServiceAttributeEvent(PrintService source,
                                  PrintServiceAttributeSet attributes) {

    super(source);
    this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
}