Package javax.print.attribute

Examples of javax.print.attribute.HashAttributeSet


public class emptySet implements Testlet
{
 
  public void test(TestHarness harness)
  {
    HashAttributeSet testSet = new HashAttributeSet();
    HashAttributeSet testSet2 = new HashAttributeSet();
   
    harness.check(testSet.equals(testSet2), true, "equals");
    harness.check(testSet.hashCode(), 0, "hashcode");
    harness.check(testSet.toArray().length, 0, "toArray");
   
View Full Code Here


  public void test(TestHarness harness)
  {
    harness.checkPoint("constructor tests");
    try
      {
        new HashAttributeSet((Attribute) null);
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }
   
    try
      {
        new HashAttributeSet((AttributeSet) null);
        harness.check(true);
      }
    catch (NullPointerException e)
      {
        harness.check(false);
      }
   
    try
      {
        new HashAttributeSet((Attribute[]) null);
        harness.check(true);
      }
    catch (NullPointerException e)
      {
        harness.check(false);
      }

    try
      {
        new HashAttributeSet(new Attribute[] { null });
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }

    harness.checkPoint("method tests");
    HashAttributeSet testSet = new HashAttributeSet();

    try
      {
        testSet.get(null);
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }

    try
      {
        testSet.add(null);
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }

    try
      {
        testSet.addAll(null);
        harness.check(false);
      }
    catch (NullPointerException e)
      {
        harness.check(true);
      }

    harness.check(testSet.remove((Attribute) null), false);
    harness.check(testSet.remove((Class) null), false);
    harness.check(testSet.containsKey(null), false);
    harness.check(testSet.containsValue(null), false);   
  }
View Full Code Here

  public void test(TestHarness harness)
  {
   
    SimpleAttribute att1 = new SimpleAttribute(1);
   
    HashAttributeSet testSet = new HashAttributeSet( att1 );
   
    // test basic functionality
    harness.check(testSet.containsValue(att1), true, "containsValue");
    harness.check(testSet.containsKey(att1.getCategory()),
                  true, "containsKey");   
    harness.check(testSet.remove(att1), true, "remove");
    harness.check(testSet.isEmpty(), true, "isEmpty");
    harness.check(testSet.add(att1), true, "add");
    harness.check(testSet.add(att1), false, "re-add");
   
    // test category replacement
    SimpleAttribute att2 = new SimpleAttribute(3);
    SimpleAttribute[] array =
      new SimpleAttribute[] { new SimpleAttribute(2), att2 };
    testSet = new HashAttributeSet( array );
   
    harness.check(testSet.size(), 1, "size");
    harness.check(testSet.hashCode(), 3, "hashcode");
    harness.check(testSet.containsValue(att2), true, "containsValue");
   
    AnotherSimpleAttribute att3 = new AnotherSimpleAttribute(4);
   
    harness.check(testSet.add(att3), true, "add");
    harness.check(testSet.size(), 2, "size");
    harness.check(testSet.hashCode(), 7, "hashcode");
   
    // build equal set for euqals test
    HashAttributeSet testSet2 = new HashAttributeSet();
    testSet2.add(att2);
    testSet2.add(att3);
   
    harness.check(testSet.equals(testSet2), true, "equals");   
    harness.check(testSet2.addAll(testSet), false, "addAll");
    testSet2.clear();
    harness.check(testSet2.isEmpty(), true, "isEmpty");
   
    // test hashcode
    testSet = new HashAttributeSet();
    testSet.add( new SimpleAttribute(1));
    testSet.add( new AnotherSimpleAttribute(2));
   
    testSet2 = new HashAttributeSet();
    testSet2.add( new SimpleAttribute(2));
    testSet2.add( new AnotherSimpleAttribute(1));
   
    harness.check(testSet.hashCode() == testSet2.hashCode(), "equal hashcode");
    harness.check(testSet.equals(testSet2), false, "no equality");
 
  }
View Full Code Here

     * Test that MadiaName, MediaSizeName, MediaTray are
     * fall into the Media attribute Category
     */
    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));
    }
View Full Code Here

        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]);
View Full Code Here

                    //uri = File.createTempFile("xxx", null).toURI();
                } catch (URISyntaxException e) {
                    fail();
                }

                AttributeSet attrs = new HashAttributeSet();
                attrs.add(Finishings.EDGE_STITCH);
                attrs.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
                attrs.add(new Destination(uri));
                attrs.add(new DocumentName("Doc X", Locale.US));
                attrs.add(new JobName("Job Y", Locale.US));
                attrs.add(new RequestingUserName("User Z", Locale.US));

                for (int j = 0; j < flavors.length; j++) {
                    if (services[i].isDocFlavorSupported(flavors[j])) {
                        AttributeSet aset = services[i]
                                .getUnsupportedAttributes(flavors[j], attrs);
View Full Code Here

        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;
        }
    }
View Full Code Here

        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;
        }
    }
View Full Code Here

            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;
    }
View Full Code Here

        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;
    }
View Full Code Here

TOP

Related Classes of javax.print.attribute.HashAttributeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.