6732647: isAttributeValueSupported() is not consistant with getSupportedValues() for Copies, TEXT flavor
Reviewed-by: tdv, prr
--- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java Thu Oct 09 17:12:50 2008 -0700
+++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java Mon Oct 13 15:41:31 2008 -0700
@@ -487,28 +487,26 @@
/* Test if the flavor is compatible with the category */
if ((category == Copies.class) ||
(category == CopiesSupported.class)) {
- CopiesSupported cs = new CopiesSupported(1, MAXCOPIES);
- AttributeClass attribClass = (getAttMap != null) ?
- (AttributeClass)getAttMap.get(cs.getName()) : null;
- if (attribClass != null) {
- int[] range = attribClass.getIntRangeValue();
- cs = new CopiesSupported(range[0], range[1]);
+ if (flavor == null ||
+ !(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) {
+ CopiesSupported cs = new CopiesSupported(1, MAXCOPIES);
+ AttributeClass attribClass = (getAttMap != null) ?
+ (AttributeClass)getAttMap.get(cs.getName()) : null;
+ if (attribClass != null) {
+ int[] range = attribClass.getIntRangeValue();
+ cs = new CopiesSupported(range[0], range[1]);
+ }
+ return cs;
+ } else {
+ return null;
}
- return cs;
} else if (category == Chromaticity.class) {
if (flavor == null ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
- flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
- flavor.equals(DocFlavor.URL.GIF) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
- flavor.equals(DocFlavor.URL.JPEG) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
- flavor.equals(DocFlavor.URL.PNG)) {
-
+ !isIPPSupportedImages(flavor.getMimeType())) {
Chromaticity[]arr = new Chromaticity[1];
arr[0] = Chromaticity.COLOR;
return (arr);
@@ -1220,7 +1218,7 @@
}
- public boolean isAttributeValueSupported(Attribute attr,
+ public boolean isAttributeValueSupported(Attribute attr,
DocFlavor flavor,
AttributeSet attributes) {
if (attr == null) {
@@ -1249,21 +1247,18 @@
if ((flavor == null) ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
- flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
- flavor.equals(DocFlavor.URL.GIF) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
- flavor.equals(DocFlavor.URL.JPEG) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
- flavor.equals(DocFlavor.URL.PNG)) {
+ !isIPPSupportedImages(flavor.getMimeType())) {
return attr == Chromaticity.COLOR;
} else {
return false;
}
} else if (attr.getCategory() == Copies.class) {
- return isSupportedCopies((Copies)attr);
+ return (flavor == null ||
+ !(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
+ isSupportedCopies((Copies)attr);
+
} else if (attr.getCategory() == Destination.class) {
if (flavor == null ||
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
--- a/jdk/src/solaris/classes/sun/print/UnixPrintService.java Thu Oct 09 17:12:50 2008 -0700
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintService.java Mon Oct 13 15:41:31 2008 -0700
@@ -686,19 +686,7 @@
}
if (category == Chromaticity.class) {
- if (flavor == null ||
- flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
- flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
- flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
- flavor.equals(DocFlavor.URL.GIF) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
- flavor.equals(DocFlavor.URL.JPEG) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
- flavor.equals(DocFlavor.URL.PNG)) {
-
+ if (flavor == null || isServiceFormattedFlavor(flavor)) {
Chromaticity[]arr = new Chromaticity[1];
arr[0] = Chromaticity.COLOR;
return (arr);
@@ -730,18 +718,7 @@
}
return new RequestingUserName(userName, null);
} else if (category == OrientationRequested.class) {
- if (flavor == null ||
- flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
- flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE) ||
- flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
- flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
- flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
- flavor.equals(DocFlavor.BYTE_ARRAY.PNG) ||
- flavor.equals(DocFlavor.URL.GIF) ||
- flavor.equals(DocFlavor.URL.JPEG) ||
- flavor.equals(DocFlavor.URL.PNG)) {
+ if (flavor == null || isServiceFormattedFlavor(flavor)) {
OrientationRequested []arr = new OrientationRequested[3];
arr[0] = OrientationRequested.PORTRAIT;
arr[1] = OrientationRequested.LANDSCAPE;
@@ -752,7 +729,14 @@
}
} else if ((category == Copies.class) ||
(category == CopiesSupported.class)) {
- return new CopiesSupported(1, MAXCOPIES);
+ if (flavor == null ||
+ !(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) {
+ return new CopiesSupported(1, MAXCOPIES);
+ } else {
+ return null;
+ }
} else if (category == Media.class) {
Media []arr = new Media[mediaSizes.length];
System.arraycopy(mediaSizes, 0, arr, 0, mediaSizes.length);
@@ -917,8 +901,10 @@
}
}
else if (attr.getCategory() == Copies.class) {
- return
- (flavor == null || isServiceFormattedFlavor(flavor)) &&
+ return (flavor == null ||
+ !(flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT))) &&
isSupportedCopies((Copies)attr);
} else if (attr.getCategory() == Destination.class) {
URI uri = ((Destination)attr).getURI();
--- a/jdk/test/javax/print/attribute/PSCopiesFlavorTest.java Thu Oct 09 17:12:50 2008 -0700
+++ b/jdk/test/javax/print/attribute/PSCopiesFlavorTest.java Mon Oct 13 15:41:31 2008 -0700
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 6527316
+ * @bug 6527316 6732647
* @summary Copies isn't supported for PS flavors.
* @run main PSCopiesFlavorTest
*/
@@ -50,5 +50,13 @@
if (suppVal || us == null) {
throw new RuntimeException("Copies should be unsupported value");
}
+
+ Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
+
+ //Copies Supported
+ if(value instanceof CopiesSupported) {
+ throw new RuntimeException("Copies should have no supported values.");
+ }
+
}
}