summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/gnu/javax
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/javax')
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Assembly.java1
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Cascade.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Direction.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Operation.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Stage.java1
-rw-r--r--libjava/classpath/gnu/javax/crypto/assembly/Transformer.java1
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Anubis.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Cast5.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Khazad.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Serpent.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Square.java6
-rw-r--r--libjava/classpath/gnu/javax/crypto/cipher/Twofish.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java572
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java1
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java21
-rw-r--r--libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java367
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java106
-rw-r--r--libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/mac/UMac32.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/PadFactory.java5
-rw-r--r--libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java2
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/Fortuna.java9
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/IPBE.java34
-rw-r--r--libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java27
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java4
-rw-r--r--libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java4
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java1
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java119
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java39
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java2
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java13
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java196
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java148
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java380
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java2
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java2
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java128
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java129
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java129
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java130
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java128
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java127
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java269
-rw-r--r--libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java234
-rw-r--r--libjava/classpath/gnu/javax/print/CupsIppOperation.java99
-rw-r--r--libjava/classpath/gnu/javax/print/CupsMediaMapping.java176
-rw-r--r--libjava/classpath/gnu/javax/print/CupsPrintService.java104
-rw-r--r--libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java260
-rw-r--r--libjava/classpath/gnu/javax/print/CupsServer.java269
-rw-r--r--libjava/classpath/gnu/javax/print/PrintAttributeException.java148
-rw-r--r--libjava/classpath/gnu/javax/print/PrintFlavorException.java120
-rw-r--r--libjava/classpath/gnu/javax/print/PrintUriException.java140
-rw-r--r--libjava/classpath/gnu/javax/print/PrinterDialog.java1722
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java471
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java99
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppException.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppPrintService.java916
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppRequest.java857
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppResponse.java778
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java185
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppUtilities.java551
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/IppValueTag.java170
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java80
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java115
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java59
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java117
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java130
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java190
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java106
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java263
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java149
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java122
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java105
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java152
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java114
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java154
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java141
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java119
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java150
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java95
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java92
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java110
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java106
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java93
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java86
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java87
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java162
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java91
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java303
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java121
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java133
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java150
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java177
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java118
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java230
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java179
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java117
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java171
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java143
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java88
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java136
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java141
-rw-r--r--libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java126
-rw-r--r--libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java34
-rw-r--r--libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java265
-rw-r--r--libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java218
-rw-r--r--libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java121
-rw-r--r--libjava/classpath/gnu/javax/swing/tree/GnuPath.java65
170 files changed, 17821 insertions, 848 deletions
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java b/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
index 1d70eff87f4..2d5bba3646e 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Assembly.java
@@ -51,7 +51,6 @@ import java.util.Map;
* of the {@link Transformer} chain of the <code>Assembly</code>.</p>
*
* @see Transformer
- * @version $Revision: 1.1 $
*/
public class Assembly
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java b/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
index 20cd3de9d88..678a7e7308d 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Cascade.java
@@ -72,8 +72,6 @@ import java.util.Set;
* CRC Press, Inc. ISBN 0-8493-8523-7, 1997<br>
* Menezes, A., van Oorschot, P. and S. Vanstone.</li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public class Cascade
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java b/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
index 71a8b178ff1..81629f5a8e7 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/CascadeStage.java
@@ -45,8 +45,6 @@ import java.util.Set;
/**
* <p>A Cascade <i>Stage</i> in a Cascade Cipher.</p>
- *
- * @version $Revision: 1.1 $
*/
class CascadeStage extends Stage
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
index 325571dcddc..dbbc7cd286e 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/CascadeTransformer.java
@@ -44,8 +44,6 @@ import java.util.Map;
/**
* An Adapter to use any {@link Cascade} as a {@link Transformer} in an
* {@link Assembly}.
- *
- * @version $Revision: 1.1 $
*/
class CascadeTransformer extends Transformer
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Direction.java b/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
index 2e8ef1145a4..58b59a6307f 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Direction.java
@@ -49,8 +49,6 @@ package gnu.javax.crypto.assembly;
* its inverse value</li>
* <li>REVERSED: equivalent to {@link gnu.crypto.mode.IMode#DECRYPTION}.</li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public final class Direction
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
index 62791264f96..3c0bdfab30c 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/LoopbackTransformer.java
@@ -43,8 +43,6 @@ import java.util.Map;
/**
* A trivial {@link Transformer} to allow closing a chain in an {@link Assembly}.
* This class is not visible outside this package.
- *
- * @version $Revision: 1.1 $
*/
final class LoopbackTransformer extends Transformer
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java b/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
index 1cd8fd9154e..1143348f675 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/ModeStage.java
@@ -53,8 +53,6 @@ import java.util.Set;
* <p>Such a stage wraps an implementation of a Block Cipher Mode of Operation
* ({@link IMode}) to allow inclusion of such an instance in a cascade of block
* ciphers.</p>
- *
- * @version $Revision: 1.1 $
*/
class ModeStage extends Stage
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Operation.java b/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
index 2646e1f3301..34cae52ea80 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Operation.java
@@ -51,8 +51,6 @@ package gnu.javax.crypto.assembly;
* the chain, and the resulting bytes are then processed by the current
* {@link Transformer}.</li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public final class Operation
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java b/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
index 8af46a72a95..c63f92e87bc 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/PaddingTransformer.java
@@ -50,8 +50,6 @@ import java.util.Map;
* <p>When using such a {@link Transformer}, in an {@link Assembly}, there must
* be at least one element behind this instance in the constructed chain;
* otherwise, a {@link TransformerException} is thrown at initialisation time.</p>
- *
- * @version $Revision: 1.1 $
*/
class PaddingTransformer extends Transformer
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Stage.java b/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
index e44985534b7..23d50bb8237 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Stage.java
@@ -82,7 +82,6 @@ import java.util.Set;
*
* @see ModeStage
* @see CascadeStage
- * @version $Revision: 1.1 $
*/
public abstract class Stage
{
diff --git a/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java b/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
index c62c4677ffb..80430dc196f 100644
--- a/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
+++ b/libjava/classpath/gnu/javax/crypto/assembly/Transformer.java
@@ -77,7 +77,6 @@ import java.util.Map;
* @see CascadeTransformer
* @see PaddingTransformer
* @see DeflateTransformer
- * @version $Revision: 1.1 $
*/
public abstract class Transformer
{
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java b/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
index 63b97ce4e08..ca4e8edfe77 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Anubis.java
@@ -576,7 +576,7 @@ public final class Anubis extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java b/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
index 5cb958ee47b..ca1fdfbd394 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Blowfish.java
@@ -688,7 +688,7 @@ public class Blowfish extends BaseCipher
{
result = testKat(TV_KEY, TV_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java b/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
index cbdfe61f5b1..a0e0c60f33f 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Cast5.java
@@ -1341,7 +1341,7 @@ public class Cast5 extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT, KAT_PT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java b/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
index b6c27833eb8..3a95874da98 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Khazad.java
@@ -514,7 +514,7 @@ public final class Khazad extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java b/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
index 058c8b3466d..bcd1872fc1b 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Rijndael.java
@@ -852,7 +852,7 @@ public final class Rijndael extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java b/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
index b323b5017b9..2ed1e4b5593 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Serpent.java
@@ -789,7 +789,7 @@ public class Serpent extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Square.java b/libjava/classpath/gnu/javax/crypto/cipher/Square.java
index 15cb8b53602..a73116eb422 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Square.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Square.java
@@ -59,8 +59,6 @@ import java.util.Iterator;
* <a href="mailto:lars.knudsen@esat.kuleuven.ac.be">Lars Knudsen</a> and
* <a href="mailto:vincent.rijmen@esat.kuleuven.ac.be">Vincent Rijmen</a>.</li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public final class Square extends BaseCipher
{
@@ -513,8 +511,8 @@ public final class Square extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java b/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
index bea7f5d2cf2..f5565d4b46f 100644
--- a/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
+++ b/libjava/classpath/gnu/javax/crypto/cipher/Twofish.java
@@ -902,7 +902,7 @@ public final class Twofish extends BaseCipher
{
result = testKat(KAT_KEY, KAT_CT);
}
- valid = new Boolean(result);
+ valid = Boolean.valueOf(result);
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
index ba7466fc39c..33de6895613 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AESSpi.java
@@ -52,8 +52,6 @@ import java.security.spec.InvalidParameterSpecException;
/**
* The implementation of the AES <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class AESSpi extends CipherAdapter
{
@@ -101,4 +99,4 @@ public final class AESSpi extends CipherAdapter
}
engineInit(opmode, key, spec, random);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
index 8fc1fe4cbbf..963fa1c0081 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/ARCFourSpi.java
@@ -64,8 +64,6 @@ import javax.crypto.ShortBufferException;
/**
* The <i>Service Provider Interface</i> (<b>SPI</b>) for the ARCFOUR
* stream cipher.
- *
- * @version $Revision: 1.1 $
*/
public class ARCFourSpi extends CipherSpi
{
@@ -205,4 +203,4 @@ public class ARCFourSpi extends CipherSpi
{
return engineUpdate(in, inOffset, length, out, outOffset);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
index ac2f596c863..0fca3b49104 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/AnubisSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Anubis <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class AnubisSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class AnubisSpi extends CipherAdapter
{
super(Registry.ANUBIS_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
index d1a28616d0d..d31d7e19390 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/BlowfishSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Blowfish <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class BlowfishSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class BlowfishSpi extends CipherAdapter
{
super(Registry.BLOWFISH_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
index 9667a67fff8..5eaa31b779b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/CipherAdapter.java
@@ -82,8 +82,6 @@ import javax.crypto.spec.IvParameterSpec;
* and the initialization vector, the subclass should override those methods.
* Otherwise a subclass need only call the {@link #CipherAdapter(String)}
* constructor with the name of the cipher.</p>
- *
- * @version $Revision: 1.1 $
*/
class CipherAdapter extends CipherSpi
{
@@ -504,4 +502,4 @@ class CipherAdapter extends CipherSpi
partBlock = new byte[blockLen];
partLen = 0;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
index f3ec8220a7f..ff86071c4ee 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/DESSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the DES <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class DESSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class DESSpi extends CipherAdapter
{
super(Registry.DES_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
index 7f43dd010fa..397c27d2ed7 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/KhazadSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Khazad <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class KhazadSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class KhazadSpi extends CipherAdapter
{
super(Registry.KHAZAD_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
index 0876c9585a3..e6d78ef393e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/NullCipherSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Null cipher <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class NullCipherSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class NullCipherSpi extends CipherAdapter
{
super(Registry.NULL_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
index 28b327d8365..9889ab9fc86 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/PBES2.java
@@ -56,8 +56,6 @@ import javax.crypto.spec.SecretKeySpec;
/**
* <p>.</p>
- *
- * @version $Revision: 1.1 $
*/
public abstract class PBES2 extends CipherAdapter
{
@@ -1349,4 +1347,4 @@ public abstract class PBES2 extends CipherAdapter
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
index 1a67f934b9e..137db2c3fa4 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/RijndaelSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Rijndael <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class RijndaelSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class RijndaelSpi extends CipherAdapter
{
super(Registry.RIJNDAEL_CIPHER, 16);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
index 394a0ce0a66..9df9685cc38 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SerpentSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Serpent <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class SerpentSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class SerpentSpi extends CipherAdapter
{
super(Registry.SERPENT_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
index bb59cd224ce..96e5dee38b1 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/SquareSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Square <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class SquareSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class SquareSpi extends CipherAdapter
{
super(Registry.SQUARE_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
index cec30f6537d..5c58ea5515e 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TripleDESSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Triple-DES <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class TripleDESSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class TripleDESSpi extends CipherAdapter
{
super(Registry.TRIPLEDES_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
index 34f2d95d60a..31df5ea4068 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/cipher/TwofishSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Twofish <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class TwofishSpi extends CipherAdapter
{
@@ -56,4 +54,4 @@ public final class TwofishSpi extends CipherAdapter
{
super(Registry.TWOFISH_CIPHER);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java b/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
index d74d386b4f0..d2501f89374 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/keyring/GnuKeyring.java
@@ -1,4 +1,4 @@
-/* GnuKeyring.java --
+/* GnuKeyring.java -- KeyStore adapter for a pair of private and public Keyrings
Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is a part of GNU Classpath.
@@ -38,376 +38,412 @@ exception statement from your version. */
package gnu.javax.crypto.jce.keyring;
+import gnu.java.security.Registry;
+import gnu.javax.crypto.keyring.GnuPrivateKeyring;
+import gnu.javax.crypto.keyring.GnuPublicKeyring;
+import gnu.javax.crypto.keyring.IKeyring;
+import gnu.javax.crypto.keyring.IPrivateKeyring;
+import gnu.javax.crypto.keyring.IPublicKeyring;
+import gnu.javax.crypto.keyring.MalformedKeyringException;
+import gnu.javax.crypto.keyring.PrimitiveEntry;
+
import java.io.BufferedInputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
import java.security.Key;
-import java.security.KeyStoreSpi;
import java.security.KeyStoreException;
+import java.security.KeyStoreSpi;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.logging.Logger;
import javax.crypto.SecretKey;
-import gnu.java.security.Registry;
-import gnu.javax.crypto.keyring.IKeyring;
-import gnu.javax.crypto.keyring.IPrivateKeyring;
-import gnu.javax.crypto.keyring.IPublicKeyring;
-import gnu.javax.crypto.keyring.GnuPrivateKeyring;
-import gnu.javax.crypto.keyring.GnuPublicKeyring;
-import gnu.javax.crypto.keyring.MalformedKeyringException;
-import gnu.javax.crypto.keyring.PrimitiveEntry;
-
-public class GnuKeyring extends KeyStoreSpi
+/**
+ * An <i>Adapter</i> over a pair of one private, and one public keyrings to
+ * emulate the keystore operations.
+ */
+public class GnuKeyring
+ extends KeyStoreSpi
{
+ private static final Logger log = Logger.getLogger(GnuKeyring.class.getName());
+ private static final String NOT_LOADED = "not loaded";
- // Constants and fields.
- // ------------------------------------------------------------------------
-
+ /** TRUE if the keystore is loaded; FALSE otherwise. */
private boolean loaded;
+ /** our underlying private keyring. */
+ private IPrivateKeyring privateKR;
+ /** our underlying public keyring. */
+ private IPublicKeyring publicKR;
- private IKeyring keyring;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- public GnuKeyring()
- {
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
+ // default 0-arguments constructor
public Enumeration engineAliases()
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return new Enumeration()
+ ensureLoaded();
+ Enumeration result;
+ if (privateKR == null)
+ result = Collections.enumeration(Collections.EMPTY_SET);
+ else
{
- public boolean hasMoreElements()
- {
- return false;
- }
-
- public Object nextElement()
- {
- throw new NoSuchElementException();
- }
- };
- }
- return keyring.aliases();
+ Set aliases = new HashSet();
+ for (Enumeration e = privateKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ aliases.add(alias);
+ }
+
+ for (Enumeration e = publicKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ aliases.add(alias);
+ }
+
+ result = Collections.enumeration(aliases);
+ }
+
+ return result;
}
public boolean engineContainsAlias(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return false;
- }
- return keyring.containsAlias(alias);
+ log.entering(this.getClass().getName(), "engineContainsAlias", alias);
+
+ ensureLoaded();
+ boolean inPrivateKR = privateKR.containsAlias(alias);
+ log.finest("inPrivateKR=" + inPrivateKR);
+ boolean inPublicKR = publicKR.containsAlias(alias);
+ log.finest("inPublicKR=" + inPublicKR);
+ boolean result = inPrivateKR || inPublicKR;
+
+ log.exiting(this.getClass().getName(), "engineContainsAlias",
+ Boolean.valueOf(result));
+ return result;
}
public void engineDeleteEntry(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring != null)
- {
- keyring.remove(alias);
- }
+ log.entering(this.getClass().getName(), "engineDeleteEntry", alias);
+
+ ensureLoaded();
+ if (privateKR.containsAlias(alias))
+ privateKR.remove(alias);
+ else if (publicKR.containsAlias(alias))
+ publicKR.remove(alias);
+ else
+ log.finer("Unknwon alias: " + alias);
+
+ log.exiting(this.getClass().getName(), "engineDeleteEntry");
}
public Certificate engineGetCertificate(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return null;
- }
- if (!(keyring instanceof IPublicKeyring))
- {
- throw new IllegalStateException("not a public keyring");
- }
- return ((IPublicKeyring) keyring).getCertificate(alias);
+ log.entering(this.getClass().getName(), "engineGetCertificate", alias);
+
+ ensureLoaded();
+ Certificate result = publicKR.getCertificate(alias);
+
+ log.exiting(this.getClass().getName(), "engineGetCertificate", result);
+ return result;
}
public String engineGetCertificateAlias(Certificate cert)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return null;
- }
- if (!(keyring instanceof IPublicKeyring))
- {
- throw new IllegalStateException("not a public keyring");
- }
- Enumeration aliases = keyring.aliases();
- while (aliases.hasMoreElements())
+ log.entering(this.getClass().getName(), "engineGetCertificateAlias", cert);
+
+ ensureLoaded();
+ String result = null;
+ for (Enumeration aliases = publicKR.aliases(); aliases.hasMoreElements();)
{
String alias = (String) aliases.nextElement();
- Certificate cert2 = ((IPublicKeyring) keyring).getCertificate(alias);
+ Certificate cert2 = publicKR.getCertificate(alias);
if (cert.equals(cert2))
{
- return alias;
+ result = alias;
+ break;
}
}
- return null;
+
+ log.exiting(this.getClass().getName(), "engineGetCertificateAlias", result);
+ return result;
}
public void engineSetCertificateEntry(String alias, Certificate cert)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- keyring = new GnuPublicKeyring("HMAC-SHA-1", 20);
- }
- if (!(keyring instanceof IPublicKeyring))
- {
- throw new IllegalStateException("not a public keyring");
- }
- ((IPublicKeyring) keyring).putCertificate(alias, cert);
+ log.entering(this.getClass().getName(), "engineSetCertificateEntry",
+ new Object[] { alias, cert });
+
+ ensureLoaded();
+ publicKR.putCertificate(alias, cert);
+
+ log.exiting(this.getClass().getName(), "engineSetCertificateEntry");
}
public Certificate[] engineGetCertificateChain(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return null;
- }
- if (!(keyring instanceof IPrivateKeyring))
- {
- throw new IllegalStateException("not a private keyring");
- }
- return ((IPrivateKeyring) keyring).getCertPath(alias);
+ log.entering(this.getClass().getName(), "engineGetCertificateChain", alias);
+
+ ensureLoaded();
+ Certificate[] result = privateKR.getCertPath(alias);
+
+ log.exiting(this.getClass().getName(), "engineGetCertificateChain", result);
+ return result;
}
public Date engineGetCreationDate(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return null;
- }
- List entries = keyring.get(alias);
- if (entries.size() == 0)
- {
- return null;
- }
- for (Iterator it = entries.iterator(); it.hasNext();)
- {
- Object o = it.next();
- if (o instanceof PrimitiveEntry)
- {
- return ((PrimitiveEntry) o).getCreationDate();
- }
- }
- return null;
+ log.entering(this.getClass().getName(), "engineGetCreationDate", alias);
+
+ ensureLoaded();
+ Date result = getCreationDate(alias, privateKR);
+ if (result == null)
+ result = getCreationDate(alias, publicKR);
+
+ log.exiting(this.getClass().getName(), "engineGetCreationDate", result);
+ return result;
}
public Key engineGetKey(String alias, char[] password)
throws UnrecoverableKeyException
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return null;
- }
- if (!(keyring instanceof IPrivateKeyring))
- {
- throw new IllegalStateException("not a private keyring");
- }
+ log.entering(this.getClass().getName(), "engineGetKey",
+ String.valueOf(password));
+
+ ensureLoaded();
+ Key result = null;
if (password == null)
{
- if (((IPrivateKeyring) keyring).containsPublicKey(alias))
- {
- return ((IPrivateKeyring) keyring).getPublicKey(alias);
- }
- }
- if (((IPrivateKeyring) keyring).containsPrivateKey(alias))
- {
- return ((IPrivateKeyring) keyring).getPrivateKey(alias, password);
+ if (privateKR.containsPublicKey(alias))
+ result = privateKR.getPublicKey(alias);
}
- return null;
+ else if (privateKR.containsPrivateKey(alias))
+ result = privateKR.getPrivateKey(alias, password);
+
+ log.exiting(this.getClass().getName(), "engineGetKey", result);
+ return result;
}
public void engineSetKeyEntry(String alias, Key key, char[] password,
- Certificate[] chain) throws KeyStoreException
+ Certificate[] chain)
+ throws KeyStoreException
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- keyring = new GnuPrivateKeyring("HMAC-SHA-1", 20, "AES", "OFB", 16);
- }
- if (!(keyring instanceof IPrivateKeyring))
- {
- throw new IllegalStateException("not a private keyring");
- }
+ log.entering(this.getClass().getName(), "engineSetKeyEntry",
+ new Object[] { alias, key, password, chain });
+ ensureLoaded();
if (key instanceof PublicKey)
+ privateKR.putPublicKey(alias, (PublicKey) key);
+ else
{
- ((IPrivateKeyring) keyring).putPublicKey(alias, (PublicKey) key);
- return;
+ if (! (key instanceof PrivateKey) && ! (key instanceof SecretKey))
+ throw new KeyStoreException("cannot store keys of type "
+ + key.getClass().getName());
+ privateKR.putCertPath(alias, chain);
+ log.finest("About to put private key in keyring...");
+ privateKR.putPrivateKey(alias, key, password);
}
- if (!(key instanceof PrivateKey) && !(key instanceof SecretKey))
- {
- throw new KeyStoreException("cannot store keys of type "
- + key.getClass().getName());
- }
- try
- {
- CertificateFactory fact = CertificateFactory.getInstance("X.509");
- ((IPrivateKeyring) keyring).putCertPath(alias, chain);
- }
- catch (CertificateException ce)
- {
- throw new KeyStoreException(ce.toString());
- }
- ((IPrivateKeyring) keyring).putPrivateKey(alias, key, password);
+
+ log.exiting(this.getClass().getName(), "engineSetKeyEntry");
}
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
throws KeyStoreException
{
- throw new KeyStoreException("method not supported");
+ KeyStoreException x = new KeyStoreException("method not supported");
+ log.throwing(this.getClass().getName(), "engineSetKeyEntry(3)", x);
+ throw x;
}
public boolean engineIsCertificateEntry(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return false;
- }
- if (!(keyring instanceof IPublicKeyring))
- {
- return false;
- }
- return ((IPublicKeyring) keyring).containsCertificate(alias);
+ log.entering(this.getClass().getName(), "engineIsCertificateEntry", alias);
+
+ ensureLoaded();
+ boolean result = publicKR.containsCertificate(alias);
+
+ log.exiting(this.getClass().getName(), "engineIsCertificateEntry",
+ Boolean.valueOf(result));
+ return result;
}
public boolean engineIsKeyEntry(String alias)
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return false;
- }
- if (!(keyring instanceof IPrivateKeyring))
- {
- return false;
- }
- return ((IPrivateKeyring) keyring).containsPublicKey(alias)
- || ((IPrivateKeyring) keyring).containsPrivateKey(alias);
+ log.entering(this.getClass().getName(), "engineIsKeyEntry", alias);
+
+ ensureLoaded();
+ boolean result = privateKR.containsPublicKey(alias)
+ || privateKR.containsPrivateKey(alias);
+
+ log.exiting(this.getClass().getName(), "engineIsKeyEntry",
+ Boolean.valueOf(result));
+ return result;
}
public void engineLoad(InputStream in, char[] password) throws IOException
{
+ log.entering(this.getClass().getName(), "engineLoad", String.valueOf(password));
if (in != null)
{
- if (!in.markSupported())
- {
- in = new BufferedInputStream(in);
- }
- in.mark(5);
- for (int i = 0; i < 4; i++)
- if (in.read() != Registry.GKR_MAGIC[i])
- throw new MalformedKeyringException("incorrect magic");
- int usage = in.read();
- in.reset();
- HashMap attr = new HashMap();
- attr.put(IKeyring.KEYRING_DATA_IN, in);
- attr.put(IKeyring.KEYRING_PASSWORD, password);
- switch (usage)
- {
- case GnuPublicKeyring.USAGE:
- keyring = new GnuPublicKeyring();
- break;
- case GnuPrivateKeyring.USAGE:
- keyring = new GnuPrivateKeyring();
- break;
- default:
- throw new MalformedKeyringException("unsupported ring usage: "
- + Integer.toBinaryString(usage));
- }
- keyring.load(attr);
+ if (! in.markSupported())
+ in = new BufferedInputStream(in);
+
+ loadPrivateKeyring(in, password);
+ loadPublicKeyring(in, password);
}
+ else
+ createNewKeyrings();
+
loaded = true;
+
+ log.exiting(this.getClass().getName(), "engineLoad");
}
public void engineStore(OutputStream out, char[] password) throws IOException
{
- if (!loaded || keyring == null)
- {
- throw new IllegalStateException ("not loaded");
- }
+ log.entering(this.getClass().getName(), "engineStore", String.valueOf(password));
+
+ ensureLoaded();
HashMap attr = new HashMap();
attr.put(IKeyring.KEYRING_DATA_OUT, out);
attr.put(IKeyring.KEYRING_PASSWORD, password);
- keyring.store(attr);
+
+ privateKR.store(attr);
+ publicKR.store(attr);
+
+ log.exiting(this.getClass().getName(), "engineStore");
}
public int engineSize()
{
- if (!loaded)
- {
- throw new IllegalStateException ("not loaded");
- }
- if (keyring == null)
- {
- return 0;
- }
- return keyring.size();
+ ensureLoaded();
+ return privateKR.size() + publicKR.size();
+ }
+
+ /**
+ * Ensure that the underlying keyring pair is loaded. Throw an exception if it
+ * isn't; otherwise returns silently.
+ *
+ * @throws IllegalStateException if the keyring is not loaded.
+ */
+ private void ensureLoaded()
+ {
+ if (! loaded)
+ throw new IllegalStateException(NOT_LOADED);
+ }
+
+ /**
+ * Load the private keyring from the designated input stream.
+ *
+ * @param in the input stream to process.
+ * @param password the password protecting the keyring.
+ * @throws MalformedKeyringException if the keyring is not a private one.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ private void loadPrivateKeyring(InputStream in, char[] password)
+ throws MalformedKeyringException, IOException
+ {
+ log.entering(this.getClass().getName(), "loadPrivateKeyring");
+
+ in.mark(5);
+ for (int i = 0; i < 4; i++)
+ if (in.read() != Registry.GKR_MAGIC[i])
+ throw new MalformedKeyringException("incorrect magic");
+
+ int usage = in.read();
+ in.reset();
+ if (usage != GnuPrivateKeyring.USAGE)
+ throw new MalformedKeyringException("Was expecting a private keyring but got a wrong USAGE: "
+ + Integer.toBinaryString(usage));
+ HashMap attr = new HashMap();
+ attr.put(IKeyring.KEYRING_DATA_IN, in);
+ attr.put(IKeyring.KEYRING_PASSWORD, password);
+ privateKR = new GnuPrivateKeyring();
+ privateKR.load(attr);
+
+ log.exiting(this.getClass().getName(), "loadPrivateKeyring");
+ }
+
+ /**
+ * Load the public keyring from the designated input stream.
+ *
+ * @param in the input stream to process.
+ * @param password the password protecting the keyring.
+ * @throws MalformedKeyringException if the keyring is not a public one.
+ * @throws IOException if an I/O related exception occurs during the process.
+ */
+ private void loadPublicKeyring(InputStream in, char[] password)
+ throws MalformedKeyringException, IOException
+ {
+ log.entering(this.getClass().getName(), "loadPublicKeyring");
+
+ in.mark(5);
+ for (int i = 0; i < 4; i++)
+ if (in.read() != Registry.GKR_MAGIC[i])
+ throw new MalformedKeyringException("incorrect magic");
+
+ int usage = in.read();
+ in.reset();
+ if (usage != GnuPublicKeyring.USAGE)
+ throw new MalformedKeyringException("Was expecting a public keyring but got a wrong USAGE: "
+ + Integer.toBinaryString(usage));
+ HashMap attr = new HashMap();
+ attr.put(IKeyring.KEYRING_DATA_IN, in);
+ attr.put(IKeyring.KEYRING_PASSWORD, password);
+ publicKR = new GnuPublicKeyring();
+ publicKR.load(attr);
+
+ log.exiting(this.getClass().getName(), "loadPublicKeyring");
+ }
+
+ /**
+ * Return the creation date of a named alias in a designated keyring.
+ *
+ * @param alias the alias to look for.
+ * @param keyring the keyring to search.
+ * @return the creattion date of the entry named <code>alias</code>. Return
+ * <code>null</code> if <code>alias</code> was not found in
+ * <code>keyring</code>.
+ */
+ private Date getCreationDate(String alias, IKeyring keyring)
+ {
+ log.entering(this.getClass().getName(), "getCreationDate",
+ new Object[] { alias, keyring });
+
+ Date result = null;
+ if (keyring != null)
+ for (Iterator it = keyring.get(alias).iterator(); it.hasNext();)
+ {
+ Object o = it.next();
+ if (o instanceof PrimitiveEntry)
+ {
+ result = ((PrimitiveEntry) o).getCreationDate();
+ break;
+ }
+ }
+
+ log.exiting(this.getClass().getName(), "getCreationDate", result);
+ return result;
+ }
+
+ /** Create empty keyrings. */
+ private void createNewKeyrings()
+ {
+ log.entering(this.getClass().getName(), "createNewKeyrings");
+
+ privateKR = new GnuPrivateKeyring("HMAC-SHA-1", 20, "AES", "OFB", 16);
+ publicKR = new GnuPublicKeyring("HMAC-SHA-1", 20);
+
+ log.exiting(this.getClass().getName(), "createNewKeyrings");
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
index 935f5e5a3e2..dd489639f29 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD2Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-MD2 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacMD2Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacMD2Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD2_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
index 49507a6dd5f..6fadf02621b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD4Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-MD4 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacMD4Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacMD4Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD4_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
index 3bc0fea6b30..2ef43974f82 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacMD5Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-MD5 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacMD5Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacMD5Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.MD5_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
index 6a57e6c9d4e..ad7a2340eed 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD128Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-RIPEMD-128 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacRipeMD128Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacRipeMD128Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.RIPEMD128_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
index a47e1a5c74b..c14e3b3bf24 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacRipeMD160Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-RIPEMD-160 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacRipeMD160Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacRipeMD160Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.RIPEMD160_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
index e251dc373ab..f102c9ebcde 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA160Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-SHA-160 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacSHA160Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacSHA160Spi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.SHA160_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
index 7caa260415e..cadad1cf5fa 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA256Spi.java
@@ -42,8 +42,6 @@ import gnu.java.security.Registry;
/**
* <p>The implementation of the HMAC-SHA-256 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
- *
- * @version $Revision: 1.1 $
*/
public final class HMacSHA256Spi extends MacAdapter
{
@@ -64,4 +62,4 @@ public final class HMacSHA256Spi extends MacAdapter
// Instance methods
// -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
index d3e454b54d6..69ef38e50f6 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA384Spi.java
@@ -42,8 +42,6 @@ import gnu.java.security.Registry;
/**
* <p>The implementation of the HMAC-SHA-384 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
- *
- * @version $Revision: 1.1 $
*/
public class HMacSHA384Spi extends MacAdapter
{
@@ -64,4 +62,4 @@ public class HMacSHA384Spi extends MacAdapter
// Instance methods
// -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
index f02267c847d..abceb4a92c9 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacSHA512Spi.java
@@ -42,8 +42,6 @@ import gnu.java.security.Registry;
/**
* <p>The implementation of the HMAC-SHA-512 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
- *
- * @version $Revision: 1.1 $
*/
public class HMacSHA512Spi extends MacAdapter
{
@@ -64,4 +62,4 @@ public class HMacSHA512Spi extends MacAdapter
// Instance methods
// -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
index e4eb26ca948..511993ea413 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacTigerSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the Tiger <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacTigerSpi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacTigerSpi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.TIGER_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
index 8e2ef6d2f8d..706e0cd5a6b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/HMacWhirlpoolSpi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the HMAC-Whirlpool <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class HMacWhirlpoolSpi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class HMacWhirlpoolSpi extends MacAdapter
{
super(Registry.HMAC_NAME_PREFIX + Registry.WHIRLPOOL_HASH);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java b/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
index c323413a4a8..dc019ca20f4 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/MacAdapter.java
@@ -57,8 +57,6 @@ import javax.crypto.MacSpi;
* the {@link javax.crypto.Mac} class, which provides the functionality of a
* message authentication code algorithm, such as the <i>Hashed Message
* Authentication Code</i> (<b>HMAC</b>) algorithms.</p>
- *
- * @version $Revision: 1.2 $
*/
class MacAdapter extends MacSpi implements Cloneable
{
@@ -153,4 +151,4 @@ class MacAdapter extends MacSpi implements Cloneable
{
mac.update(in, off, len);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
index 0a4222237ef..1734e1e695b 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/TMMH16Spi.java
@@ -50,8 +50,6 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* The implementation of the TMMH16 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class TMMH16Spi extends MacAdapter
{
@@ -88,4 +86,4 @@ public final class TMMH16Spi extends MacAdapter
throw new InvalidAlgorithmParameterException(iae.getMessage());
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
index a24b8e59c9f..af678c0fa8a 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/UHash32Spi.java
@@ -43,8 +43,6 @@ import gnu.java.security.Registry;
/**
* The implementation of the UHash-32 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class UHash32Spi extends MacAdapter
{
@@ -56,4 +54,4 @@ public final class UHash32Spi extends MacAdapter
{
super(Registry.UHASH32);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java b/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
index 52c58f36f75..4e90468b10c 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/mac/UMac32Spi.java
@@ -50,8 +50,6 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* The implementation of the UMAC-32 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
- *
- * @version $Revision: 1.1 $
*/
public final class UMac32Spi extends MacAdapter
{
@@ -88,4 +86,4 @@ public final class UMac32Spi extends MacAdapter
throw new InvalidAlgorithmParameterException(iae.getMessage());
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
index 5b3badc8d83..0d09d5cef2c 100644
--- a/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
+++ b/libjava/classpath/gnu/javax/crypto/jce/sig/DHKeyPairGeneratorSpi.java
@@ -44,6 +44,7 @@ import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
import javax.crypto.spec.DHGenParameterSpec;
+import javax.crypto.spec.DHParameterSpec;
import gnu.java.security.Registry;
import gnu.java.security.jce.sig.KeyPairGeneratorAdapter;
@@ -75,7 +76,8 @@ public class DHKeyPairGeneratorSpi
HashMap attributes = new HashMap();
if (params != null)
{
- if (! (params instanceof DHGenParameterSpec))
+ if (! (params instanceof DHGenParameterSpec) &&
+ ! (params instanceof DHParameterSpec))
throw new InvalidAlgorithmParameterException("params");
attributes.put(GnuDHKeyPairGenerator.DH_PARAMETERS, params);
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
index 6b9cf70b67c..0be82bfb492 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/DiffieHellmanSender.java
@@ -55,7 +55,6 @@ import javax.crypto.interfaces.DHPrivateKey;
* Diffie-Hellman key agreement exchange (A in [HAC]).</p>
*
* @see DiffieHellmanKeyAgreement
- * @version $Revision: 1.1 $
*/
public class DiffieHellmanSender extends DiffieHellmanKeyAgreement
{
diff --git a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
index eafc8d01c1f..5626a2979a8 100644
--- a/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/key/dh/GnuDHKeyPairGenerator.java
@@ -187,9 +187,19 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
}
else if (params instanceof DHParameterSpec)
{
+ // FIXME: I'm not sure this is correct. It seems to behave the
+ // same way as Sun's RI, but I don't know if this behavior is
+ // documented anywhere.
DHParameterSpec jceSpec = (DHParameterSpec) params;
- l = jceSpec.getP().bitLength();
+ p = jceSpec.getP();
+ g = jceSpec.getG();
+ l = p.bitLength();
m = jceSpec.getL();
+
+ // If no exponent size was given, generate an exponent as
+ // large as the prime.
+ if (m == 0)
+ m = l;
}
else
{
@@ -242,7 +252,12 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
}
// generate a private number x of length m such as: 1 < x < q - 1
- BigInteger q_minus_1 = q.subtract(BigInteger.ONE);
+ BigInteger q_minus_1 = null;
+ if (q != null)
+ q_minus_1 = q.subtract(BigInteger.ONE);
+
+ // We already check if m is modulo 8 in `setup.' This could just
+ // be m >>> 3.
byte[] mag = new byte[(m + 7) / 8];
BigInteger x;
while (true)
@@ -250,7 +265,7 @@ public class GnuDHKeyPairGenerator implements IKeyPairGenerator
nextRandomBytes(mag);
x = new BigInteger(1, mag);
if (x.bitLength() == m && x.compareTo(BigInteger.ONE) > 0
- && x.compareTo(q_minus_1) < 0)
+ && (q_minus_1 == null || x.compareTo(q_minus_1) < 0))
{
break;
}
diff --git a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
index 23e4440773b..ecbe36f62b1 100644
--- a/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
+++ b/libjava/classpath/gnu/javax/crypto/key/srp6/SRP6TLSServer.java
@@ -61,8 +61,6 @@ import java.util.Map;
* SRP for TLS Authentication</a>. The only difference between it and the SASL
* variant is that the shared secret is the entity <code>S</code> and not
* <code>H(S)</code>.</p>
- *
- * @version $Revision: 1.1 $
*/
public class SRP6TLSServer extends SRP6KeyAgreement
{
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
index d49bd09636d..c1fe30e677b 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/GnuPrivateKeyring.java
@@ -42,8 +42,8 @@ import gnu.java.security.Registry;
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.security.Key;
import java.security.PublicKey;
@@ -51,17 +51,18 @@ import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.util.Date;
import java.util.Iterator;
-import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* <p>.</p>
*/
public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
{
-
// Constants and variables
// -------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(GnuPrivateKeyring.class.getName());
public static final int USAGE = Registry.GKR_PRIVATE_KEYS
| Registry.GKR_PUBLIC_CREDENTIALS;
@@ -104,225 +105,277 @@ public class GnuPrivateKeyring extends BaseKeyring implements IPrivateKeyring
public boolean containsPrivateKey(String alias)
{
- if (!containsAlias(alias))
- {
- return false;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
+ log.entering(this.getClass().getName(), "containsPrivateKey", alias);
+
+ boolean result = false;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
if (it.next() instanceof PasswordAuthenticatedEntry)
{
- return true;
+ result = true;
+ break;
}
- }
- return false;
+
+ log.exiting(this.getClass().getName(), "containsPrivateKey",
+ Boolean.valueOf(result));
+ return result;
}
public Key getPrivateKey(String alias, char[] password)
throws UnrecoverableKeyException
{
- if (!containsAlias(alias))
- {
- return null;
- }
- List l = get(alias);
- PasswordAuthenticatedEntry e1 = null;
- PasswordEncryptedEntry e2 = null;
- for (Iterator it = l.iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e instanceof PasswordAuthenticatedEntry)
- {
- e1 = (PasswordAuthenticatedEntry) e;
- break;
- }
- }
- if (e1 == null)
- {
- return null;
- }
- try
- {
- e1.verify(password);
- }
- catch (Exception e)
- {
- throw new UnrecoverableKeyException("authentication failed");
- }
- for (Iterator it = e1.getEntries().iterator(); it.hasNext();)
+ log.entering(this.getClass().getName(), "getPrivateKey",
+ new Object[] { alias, String.valueOf(password) });
+
+ Key result = null;
+ if (containsAlias(alias))
{
- Entry e = (Entry) it.next();
- if (e instanceof PasswordEncryptedEntry)
+ PasswordAuthenticatedEntry e1 = null;
+ PasswordEncryptedEntry e2 = null;
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
{
- e2 = (PasswordEncryptedEntry) e;
- break;
+ Entry e = (Entry) it.next();
+ if (e instanceof PasswordAuthenticatedEntry)
+ {
+ e1 = (PasswordAuthenticatedEntry) e;
+ break;
+ }
}
- }
- if (e2 == null)
- {
- return null;
- }
- try
- {
- e2.decrypt(password);
- }
- catch (Exception e)
- {
- throw new UnrecoverableKeyException("decryption failed");
- }
- for (Iterator it = e2.get(alias).iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e instanceof PrivateKeyEntry)
+
+ if (e1 != null)
{
- return ((PrivateKeyEntry) e).getKey();
+ try
+ {
+ e1.verify(password);
+ }
+ catch (Exception e)
+ {
+ throw new UnrecoverableKeyException("authentication failed");
+ }
+
+ for (Iterator it = e1.getEntries().iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e instanceof PasswordEncryptedEntry)
+ {
+ e2 = (PasswordEncryptedEntry) e;
+ break;
+ }
+ }
+
+ if (e2 != null)
+ {
+ try
+ {
+ e2.decrypt(password);
+ }
+ catch (Exception e)
+ {
+ throw new UnrecoverableKeyException("decryption failed");
+ }
+
+ for (Iterator it = e2.get(alias).iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e instanceof PrivateKeyEntry)
+ {
+ result = ((PrivateKeyEntry) e).getKey();
+ break;
+ }
+ }
+ }
}
}
- return null;
+
+ log.exiting(this.getClass().getName(), "getPrivateKey", result);
+ return result;
}
public void putPrivateKey(String alias, Key key, char[] password)
{
- if (containsPrivateKey(alias))
- {
- return;
- }
- alias = fixAlias(alias);
- Properties p = new Properties();
- p.put("alias", alias);
- PrivateKeyEntry pke = new PrivateKeyEntry(key, new Date(), p);
- PasswordEncryptedEntry enc = new PasswordEncryptedEntry(cipher, mode,
- keylen,
- new Properties());
- PasswordAuthenticatedEntry auth = new PasswordAuthenticatedEntry(
- mac,
- maclen,
- new Properties());
- enc.add(pke);
- auth.add(enc);
- try
- {
- enc.encode(null, password);
- auth.encode(null, password);
- }
- catch (IOException ioe)
+ log.entering(this.getClass().getName(), "putPrivateKey",
+ new Object[] { alias, key, String.valueOf(password) });
+
+ if (! containsPrivateKey(alias))
{
- throw new IllegalArgumentException(ioe.toString());
+ alias = fixAlias(alias);
+ Properties p = new Properties();
+ p.put("alias", alias);
+ PrivateKeyEntry pke = new PrivateKeyEntry(key, new Date(), p);
+ PasswordEncryptedEntry enc;
+ enc = new PasswordEncryptedEntry(cipher, mode, keylen, new Properties());
+ enc.add(pke);
+
+ PasswordAuthenticatedEntry auth;
+ auth = new PasswordAuthenticatedEntry(mac, maclen, new Properties());
+ auth.add(enc);
+
+ log.finest("About to encrypt the key...");
+ try
+ {
+ enc.encode(null, password);
+ }
+ catch (IOException x)
+ {
+ log.log(Level.FINER, "Exception while encrypting the key. "
+ + "Rethrow as IllegalArgumentException", x);
+ throw new IllegalArgumentException(x.toString());
+ }
+
+ log.finest("About to authenticate the encrypted key...");
+ try
+ {
+ auth.encode(null, password);
+ }
+ catch (IOException x)
+ {
+ log.log(Level.FINER, "Exception while authenticating the encrypted "
+ + "key. Rethrow as IllegalArgumentException", x);
+ throw new IllegalArgumentException(x.toString());
+ }
+
+ keyring.add(auth);
}
- keyring.add(auth);
+ else
+ log.finer("Keyring already contains alias: " + alias);
+
+ log.exiting(this.getClass().getName(), "putPrivateKey");
}
public boolean containsPublicKey(String alias)
{
- if (!containsAlias(alias))
- {
- return false;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
+ log.entering(this.getClass().getName(), "containsPublicKey", alias);
+
+ boolean result = false;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
if (it.next() instanceof PublicKeyEntry)
{
- return true;
+ result = true;
+ break;
}
- }
- return false;
+
+ log.exiting(this.getClass().getName(), "containsPublicKey",
+ Boolean.valueOf(result));
+ return result;
}
public PublicKey getPublicKey(String alias)
{
- if (!containsAlias(alias))
- {
- return null;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e instanceof PublicKeyEntry)
- {
- return ((PublicKeyEntry) e).getKey();
- }
- }
- return null;
+ log.entering(this.getClass().getName(), "getPublicKey", alias);
+
+ PublicKey result = null;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e instanceof PublicKeyEntry)
+ {
+ result = ((PublicKeyEntry) e).getKey();
+ break;
+ }
+ }
+
+ log.exiting(this.getClass().getName(), "getPublicKey", result);
+ return result;
}
public void putPublicKey(String alias, PublicKey key)
{
- if (containsPublicKey(alias))
+ log.entering(this.getClass().getName(), "putPublicKey",
+ new Object[] { alias, key });
+
+ if (! containsPublicKey(alias))
{
- return;
+ Properties p = new Properties();
+ p.put("alias", fixAlias(alias));
+ add(new PublicKeyEntry(key, new Date(), p));
}
- Properties p = new Properties();
- p.put("alias", fixAlias(alias));
- add(new PublicKeyEntry(key, new Date(), p));
+ else
+ log.finer("Keyring already contains alias: " + alias);
+
+ log.exiting(this.getClass().getName(), "putPublicKey");
}
public boolean containsCertPath(String alias)
{
- if (!containsAlias(alias))
- {
- return false;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
+ log.entering(this.getClass().getName(), "containsCertPath", alias);
+
+ boolean result = false;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
if (it.next() instanceof CertPathEntry)
{
- return true;
+ result = true;
+ break;
}
- }
- return false;
+
+ log.exiting(this.getClass().getName(), "containsCertPath",
+ Boolean.valueOf(result));
+ return result;
}
public Certificate[] getCertPath(String alias)
{
- if (!containsAlias(alias))
- {
- return null;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e instanceof CertPathEntry)
- {
- return ((CertPathEntry) e).getCertPath();
- }
- }
- return null;
+ log.entering(this.getClass().getName(), "getCertPath", alias);
+
+ Certificate[] result = null;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e instanceof CertPathEntry)
+ {
+ result = ((CertPathEntry) e).getCertPath();
+ break;
+ }
+ }
+
+ log.exiting(this.getClass().getName(), "getCertPath", result);
+ return result;
}
public void putCertPath(String alias, Certificate[] path)
{
- if (containsCertPath(alias))
+ log.entering(this.getClass().getName(), "putCertPath",
+ new Object[] { alias, path });
+
+ if (! containsCertPath(alias))
{
- return;
+ Properties p = new Properties();
+ p.put("alias", fixAlias(alias));
+ add(new CertPathEntry(path, new Date(), p));
}
- Properties p = new Properties();
- p.put("alias", fixAlias(alias));
- add(new CertPathEntry(path, new Date(), p));
+ else
+ log.finer("Keyring already contains alias: " + alias);
+
+ log.exiting(this.getClass().getName(), "putCertPath");
}
protected void load(InputStream in, char[] password) throws IOException
{
+ log.entering(this.getClass().getName(), "load",
+ new Object[] { in, String.valueOf(password) });
+
if (in.read() != USAGE)
- {
- throw new MalformedKeyringException("incompatible keyring usage");
- }
+ throw new MalformedKeyringException("incompatible keyring usage");
+
if (in.read() != PasswordAuthenticatedEntry.TYPE)
- {
- throw new MalformedKeyringException(
- "expecting password-authenticated entry tag");
- }
- keyring = PasswordAuthenticatedEntry.decode(new DataInputStream(in),
- password);
+ throw new MalformedKeyringException("expecting password-authenticated entry tag");
+
+ keyring = PasswordAuthenticatedEntry.decode(new DataInputStream(in), password);
+
+ log.exiting(this.getClass().getName(), "load");
}
protected void store(OutputStream out, char[] password) throws IOException
{
+ log.entering(this.getClass().getName(), "store",
+ new Object[] { out, String.valueOf(password) });
+
out.write(USAGE);
keyring.encode(new DataOutputStream(out), password);
+
+ log.exiting(this.getClass().getName(), "store");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
index 318eb036fc8..490eb4458fa 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/GnuPublicKeyring.java
@@ -38,26 +38,24 @@ exception statement from your version. */
package gnu.javax.crypto.keyring;
+import gnu.java.security.Registry;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
+import java.security.cert.Certificate;
import java.util.Date;
import java.util.Iterator;
-import java.util.List;
-
-import java.security.cert.Certificate;
-
-import gnu.java.security.Registry;
+import java.util.logging.Logger;
public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
{
-
// Fields.
// ------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(GnuPublicKeyring.class.getName());
public static final int USAGE = Registry.GKR_CERTIFICATES;
// Constructors.
@@ -79,68 +77,84 @@ public class GnuPublicKeyring extends BaseKeyring implements IPublicKeyring
public boolean containsCertificate(String alias)
{
- if (!containsAlias(alias))
- {
- return false;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
+ log.entering(this.getClass().getName(), "containsCertificate", alias);
+
+ boolean result = false;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
if (it.next() instanceof CertificateEntry)
{
- return true;
+ result = true;
+ break;
}
- }
- return false;
+
+ log.exiting(this.getClass().getName(), "containsCertificate",
+ Boolean.valueOf(result));
+ return result;
}
public Certificate getCertificate(String alias)
{
- if (!containsAlias(alias))
- {
- return null;
- }
- List l = get(alias);
- for (Iterator it = l.iterator(); it.hasNext();)
- {
- Entry e = (Entry) it.next();
- if (e instanceof CertificateEntry)
- {
- return ((CertificateEntry) e).getCertificate();
- }
- }
- return null;
+ log.entering(this.getClass().getName(), "getCertificate", alias);
+
+ Certificate result = null;
+ if (containsAlias(alias))
+ for (Iterator it = get(alias).iterator(); it.hasNext();)
+ {
+ Entry e = (Entry) it.next();
+ if (e instanceof CertificateEntry)
+ {
+ result = ((CertificateEntry) e).getCertificate();
+ break;
+ }
+ }
+
+ log.exiting(this.getClass().getName(), "getCertificate", result);
+ return result;
}
public void putCertificate(String alias, Certificate cert)
{
- if (containsCertificate(alias))
+ log.entering(this.getClass().getName(), "putCertificate",
+ new Object[] { alias, cert });
+
+ if (! containsCertificate(alias))
{
- return;
+ Properties p = new Properties();
+ p.put("alias", fixAlias(alias));
+ add(new CertificateEntry(cert, new Date(), p));
}
- Properties p = new Properties();
- p.put("alias", fixAlias(alias));
- add(new CertificateEntry(cert, new Date(), p));
+ else
+ log.finer("Keyring already contains alias: " + alias);
+
+ log.exiting(this.getClass().getName(), "putCertificate");
}
protected void load(InputStream in, char[] password) throws IOException
{
+ log.entering(this.getClass().getName(), "load",
+ new Object[] { in, String.valueOf(password) });
+
if (in.read() != USAGE)
- {
- throw new MalformedKeyringException("incompatible keyring usage");
- }
+ throw new MalformedKeyringException("incompatible keyring usage");
+
if (in.read() != PasswordAuthenticatedEntry.TYPE)
- {
- throw new MalformedKeyringException(
- "expecting password-authenticated entry tag");
- }
- keyring = PasswordAuthenticatedEntry.decode(new DataInputStream(in),
- password);
+ throw new MalformedKeyringException("expecting password-authenticated entry tag");
+
+ DataInputStream dis = new DataInputStream(in);
+ keyring = PasswordAuthenticatedEntry.decode(dis, password);
+
+ log.exiting(this.getClass().getName(), "load");
}
protected void store(OutputStream out, char[] password) throws IOException
{
+ log.entering(this.getClass().getName(), "store",
+ new Object[] { out, String.valueOf(password) });
+
out.write(USAGE);
keyring.encode(new DataOutputStream(out), password);
+
+ log.exiting(this.getClass().getName(), "store");
}
}
diff --git a/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java b/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
index 30634991570..88249563341 100644
--- a/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
+++ b/libjava/classpath/gnu/javax/crypto/keyring/PrivateKeyEntry.java
@@ -57,8 +57,6 @@ import java.util.Date;
/**
* <p>An immutable class representing a private or secret key entry.</p>
- *
- * @version $Revision: 1.1 $
*/
public final class PrivateKeyEntry extends PrimitiveEntry
{
diff --git a/libjava/classpath/gnu/javax/crypto/mac/UMac32.java b/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
index d20d4f4a9fc..01388885699 100644
--- a/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
+++ b/libjava/classpath/gnu/javax/crypto/mac/UMac32.java
@@ -419,7 +419,7 @@ public class UMac32 extends BaseMac
mac.update(data, 0, 128);
byte[] result = mac.digest();
// System.out.println("UMAC test vector: "+Util.toString(result));
- valid = new Boolean(TV1.equals(Util.toString(result)));
+ valid = Boolean.valueOf(TV1.equals(Util.toString(result)));
}
return valid.booleanValue();
}
diff --git a/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java b/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
index d89c0016d85..989e3edbcd0 100644
--- a/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
+++ b/libjava/classpath/gnu/javax/crypto/mode/IAuthenticatedMode.java
@@ -50,11 +50,9 @@ import gnu.javax.crypto.mac.IMac;
* is done via the {@link IMac#digest()} method, and header updating
* (if supported by the mode) is done via the {@link
* IMac#update(byte[],int,int)} method.
- *
- * @version $Revision: 1.1 $
*/
public interface IAuthenticatedMode extends IMode, IMac
{
// Trivial conjunction of IMode and IMac.
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java b/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
index e122719b62b..913d69dcbaf 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/PadFactory.java
@@ -84,7 +84,7 @@ public class PadFactory implements Registry
if (pad.endsWith("padding"))
pad = pad.substring(0, pad.length() - "padding".length());
IPad result = null;
- if (pad.equals(PKCS7_PAD))
+ if (pad.equals(PKCS7_PAD) || pad.equals(PKCS5_PAD))
{
result = new PKCS7();
}
@@ -122,6 +122,7 @@ public class PadFactory implements Registry
public static final Set getNames()
{
HashSet hs = new HashSet();
+ hs.add(PKCS5_PAD);
hs.add(PKCS7_PAD);
hs.add(TBC_PAD);
hs.add(EME_PKCS1_V1_5_PAD);
@@ -133,4 +134,4 @@ public class PadFactory implements Registry
// Instance methods
// -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java b/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
index cc74dfb26bf..e477cf303c7 100644
--- a/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
+++ b/libjava/classpath/gnu/javax/crypto/pad/WrongPaddingException.java
@@ -41,8 +41,6 @@ package gnu.javax.crypto.pad;
/**
* <p>A checked exception that indicates that a padding algorithm did not find the
* expected padding bytes when unpadding some data.</p>
- *
- * @version $Revision: 1.1 $
*/
public class WrongPaddingException extends Exception
{
@@ -60,4 +58,4 @@ public class WrongPaddingException extends Exception
// Instant methods
// -------------------------------------------------------------------------
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java b/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
index 197009232bc..6585dcb907a 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/CSPRNG.java
@@ -364,7 +364,7 @@ public class CSPRNG extends BasePRNG
{
CSPRNG instance = new CSPRNG();
HashMap attrib = new HashMap();
- attrib.put(BLOCKING, new Boolean(getProperty(BLOCK)));
+ attrib.put(BLOCKING, Boolean.valueOf(getProperty(BLOCK)));
String s = null;
// Get each file source "gnu.crypto.csprng.file.N".
diff --git a/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java b/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
index 6453a9d02d0..69ce860f451 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/Fortuna.java
@@ -142,6 +142,14 @@ public class Fortuna extends BasePRNG implements Serializable,
pool = 0;
pool0Count = 0;
generator.init(attributes);
+ try
+ {
+ fillBlock ();
+ }
+ catch (LimitReachedException shouldNotHappen)
+ {
+ throw new RuntimeException (shouldNotHappen);
+ }
}
public void fillBlock() throws LimitReachedException
@@ -324,6 +332,7 @@ public class Fortuna extends BasePRNG implements Serializable,
byte[] seed = (byte[]) attributes.get(SEED);
if (seed != null)
addRandomBytes(seed);
+ fillBlock ();
}
/**
diff --git a/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java b/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
index 0de38e256ea..7d4f4c9a32c 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/ICMGenerator.java
@@ -98,8 +98,6 @@ import java.util.Map;
* <li><a href="http://www.ietf.org/internet-drafts/draft-mcgrew-saag-icm-00.txt">
* Integer Counter Mode</a>, David A. McGrew.</li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public class ICMGenerator extends BasePRNG implements Cloneable
{
@@ -376,4 +374,4 @@ public class ICMGenerator extends BasePRNG implements Cloneable
cipher.encryptBlock(buffer, 0, buffer, 0);
blockNdx = blockNdx.add(BigInteger.ONE); // increment blockNdx
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/IPBE.java b/libjava/classpath/gnu/javax/crypto/prng/IPBE.java
index 531e7ead88a..66921d635d5 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/IPBE.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/IPBE.java
@@ -39,31 +39,43 @@ exception statement from your version. */
package gnu.javax.crypto.prng;
/**
- * <p>Trivial interface to group Password-based encryption property names.</p>
- *
- * @version $Revision: 1.1 $
+ * Trivial interface to group Password-based encryption property names and
+ * constants.
*/
public interface IPBE
{
-
- // Constants
- // -------------------------------------------------------------------------
-
/**
* Property name for the iteration count in a PBE algorithm. The property
* associated with this is expected to be an {@link Integer}.
*/
- public static final String ITERATION_COUNT = "gnu.crypto.pbe.iteration.count";
+ String ITERATION_COUNT = "gnu.crypto.pbe.iteration.count";
/**
* Property name for the password in a PBE algorithm. The property associated
* with this is expected to be a char array.
*/
- public static final String PASSWORD = "gnu.crypto.pbe.password";
+ String PASSWORD = "gnu.crypto.pbe.password";
+
+ /**
+ * Property name for the password character encoding in a PBE algorithm. The
+ * property associated with this is expected to be a String denoting a valid
+ * character-encoding name. If this property is not set, and a password is
+ * used, then {@link #DEFAULT_PASSWORD_ENCODING} will be used when converting
+ * the password character(s) to bytes.
+ */
+ String PASSWORD_ENCODING = "gnu.crypto.pbe.password.encoding";
/**
* Property name for the salt in a PBE algorithm. The property associated
* with this is expected to be a byte array.
*/
- public static final String SALT = "gnu.crypto.pbe.salt";
-} \ No newline at end of file
+ String SALT = "gnu.crypto.pbe.salt";
+
+ /**
+ * The default character set encoding name to be used if (a) a password is
+ * to be used as the source for a PBE-based Key Derivation Function (KDF) and
+ * (b) no character set encoding name was specified among the attributes used
+ * to initialize the instance.
+ */
+ String DEFAULT_PASSWORD_ENCODING = "UTF-8";
+}
diff --git a/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java b/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
index 5146bd4b9ab..d39cd0a6597 100644
--- a/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
+++ b/libjava/classpath/gnu/javax/crypto/prng/PBKDF2.java
@@ -62,8 +62,6 @@ import java.util.Map;
* <li>B. Kaliski, <a href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898:
* Password-Based Cryptography Specification, Version 2.0</a></li>
* </ol>
- *
- * @version $Revision: 1.1 $
*/
public class PBKDF2 extends BasePRNG implements Cloneable
{
@@ -129,23 +127,34 @@ public class PBKDF2 extends BasePRNG implements Cloneable
salt = s;
}
+ byte[] macKeyMaterial;
char[] password = (char[]) attributes.get(IPBE.PASSWORD);
if (password != null)
{
+ String encoding = (String) attributes.get(IPBE.PASSWORD_ENCODING);
+ if (encoding == null || encoding.trim().length() == 0)
+ encoding = IPBE.DEFAULT_PASSWORD_ENCODING;
+ else
+ encoding = encoding.trim();
+
try
{
- macAttrib.put(IMac.MAC_KEY_MATERIAL,
- new String(password).getBytes("UTF-8"));
+ macKeyMaterial = new String(password).getBytes(encoding);
}
catch (UnsupportedEncodingException uee)
{
- throw new Error(uee.getMessage());
+ throw new IllegalArgumentException("Unknown or unsupported encoding: "
+ + encoding, uee);
}
}
+ else
+ macKeyMaterial = (byte[]) attributes.get(IMac.MAC_KEY_MATERIAL);
+
+ if (macKeyMaterial != null)
+ macAttrib.put(IMac.MAC_KEY_MATERIAL, macKeyMaterial);
else if (!initialised)
- {
- throw new IllegalArgumentException("no password specified");
- } // otherwise re-use previous password.
+ throw new IllegalArgumentException("Neither password nor key-material were specified");
+ // otherwise re-use previous password/key-material
try
{
@@ -213,4 +222,4 @@ public class PBKDF2 extends BasePRNG implements Cloneable
}
}
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java b/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
index 561827d8d04..adfc06593f2 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/ConfidentialityException.java
@@ -44,8 +44,6 @@ import javax.security.sasl.SaslException;
* Used by mechanisms that offer a security services layer, this checked
* exception is thrown to indicate that a violation has occured during the
* processing of a <i>confidentiality</i> protection filter.
- *
- * @version $Revision: 1.1 $
*/
public class ConfidentialityException extends SaslException
{
@@ -81,4 +79,4 @@ public class ConfidentialityException extends SaslException
{
super(s, x);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java b/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
index 94d9269a1dc..b46ad98e316 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/IllegalMechanismStateException.java
@@ -46,8 +46,6 @@ import javax.security.sasl.AuthenticationException;
* that mechanism was not completed yet, or that an operation that should be
* invoked on incomplete mechanisms was invoked but the authentication phase of
* that mechanism was already completed.
- *
- * @version $Revision: 1.1 $
*/
public class IllegalMechanismStateException extends AuthenticationException
{
@@ -83,4 +81,4 @@ public class IllegalMechanismStateException extends AuthenticationException
{
super(detail, ex);
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
index cfaf22b1e02..51492f9773c 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/IALG.java
@@ -50,8 +50,6 @@ import javax.security.sasl.SaslException;
/**
* <p>A Factory class that returns IALG (Integrity Algorithm) instances that
* operate as described in the draft-burdis-cat-sasl-srp-04 and later.</p>
- *
- * @version $Revision: 1.1 $
*/
public final class IALG implements Cloneable
{
@@ -156,4 +154,4 @@ public final class IALG implements Cloneable
{
return hmac.macSize();
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
index 11902b82ed8..672660b261c 100644
--- a/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
+++ b/libjava/classpath/gnu/javax/crypto/sasl/srp/SRPServer.java
@@ -72,8 +72,6 @@ import javax.security.sasl.SaslServer;
/**
* <p>The SASL-SRP server-side mechanism.</p>
- *
- * @version $Revision: 1.2 $
*/
public class SRPServer extends ServerMechanism implements SaslServer
{
@@ -1153,4 +1151,4 @@ public class SRPServer extends ServerMechanism implements SaslServer
return prng;
}
-} \ No newline at end of file
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
index c4a582bfa20..df53f2e3dee 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPDecoder.java
@@ -41,7 +41,6 @@ import java.io.IOException;
import javax.imageio.stream.ImageInputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.BufferedImage;
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java
new file mode 100644
index 00000000000..fc8dcf00f67
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPEncoder.java
@@ -0,0 +1,119 @@
+/* BMPEncoder.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public abstract class BMPEncoder
+{
+
+ /**
+ * Constructs a new BMPEncoder.
+ */
+ public BMPEncoder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Determines the coding type of the bitmap and returns the corresponding
+ * encoder.
+ *
+ * @param fh - the file header
+ * @param ih - the info header
+ * @return the appropriate encoder
+ */
+ public static BMPEncoder getEncoder(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ switch (ih.getCompression())
+ {
+ case BMPInfoHeader.BI_RGB:
+ switch (ih.getBitCount())
+ {
+ case 32:
+ return new EncodeRGB32(fh, ih);
+
+ case 24:
+ return new EncodeRGB24(fh, ih);
+
+ case 16:
+ return new EncodeRGB16(fh, ih);
+
+ case 8:
+ return new EncodeRGB8(fh, ih);
+
+ case 4:
+ return new EncodeRGB4(fh, ih);
+
+ case 1:
+ return new EncodeRGB1(fh, ih);
+
+ default:
+ return null;
+ }
+ case BMPInfoHeader.BI_RLE4:
+ return new EncodeRLE4(fh, ih);
+
+ case BMPInfoHeader.BI_RLE8:
+ return new EncodeRLE8(fh, ih);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data, metadata and
+ * thumbnails to be written
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public abstract void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param)
+ throws IOException;
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
index 246e0eacfeb..4ba32d3c30a 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPFileHeader.java
@@ -37,27 +37,32 @@ exception statement from your version. */
package gnu.javax.imageio.bmp;
+import java.awt.image.RenderedImage;
import java.io.IOException;
-import javax.imageio.stream.ImageInputStream;
-import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import javax.imageio.IIOImage;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+
public class BMPFileHeader {
/** Header signature, always 'BM' */
private final static short bfType = 0x424d;
/** Bitmap file size, in bytes. */
- private long bfSize;
+ protected long bfSize;
/** Offset from the beginning of the file to the bitmap data */
- private long bfOffBits;
+ protected long bfOffBits;
/** BITMAPFILEHEADER is 14 bytes */
public static final int SIZE = 14;
-
+ private static final int BITMAPINFOHEADER_SIZE = 40;
+
/**
* Creates the header from an input stream, which is not closed.
+ *
* @throws IOException if an I/O error occured.
* @throws BMPException if the header was invalid
*/
@@ -82,17 +87,37 @@ public class BMPFileHeader {
bfOffBits = ((long)buf.getInt(10) & (0xFFFFFFFF));
}
+
+ /**
+ * Creates the header from an output stream, which is not closed.
+ *
+ * @param out - the image output stream
+ * @param im - the image
+ * @throws IOException if an I/O error occured.
+ */
+ public BMPFileHeader(ImageOutputStream out, IIOImage im) throws IOException
+ {
+ RenderedImage img = im.getRenderedImage();
+ int w = img.getWidth();
+ int h = img.getHeight();
+
+ bfOffBits = SIZE + BITMAPINFOHEADER_SIZE;
+ bfSize = ((w * h) * 3) + ((4 - ((w * 3) % 4)) * h) + bfOffBits;
+
+ write(out);
+ }
/**
* Writes the header to an output stream, which is not closed or flushed.
+ *
* @throws IOException if an I/O error occured.
*/
- public void write(OutputStream out) throws IOException {
+ public void write(ImageOutputStream out) throws IOException {
ByteBuffer buf = ByteBuffer.allocate(SIZE);
buf.putShort(0, bfType); // ID
buf.putInt(2, (int)(bfSize & (0xFFFFFFFF))); // size
buf.putInt(6, 0); // 4 reserved bytes set to zero
- buf.putInt(2, (int)(bfOffBits & (0xFFFFFFFF))); // size
+ buf.putInt(7, (int)(bfOffBits & (0xFFFFFFFF))); // size
out.write(buf.array());
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
index 3341d4b4aed..f1359da6adb 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReader.java
@@ -145,8 +145,6 @@ public class BMPImageReader extends ImageReader {
readHeaders();
return decoder.decode((ImageInputStream)input);
}
-
-
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
index b175c7d076b..cf8547c713f 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
@@ -54,9 +54,8 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
static final String[] MIMETypes = {
"image/bmp",
"image/x-windows-bmp"};
-
- static final String[] writerSpiNames = null;
- //{"com.mycompany.imageio.MyFormatImageWriterSpi" };
+ static final String[] writerSpiNames =
+ { "gnu.javax.imageio.bmp.BMPImageWriterSpi" };
static final boolean supportsStandardStreamMetadataFormat = false;
static final String nativeStreamMetadataFormatName = null;
@@ -73,7 +72,7 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
super(vendorName, version,
names, suffixes, MIMETypes,
readerClassName,
- STANDARD_INPUT_TYPE, // Accept ImageImageInputStreams
+ STANDARD_INPUT_TYPE, // Accept ImageInputStreams
writerSpiNames,
supportsStandardStreamMetadataFormat,
nativeStreamMetadataFormatName,
@@ -115,9 +114,3 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
return new BMPImageReader(this);
}
}
-
-
-
-
-
-
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java
new file mode 100644
index 00000000000..08b5041c967
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriter.java
@@ -0,0 +1,196 @@
+/* BMPImageWriter.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.stream.ImageOutputStream;
+
+public class BMPImageWriter
+ extends ImageWriter
+{
+ protected BMPEncoder encoder;
+ protected BMPFileHeader fileHeader;
+ protected BMPInfoHeader infoHeader;
+
+ /**
+ * Construct an bmp image writer.
+ *
+ * @param originatingProvider - the provider that is constructing this image
+ * writer, or null
+ */
+ protected BMPImageWriter(ImageWriterSpi originatingProvider)
+ {
+ super(originatingProvider);
+ encoder = null;
+ fileHeader = null;
+ infoHeader = null;
+ }
+
+ /**
+ * Convert IIOMetadata from an input reader format, returning an IIOMetadata
+ * suitable for use by an image writer. The ImageTypeSpecifier specifies the
+ * destination image type. An optional ImageWriteParam argument is available
+ * in case the image writing parameters affect the metadata conversion.
+ *
+ * @param inData - the metadata coming from an image reader
+ * @param imageType - the output image type of the writer
+ * @param param - the image writing parameters or null
+ * @return the converted metadata that should be used by the image writer, or
+ * null if this ImageTranscoder has no knowledge of the input metadata
+ * @exception IllegalArgumentException if either inData or imageType is null
+ */
+ public IIOMetadata convertImageMetadata(IIOMetadata inData,
+ ImageTypeSpecifier imageType,
+ ImageWriteParam param)
+ {
+ // FIXME: Support metadata.
+ if (inData == null || imageType == null)
+ throw new IllegalArgumentException("IIOMetadata and ImageTypeSpecifier cannot be null.");
+ return null;
+ }
+
+ /**
+ * Convert IIOMetadata from an input stream format, returning an
+ * IIOMetadata suitable for use by an image writer.
+ *
+ * An optional ImageWriteParam argument is available in case the
+ * image writing parameters affect the metadata conversion.
+ *
+ * @param inData - the metadata coming from an input image stream
+ * @param param - the image writing parameters or null
+ * @return the converted metadata that should be used by the image
+ * writer, or null if this ImageTranscoder has no knowledge of the
+ * input metadata
+ *
+ * @exception IllegalArgumentException if inData is null
+ */
+ public IIOMetadata convertStreamMetadata (IIOMetadata inData,
+ ImageWriteParam param)
+ {
+ // FIXME: Support metadata.
+ if (inData == null)
+ throw new IllegalArgumentException("IIOMetadata cannot be null.");
+ return null;
+ }
+
+ /**
+ * Get a metadata object appropriate for encoding an image specified
+ * by the given image type specifier and optional image write
+ * parameters.
+ *
+ * @param imageType - an image type specifier
+ * @param param - image writing parameters, or null
+ * @return a metadata object appropriate for encoding an image of
+ * the given type with the given parameters
+ */
+ public IIOMetadata getDefaultImageMetadata (ImageTypeSpecifier imageType, ImageWriteParam param)
+ {
+ // FIXME: Support metadata.
+ return null;
+ }
+
+ /**
+ * Get a metadata object appropriate for encoding the default image
+ * type handled by this writer, optionally considering image write
+ * parameters.
+ *
+ * @param param - image writing parameters, or null
+ * @return a metadata object appropriate for encoding an image of
+ * the default type with the given parameters
+ */
+ public IIOMetadata getDefaultStreamMetadata (ImageWriteParam param)
+ {
+ // FIXME: Support metadata.
+ return null;
+ }
+
+ /**
+ * Write an image stream, including thumbnails and metadata to the
+ * output stream. The output must have been set prior to this
+ * method being called. Metadata associated with the stream may be
+ * supplied, or it can be left null. IIOImage may contain raster
+ * data if this writer supports rasters, or it will contain a
+ * rendered image. Thumbnails are resized if need be. Image
+ * writing parameters may be specified to affect writing, or may be
+ * left null.
+ *
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data, metadata and
+ * thumbnails to be written
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ * @throws BMPException if the encoder has not been initialized.
+ */
+ public void write(IIOMetadata streamMetadata, IIOImage image,
+ ImageWriteParam param) throws IOException, BMPException
+ {
+ checkStream();
+ ImageOutputStream out = (ImageOutputStream) output;
+ fileHeader = new BMPFileHeader(out, image);
+ infoHeader = new BMPInfoHeader(out, image, param);
+ encoder = BMPEncoder.getEncoder(fileHeader, infoHeader);
+
+ if (encoder != null)
+ encoder.encode(out, streamMetadata, image, param);
+ else
+ throw new BMPException("Encoder has not been initialized.");
+ out.close();
+ }
+
+ /**
+ * Checks the output stream.
+ *
+ * @throws IOException if there is an error with the output stream
+ */
+ private void checkStream() throws IOException
+ {
+ if (!(output instanceof ImageOutputStream))
+ throw new IllegalStateException("Output not an ImageOutputStream.");
+ if (output == null)
+ throw new IllegalStateException("No output stream.");
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java
new file mode 100644
index 00000000000..b2a4273c93a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPImageWriterSpi.java
@@ -0,0 +1,148 @@
+/* BMPImageWriterSpi.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.util.Locale;
+
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.spi.ImageWriterSpi;
+
+public class BMPImageWriterSpi
+ extends ImageWriterSpi
+{
+
+ static final String vendorName = "GNU";
+ static final String version = "0.1";
+ static final String writerClassName = "gnu.javax.imageio.bmp.BMPImageWriter";
+ static final String[] names = { "Microsoft Windows BMP" };
+ static final String[] suffixes = { ".bmp", ".bm" };
+ static final String[] MIMETypes = { "image/bmp", "image/x-windows-bmp" };
+ static final String[] readerSpiNames = { "gnu.javax.imageio.bmp.BMPImageReaderSpi" };
+
+ static final boolean supportsStandardStreamMetadataFormat = false;
+ static final String nativeStreamMetadataFormatName = null;
+ static final String nativeStreamMetadataFormatClassName = null;
+ static final String[] extraStreamMetadataFormatNames = null;
+ static final String[] extraStreamMetadataFormatClassNames = null;
+ static final boolean supportsStandardImageMetadataFormat = false;
+ static final String nativeImageMetadataFormatName = null;
+ static final String nativeImageMetadataFormatClassName = null;
+ static final String[] extraImageMetadataFormatNames = null;
+ static final String[] extraImageMetadataFormatClassNames = null;
+
+ private BMPImageWriter writerInstance;
+
+ public BMPImageWriterSpi()
+ {
+ super(vendorName, version, names, suffixes, MIMETypes, writerClassName,
+ STANDARD_OUTPUT_TYPE, readerSpiNames, supportsStandardStreamMetadataFormat,
+ nativeStreamMetadataFormatName, nativeStreamMetadataFormatClassName,
+ extraStreamMetadataFormatNames, extraStreamMetadataFormatClassNames,
+ supportsStandardImageMetadataFormat, nativeImageMetadataFormatName,
+ nativeImageMetadataFormatClassName, extraImageMetadataFormatNames,
+ extraImageMetadataFormatClassNames);
+ }
+
+ /**
+ * Returns true if the image can be encoded.
+ *
+ * @param type - the image type specifier.
+ * @return true if image can be encoded, otherwise false.
+ */
+ public boolean canEncodeImage(ImageTypeSpecifier type)
+ {
+ if (type == null)
+ return false;
+
+ BMPInfoHeader ih = writerInstance.infoHeader;
+ if (ih != null)
+ {
+ int compressionType = ih.getCompression();
+ int bytes = type.getColorModel().getPixelSize();
+ if ((compressionType == BMPInfoHeader.BI_RLE4 && (bytes != 4 || bytes != 8))
+ || (compressionType == BMPInfoHeader.BI_RGB && ((bytes != 1
+ || bytes != 4
+ || bytes != 8
+ || bytes != 16
+ || bytes != 24
+ || bytes != 32))))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates an instance of ImageWriter using the given extension.
+ *
+ * @param extension - the provider that is constructing this image writer, or
+ * null
+ */
+ public ImageWriter createWriterInstance(Object extension)
+ {
+ if (extension != null && extension instanceof ImageWriterSpi)
+ writerInstance = new BMPImageWriter((ImageWriterSpi) extension);
+ else
+ writerInstance = new BMPImageWriter(this);
+ return writerInstance;
+ }
+
+ /**
+ * Gets the instance of ImageWriter, if already created.
+ */
+ public BMPImageWriter getWriterInstance()
+ {
+ if (writerInstance != null)
+ return writerInstance;
+ return (BMPImageWriter) createWriterInstance(null);
+ }
+
+ /**
+ * Returns a short description of this service provider that can be
+ * presented to a human user.
+ *
+ * @param locale - the locale for which the description string should
+ * be localized.
+ */
+ public String getDescription(Locale locale)
+ {
+ return "Microsoft BMP v3";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java b/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
index edcb4e644cc..a9f1ffda7e5 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/BMPInfoHeader.java
@@ -37,49 +37,55 @@ exception statement from your version. */
package gnu.javax.imageio.bmp;
+import java.awt.Dimension;
+import java.awt.image.ColorModel;
+import java.awt.image.RenderedImage;
import java.io.IOException;
-import javax.imageio.stream.ImageInputStream;
-import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.awt.Dimension;
-public class BMPInfoHeader {
- /** Size of the bitmap info header*/
- private int biSize;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+
+public class BMPInfoHeader
+{
+ /** Size of the bitmap info header */
+ protected int biSize;
- /** Pixel width of the bitmap */
- private int biWidth;
+ /** Pixel width of the bitmap */
+ protected int biWidth;
- /** Pixel height of the bitmap */
- private int biHeight;
+ /** Pixel height of the bitmap */
+ protected int biHeight;
- /** Number of bitplanes = 1 */
- private short biPlanes;
+ /** Number of bitplanes = 1 */
+ protected short biPlanes;
- /** Number of bpp = 1,4,8,24 */
- private short biBitCount;
+ /** Number of bpp = 1,4,8,24 */
+ protected short biBitCount;
- /** Compression type, RGB8, RLE8, RLE4, BITFIELDS */
- private int biCompression;
+ /** Compression type, RGB8, RLE8, RLE4, BITFIELDS */
+ protected int biCompression;
- /** Byte size of the uncompressed bitmap, can be 0. */
- private int biSizeImage;
+ /** Byte size of the uncompressed bitmap, can be 0. */
+ protected int biSizeImage;
- /** X resolution, dots per meter */
- private int biXPelsPerMeter;
+ /** X resolution, dots per meter */
+ protected int biXPelsPerMeter;
- /** Y resolution, dots per meter */
- private int biYPelsPerMeter;
+ /** Y resolution, dots per meter */
+ protected int biYPelsPerMeter;
- /** Number of colors used (palette only, can be 0 for all) */
- private int biClrUsed;
+ /** Number of colors used (palette only, can be 0 for all) */
+ protected int biClrUsed;
- /** Number of 'important' colors, 0 for all */
- private int biClrImportant;
+ /** Number of 'important' colors, 0 for all */
+ protected int biClrImportant;
- /** BITMAPINFOHEADER is 40 bytes */
- public static final int SIZE = 40;
+ /** BITMAPINFOHEADER is 40 bytes */
+ public static final int SIZE = 40;
/**
* Compression types
@@ -91,111 +97,221 @@ public class BMPInfoHeader {
/**
* Creates the header from an input stream, which is not closed.
+ *
+ * @param in - the image input stream
* @throws IOException if an I/O error occured.
* @throws BMPException if the header was invalid
*/
- public BMPInfoHeader(ImageInputStream in) throws IOException, BMPException {
- byte[] data = new byte[SIZE];
-
- if (in.read(data) != SIZE)
- throw new IOException("Couldn't read header.");
- ByteBuffer buf = ByteBuffer.wrap(data);
- buf.order(ByteOrder.LITTLE_ENDIAN);
-
- int n;
- if((n=buf.getInt()) != SIZE)
- throw new BMPException("Invalid BITMAPINFOHEADER size: "+n);
-
- biWidth = buf.getInt();
- biHeight = buf.getInt();
- biPlanes = buf.getShort();
- setBitCount(buf.getShort());
- setCompression(buf.getInt());
- biSizeImage = buf.getInt();
- biXPelsPerMeter = buf.getInt();
- biYPelsPerMeter = buf.getInt();
- biClrUsed = buf.getInt();
- biClrImportant = buf.getInt();
- }
-
- public void setBitCount(short bitcount) throws BMPException {
- switch(bitcount){
- case 1:
- case 4:
- case 8:
- case 16:
- case 24:
- case 32:
- biBitCount = bitcount;
- break;
-
- default:
- throw new BMPException("Invalid number of bits per pixel: "+
- bitcount);
- }
- }
-
- public short getBitCount() { return biBitCount; }
-
- public void setCompression(int compression) throws BMPException {
- switch(compression){
- case BI_RLE8:
- if(getBitCount() != 8)
- throw new BMPException("Invalid number of bits per pixel.");
- biCompression = compression;
- break;
- case BI_RLE4:
- if(getBitCount() != 4)
- throw new BMPException("Invalid number of bits per pixel.");
- biCompression = compression;
- break;
-
- case BI_RGB:
- case BI_BITFIELDS:
- biCompression = compression;
- break;
-
- default:
- throw new BMPException("Unknown bitmap compression type.");
- }
- }
-
- public int getNumberOfPaletteEntries(){
- if(biClrUsed == 0)
- switch(biBitCount){
- case 1:
- return 2;
- case 4:
- return 16;
- case 8:
- return 256;
-
- default: // should not happen
- return 0;
- }
-
- return biClrUsed;
- }
-
- public int getCompression(){
- return biCompression;
- }
-
- public Dimension getSize(){
- return new Dimension(biWidth, biHeight);
- }
-
- public int getWidth(){
- return biWidth;
- }
-
- public int getHeight(){
- return biHeight;
- }
-
- public void setSize(Dimension d){
- biWidth = (int)d.getWidth();
- biHeight = (int)d.getHeight();
- }
-
+ public BMPInfoHeader(ImageInputStream in) throws IOException, BMPException
+ {
+ byte[] data = new byte[SIZE];
+
+ if (in.read(data) != SIZE)
+ throw new IOException("Couldn't read header.");
+ ByteBuffer buf = ByteBuffer.wrap(data);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+
+ int n;
+ if ((n = buf.getInt()) != SIZE)
+ throw new BMPException("Invalid BITMAPINFOHEADER size: " + n);
+
+ biWidth = buf.getInt();
+ biHeight = buf.getInt();
+ biPlanes = buf.getShort();
+ setBitCount(buf.getShort());
+ setCompression(buf.getInt());
+ biSizeImage = buf.getInt();
+ biXPelsPerMeter = buf.getInt();
+ biYPelsPerMeter = buf.getInt();
+ biClrUsed = buf.getInt();
+ biClrImportant = buf.getInt();
+ }
+
+ /**
+ * Creates the info header from an output stream, which is not closed.
+ *
+ * @param out - the image output stream
+ * @param im - the image
+ * @param param - the image write param.
+ * @throws IOException if an I/O error occured.
+ */
+ public BMPInfoHeader(ImageOutputStream out, IIOImage im, ImageWriteParam param) throws IOException
+ {
+ RenderedImage img = im.getRenderedImage();
+ ColorModel cMod = img.getColorModel();
+
+ biSize = SIZE;
+ biWidth = img.getWidth();
+ biHeight = img.getHeight();
+ biPlanes = 1;
+
+ if (param != null && param.canWriteCompressed())
+ {
+ String compType = param.getCompressionType();
+ if (compType.equals("BI_RLE8"))
+ {
+ biCompression = BI_RLE8;
+ biBitCount = 8;
+ }
+ else if (compType.equals("BI_RLE4"))
+ {
+ biCompression = BI_RLE4;
+ biBitCount = 4;
+ }
+ else
+ {
+ biCompression = BI_RGB;
+ biBitCount = (short) cMod.getPixelSize();
+ }
+ }
+ else
+ {
+ biBitCount = (short) cMod.getPixelSize();
+ biCompression = BI_RGB;
+ }
+
+ biXPelsPerMeter = 0x0;
+ biYPelsPerMeter = 0x0;
+ biClrUsed = 0;
+ biClrImportant = 0;
+ biSizeImage = ((biWidth * biHeight) * 3)
+ + ((4 - ((biWidth * 3) % 4)) * biHeight);
+ out.write(intToDWord(biSize));
+ out.write(intToDWord(biWidth));
+ out.write(intToDWord(biHeight));
+ out.write(intToWord(biPlanes));
+ out.write(intToWord(biBitCount));
+ out.write(intToDWord(biCompression));
+ out.write(intToDWord(biSizeImage));
+ out.write(intToDWord(biXPelsPerMeter));
+ out.write(intToDWord(biYPelsPerMeter));
+ out.write(intToDWord(biClrUsed));
+ out.write(intToDWord(biClrImportant));
+ }
+
+ /**
+ * Converts an int to a word, where the return value is stored in a
+ * 2-byte array.
+ *
+ * @param val - the value to convert
+ * @return the array
+ */
+ private byte[] intToWord(int val)
+ {
+ byte b[] = new byte[2];
+ b[0] = (byte) (val & 0x00FF);
+ b[1] = (byte) ((val >> 8) & 0x00FF);
+ return b;
+ }
+
+ /**
+ * Converts an int to a double word, where the return value is
+ * stored in a 4-byte array.
+ *
+ * @param val - the value to convert
+ * @return the array
+ */
+ private byte[] intToDWord(int val)
+ {
+ byte b[] = new byte[4];
+ b[0] = (byte) (val & 0x00FF);
+ b[1] = (byte) ((val >> 8) & 0x000000FF);
+ b[2] = (byte) ((val >> 16) & 0x000000FF);
+ b[3] = (byte) ((val >> 24) & 0x000000FF);
+ return b;
+ }
+
+
+ public void setBitCount(short bitcount) throws BMPException
+ {
+ switch (bitcount)
+ {
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ case 24:
+ case 32:
+ biBitCount = bitcount;
+ break;
+
+ default:
+ throw new BMPException("Invalid number of bits per pixel: " + bitcount);
+ }
+ }
+
+ public short getBitCount()
+ {
+ return biBitCount;
+ }
+
+ public void setCompression(int compression) throws BMPException
+ {
+ switch (compression)
+ {
+ case BI_RLE8:
+ if (getBitCount() != 8)
+ throw new BMPException("Invalid number of bits per pixel.");
+ biCompression = compression;
+ break;
+ case BI_RLE4:
+ if (getBitCount() != 4)
+ throw new BMPException("Invalid number of bits per pixel.");
+ biCompression = compression;
+ break;
+
+ case BI_RGB:
+ case BI_BITFIELDS:
+ biCompression = compression;
+ break;
+
+ default:
+ throw new BMPException("Unknown bitmap compression type.");
+ }
+ }
+
+ public int getNumberOfPaletteEntries()
+ {
+ if (biClrUsed == 0)
+ switch (biBitCount)
+ {
+ case 1:
+ return 2;
+ case 4:
+ return 16;
+ case 8:
+ return 256;
+
+ default: // should not happen
+ return 0;
+ }
+
+ return biClrUsed;
+ }
+
+ public int getCompression()
+ {
+ return biCompression;
+ }
+
+ public Dimension getSize()
+ {
+ return new Dimension(biWidth, biHeight);
+ }
+
+ public int getWidth()
+ {
+ return biWidth;
+ }
+
+ public int getHeight()
+ {
+ return biHeight;
+ }
+
+ public void setSize(Dimension d)
+ {
+ biWidth = (int) d.getWidth();
+ biHeight = (int) d.getHeight();
+ }
}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
index ee64f4b0eac..47ce8cc76d2 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeBF32.java
@@ -39,8 +39,6 @@ package gnu.javax.imageio.bmp;
import java.io.IOException;
import javax.imageio.stream.ImageInputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
index 2a910cb3063..2b7f99be169 100644
--- a/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
+++ b/libjava/classpath/gnu/javax/imageio/bmp/DecodeRGB24.java
@@ -50,7 +50,7 @@ public class DecodeRGB24 extends BMPDecoder {
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
skipToImage(in);
-
+
Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java
new file mode 100644
index 00000000000..293aba8102d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB1.java
@@ -0,0 +1,128 @@
+/* EncodeRGB1.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB1
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB1(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[1];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java
new file mode 100644
index 00000000000..3e9912855b1
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB16.java
@@ -0,0 +1,129 @@
+/* EncodeRGB16.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB16
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB16(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[2];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+ rgb[1] = (byte) (value >> 8 & 0xFF);
+
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java
new file mode 100644
index 00000000000..10c1abee8a3
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB24.java
@@ -0,0 +1,129 @@
+/* EncodeRGB24.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB24
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB24(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[3];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+ rgb[1] = (byte) ((value >> 8) & 0xFF);
+ rgb[2] = (byte) ((value >> 16) & 0xFF);
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java
new file mode 100644
index 00000000000..d653bbf9ffd
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB32.java
@@ -0,0 +1,130 @@
+/* EncodeRGB32.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB32
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB32(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[4];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+ rgb[1] = (byte) ((value >> 8) & 0xFF);
+ rgb[2] = (byte) ((value >> 16) & 0xFF);
+ rgb[3] = (byte) ((value >> 24) & 0xFF);
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java
new file mode 100644
index 00000000000..f1903541f7c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB4.java
@@ -0,0 +1,128 @@
+/* EncodeRGB4.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB4
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB4(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[1];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
new file mode 100644
index 00000000000..dd7387a9a17
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
@@ -0,0 +1,127 @@
+/* EncodeRGB8.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRGB8
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRGB8(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ byte rgb[] = new byte[1];
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+
+ rgb[0] = (byte) (value & 0xFF);
+ o.write(rgb);
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
new file mode 100644
index 00000000000..3674c4d7877
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
@@ -0,0 +1,269 @@
+/* EncodeRLE4.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRLE4
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * RLE control codes
+ */
+ private static final byte ESCAPE = (byte)0;
+ private static final byte EOL = (byte)0; // end of line
+ private static final byte EOB = (byte)1; // end of bitmap
+ private static final byte DELTA = (byte)2; // delta
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRLE4(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ ByteBuffer buf = ByteBuffer.allocate(size);
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+ buf.put((byte) (value & 0xFF));
+
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+
+ buf.flip();
+ o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+
+ /**
+ * Uncompresses the image stored in the buffer.
+ *
+ * @param w - the width of the image
+ * @param h - the height of the image
+ * @param buf - the ByteBuffer containing the pixel values.
+ * @return byte array containing the uncompressed image
+ * @throws IOException if an error is encountered while reading
+ * buffer.
+ */
+ private byte[] uncompress(int w, int h, ByteBuffer buf)
+ throws IOException
+ {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w * h >> 1];
+ int offIn = 0;
+ int x = 0, y = 0;
+
+ w += (w & 1);
+ w = w >> 1;
+
+ try
+ {
+ while (((x >> 1) + y * w) < w * h)
+ {
+ try
+ {
+ buf.get(cmd);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ if (cmd[0] == ESCAPE)
+ {
+ switch (cmd[1])
+ {
+ case EOB:
+ return data;
+ case EOL:
+ x = 0;
+ y++;
+ break;
+ case DELTA:
+ try
+ {
+ buf.get(cmd);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ int length = cmd[1] & (0xFF);
+
+ int bytesize = length;
+ bytesize += (bytesize & 1);
+ bytesize >>= 1;
+ bytesize += (bytesize & 1);
+
+ byte[] run = new byte[bytesize];
+ try
+ {
+ buf.get(run);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ if ((x & 1) == 0)
+ {
+ length += (length & 1);
+ length >>= 1;
+ System.arraycopy(run, 0, data,
+ ((x >> 1) + w * (h - y - 1)), length);
+ }
+ else
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if ((i & 1) == 0)
+ data[((x + i) >> 1) + w * (h - y - 1)] |= ((run[i >> 1] & 0xF0) >> 4);
+ else
+ data[((x + i) >> 1) + w * (h - y - 1)] |= ((run[i >> 1] & 0x0F) << 4);
+ }
+ }
+ x += cmd[1] & (0xFF);
+ break;
+ }
+ }
+ else
+ {
+ int length = cmd[0] & (0xFF);
+ if ((x & 1) == 0)
+ {
+ length += (length & 1);
+ length >>= 1;
+ for (int i = 0; i < length; i++)
+ data[(h - y - 1) * w + i + (x >> 1)] = cmd[1];
+ }
+ else
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if ((i & 1) == 0)
+ data[((x + i) >> 1) + w * (h - y - 1)] |= ((cmd[1] & 0xF0) >> 4);
+ else
+ data[((x + i) >> 1) + w * (h - y - 1)] |= ((cmd[1] & 0x0F) << 4);
+ }
+ }
+ x += cmd[0] & (0xFF);
+ }
+ }
+ return data;
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ throw new BMPException("Invalid RLE data.");
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
new file mode 100644
index 00000000000..dbbaeb26996
--- /dev/null
+++ b/libjava/classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
@@ -0,0 +1,234 @@
+/* EncodeRGB32.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.imageio.bmp;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.io.IOException;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeRLE8
+ extends BMPEncoder
+{
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ /**
+ * RLE control codes
+ */
+ private static final byte ESCAPE = (byte)0;
+ private static final byte EOL = (byte)0; // end of line
+ private static final byte EOB = (byte)1; // end of bitmap
+ private static final byte DELTA = (byte)2; // delta
+
+ /**
+ * Constructs an instance of this class.
+ *
+ * @param fh - the file header to use.
+ * @param ih - the info header to use.
+ */
+ public EncodeRLE8(BMPFileHeader fh, BMPInfoHeader ih)
+ {
+ super();
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * The image encoder.
+ *
+ * @param o - the image output stream
+ * @param streamMetadata - metadata associated with this stream, or
+ * null
+ * @param image - an IIOImage containing image data.
+ * @param param - image writing parameters, or null
+ * @exception IOException if a write error occurs
+ */
+ public void encode(ImageOutputStream o, IIOMetadata streamMetadata,
+ IIOImage image, ImageWriteParam param) throws IOException
+ {
+ int size;
+ int value;
+ int j;
+ int rowCount;
+ int rowIndex;
+ int lastRowIndex;
+ int[] bitmap;
+ size = (infoHeader.biWidth * infoHeader.biHeight) - 1;
+ rowCount = 1;
+ rowIndex = size - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ ByteBuffer buf = ByteBuffer.allocate(size);
+ try
+ {
+ bitmap = new int[infoHeader.biWidth * infoHeader.biHeight];
+ PixelGrabber pg = new PixelGrabber((BufferedImage) image.getRenderedImage(),
+ 0, 0, infoHeader.biWidth,
+ infoHeader.biHeight, bitmap, 0,
+ infoHeader.biWidth);
+ pg.grabPixels();
+
+ for (j = 0; j < size; j++)
+ {
+ value = bitmap[rowIndex];
+ buf.put((byte) (value & 0xFF));
+
+ if (rowCount == infoHeader.biWidth)
+ {
+ rowCount = 1;
+ rowIndex = lastRowIndex - infoHeader.biWidth;
+ lastRowIndex = rowIndex;
+ }
+ else
+ rowCount++;
+ rowIndex++;
+ }
+
+ buf.flip();
+ o.write(uncompress(infoHeader.biWidth, infoHeader.biHeight, buf));
+ }
+ catch (Exception wb)
+ {
+ wb.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Uncompresses the image stored in the buffer.
+ *
+ * @param w - the width of the image
+ * @param h - the height of the image
+ * @param buf - the ByteBuffer containing the pixel values.
+ * @return byte array containing the uncompressed image
+ * @throws IOException if an error is encountered while reading
+ * buffer.
+ */
+ private byte[] uncompress(int w, int h, ByteBuffer buf) throws IOException
+ {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w * h];
+ int offIn = 0;
+ int x = 0, y = 0;
+
+ try
+ {
+ while ((x + y * w) < w * h)
+ {
+ try
+ {
+ buf.get(cmd);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ if (cmd[0] == ESCAPE)
+ {
+ switch (cmd[1])
+ {
+ case EOB:
+ return data;
+ case EOL:
+ x = 0;
+ y++;
+ break;
+ case DELTA:
+ try
+ {
+ buf.get(cmd);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ int length = cmd[1] & (0xFF);
+ int copylength = length;
+
+ length += (length & 1);
+
+ byte[] run = new byte[length];
+
+ try
+ {
+ buf.get(run);
+ }
+ catch (BufferUnderflowException e)
+ {
+ throw new IOException("Error reading compressed data.");
+ }
+
+ System.arraycopy(run, 0, data, (x + w * (h - y - 1)),
+ copylength);
+ x += copylength;
+ break;
+ }
+ }
+ else
+ {
+ int length = cmd[0] & (0xFF);
+ for (int i = 0; i < length; i++)
+ data[(h - y - 1) * w + x++] = cmd[1];
+ }
+ }
+ return data;
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ throw new BMPException("Invalid RLE data.");
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsIppOperation.java b/libjava/classpath/gnu/javax/print/CupsIppOperation.java
new file mode 100644
index 00000000000..e9151691124
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsIppOperation.java
@@ -0,0 +1,99 @@
+/* CupsIppOperation.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+
+/**
+ * Operations as provided by CUPS up to version 1.1
+ * <p>
+ * See: CUPS Implementation of IPP, chapter 3.2<br>
+ * http://www.cups.org/doc-1.1/ipp.html
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CupsIppOperation
+{
+
+ /** Get the default destination - since CUPS 1.0 */
+ public static final int CUPS_GET_DEFAULT = 0x4001;
+
+ /** Get all of the available printers - since CUPS 1.0 */
+ public static final int CUPS_GET_PRINTERS = 0x4002;
+
+ /** Add or modify a printer - since CUPS 1.0 */
+ public static final int CUPS_ADD_MODIFY_PRINTER = 0x4003;
+
+ /** Delete a printer - since CUPS 1.0 */
+ public static final int CUPS_DELETE_PRINTER = 0x4004;
+
+ /** Get all of the available printer classes - since CUPS 1.0 */
+ public static final int CUPS_GET_CLASSES = 0x4005;
+
+ /** Add or modify a printer class - since CUPS 1.0 */
+ public static final int CUPS_ADD_MODIFY_CLASS = 0x4006;
+
+ /** Delete a printer class - since CUPS 1.0 */
+ public static final int CUPS_DELETE_CLASS = 0x4007;
+
+ /** Accept jobs on a printer or printer class - since CUPS 1.0 */
+ public static final int CUPS_ACCEPT_JOBS = 0x4008;
+
+ /** Reject jobs on a printer or printer class - since CUPS 1.0 */
+ public static final int CUPS_REJECT_JOBS = 0x4009;
+
+ /** Set the default destination - since CUPS 1.0 */
+ public static final int CUPS_SET_DEFAULT = 0x400A;
+
+ /** Get all of the available PPDs - since CUPS 1.1 */
+ public static final int CUPS_GET_DEVICES = 0x400B;
+
+ /** Get all of the available PPDs - since CUPS 1.1 */
+ public static final int CUPS_GET_PPDS = 0x400C;
+
+ /** Move a job to a different printer - since CUPS 1.1 */
+ public static final int CUPS_MOVE_JOB = 0x400D;
+
+
+ private CupsIppOperation()
+ {
+ // not to be instantiated
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsMediaMapping.java b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java
new file mode 100644
index 00000000000..eaf2d5e54ae
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsMediaMapping.java
@@ -0,0 +1,176 @@
+/* CupsMediaMapping.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.print.attribute.standard.MediaSizeName;
+
+/**
+ * Provides the currently known mappings of the media attribute
+ * values of the CUPS printing system to the IPP standard values.
+ * <p>
+ * The mapping is used to build up print service specific mappings
+ * for use of media attribute translation between Java JPS API and
+ * CUPS.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class CupsMediaMapping
+{
+ // the mapping map
+ private static final HashMap ippByCups = new HashMap();
+
+ /**
+ * Initialize currently known mappings.
+ */
+ static
+ {
+ ippByCups.put("Postcard", MediaSizeName.JAPANESE_POSTCARD);
+ ippByCups.put("Statement", MediaSizeName.INVOICE);
+
+ ippByCups.put("Letter", MediaSizeName.NA_LETTER);
+ ippByCups.put("Executive", MediaSizeName.EXECUTIVE);
+ ippByCups.put("Legal", MediaSizeName.NA_LEGAL);
+
+ ippByCups.put("A0", MediaSizeName.ISO_A0);
+ ippByCups.put("A1", MediaSizeName.ISO_A1);
+ ippByCups.put("A2", MediaSizeName.ISO_A2);
+ ippByCups.put("A3", MediaSizeName.ISO_A3);
+ ippByCups.put("A4", MediaSizeName.ISO_A4);
+ ippByCups.put("A5", MediaSizeName.ISO_A5);
+ ippByCups.put("A6", MediaSizeName.ISO_A6);
+ ippByCups.put("A7", MediaSizeName.ISO_A7);
+ ippByCups.put("A8", MediaSizeName.ISO_A8);
+ ippByCups.put("A9", MediaSizeName.ISO_A9);
+ ippByCups.put("A10", MediaSizeName.ISO_A10);
+
+ ippByCups.put("B0", MediaSizeName.JIS_B0);
+ ippByCups.put("B1", MediaSizeName.JIS_B1);
+ ippByCups.put("B2", MediaSizeName.JIS_B2);
+ ippByCups.put("B3", MediaSizeName.JIS_B3);
+ ippByCups.put("B4", MediaSizeName.JIS_B4);
+ ippByCups.put("B5", MediaSizeName.JIS_B5);
+ ippByCups.put("B6", MediaSizeName.JIS_B6);
+ ippByCups.put("B7", MediaSizeName.JIS_B7);
+ ippByCups.put("B8", MediaSizeName.JIS_B8);
+ ippByCups.put("B9", MediaSizeName.JIS_B9);
+ ippByCups.put("B10", MediaSizeName.JIS_B10);
+
+ ippByCups.put("ISOB0", MediaSizeName.ISO_B0);
+ ippByCups.put("ISOB1", MediaSizeName.ISO_B1);
+ ippByCups.put("ISOB2", MediaSizeName.ISO_B2);
+ ippByCups.put("ISOB3", MediaSizeName.ISO_B3);
+ ippByCups.put("ISOB4", MediaSizeName.ISO_B4);
+ ippByCups.put("ISOB5", MediaSizeName.ISO_B5);
+ ippByCups.put("ISOB6", MediaSizeName.ISO_B6);
+ ippByCups.put("ISOB7", MediaSizeName.ISO_B7);
+ ippByCups.put("ISOB8", MediaSizeName.ISO_B8);
+ ippByCups.put("ISOB9", MediaSizeName.ISO_B9);
+ ippByCups.put("ISOB10", MediaSizeName.ISO_B10);
+ ippByCups.put("EnvISOB0", MediaSizeName.ISO_B0);
+ ippByCups.put("EnvISOB1", MediaSizeName.ISO_B1);
+ ippByCups.put("EnvISOB2", MediaSizeName.ISO_B2);
+ ippByCups.put("EnvISOB3", MediaSizeName.ISO_B3);
+ ippByCups.put("EnvISOB4", MediaSizeName.ISO_B4);
+ ippByCups.put("EnvISOB5", MediaSizeName.ISO_B5);
+ ippByCups.put("EnvISOB6", MediaSizeName.ISO_B6);
+ ippByCups.put("EnvISOB7", MediaSizeName.ISO_B7);
+ ippByCups.put("EnvISOB8", MediaSizeName.ISO_B8);
+ ippByCups.put("EnvISOB9", MediaSizeName.ISO_B9);
+ ippByCups.put("EnvISOB10", MediaSizeName.ISO_B10);
+
+ ippByCups.put("C0", MediaSizeName.ISO_C0);
+ ippByCups.put("C1", MediaSizeName.ISO_C1);
+ ippByCups.put("C2", MediaSizeName.ISO_C2);
+ ippByCups.put("C3", MediaSizeName.ISO_C3);
+ ippByCups.put("C4", MediaSizeName.ISO_C4);
+ ippByCups.put("C5", MediaSizeName.ISO_C5);
+ ippByCups.put("C6", MediaSizeName.ISO_C6);
+
+ ippByCups.put("EnvPersonal", MediaSizeName.PERSONAL_ENVELOPE);
+ ippByCups.put("EnvMonarch", MediaSizeName.MONARCH_ENVELOPE);
+ ippByCups.put("Monarch", MediaSizeName.MONARCH_ENVELOPE);
+ ippByCups.put("Env9", MediaSizeName.NA_NUMBER_9_ENVELOPE);
+ ippByCups.put("Env10", MediaSizeName.NA_NUMBER_10_ENVELOPE);
+ ippByCups.put("Env11", MediaSizeName.NA_NUMBER_11_ENVELOPE);
+ ippByCups.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE);
+ ippByCups.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE);
+ ippByCups.put("c8x10", MediaSizeName.NA_8X10);
+
+ ippByCups.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG);
+ ippByCups.put("DL", MediaSizeName.ISO_DESIGNATED_LONG);
+ ippByCups.put("EnvC0", MediaSizeName.ISO_C0);
+ ippByCups.put("EnvC1", MediaSizeName.ISO_C1);
+ ippByCups.put("EnvC2", MediaSizeName.ISO_C2);
+ ippByCups.put("EnvC3", MediaSizeName.ISO_C3);
+ ippByCups.put("EnvC4", MediaSizeName.ISO_C4);
+ ippByCups.put("EnvC5", MediaSizeName.ISO_C5);
+ ippByCups.put("EnvC6", MediaSizeName.ISO_C6);
+ }
+
+ /**
+ * Returns the IPP media name of the given cups name.
+ *
+ * @param cupsName the name in cups
+ * @return The IPP name if a mapping is known, <code>null</code> otherwise.
+ */
+ public static final String getIppName(String cupsName)
+ {
+ return (String) ippByCups.get(cupsName);
+ }
+
+ /**
+ * Returns the mapping map for iteration.
+ *
+ * @return The mapping map as unmodifiable map.
+ */
+ public static final Map getMappingMap()
+ {
+ return Collections.unmodifiableMap(ippByCups);
+ }
+
+ private CupsMediaMapping()
+ {
+ // not to be instantiated
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsPrintService.java b/libjava/classpath/gnu/javax/print/CupsPrintService.java
new file mode 100644
index 00000000000..4f77523c530
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsPrintService.java
@@ -0,0 +1,104 @@
+/* CupsPrintService.java -- Cups specific implementation subclass
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import gnu.javax.print.ipp.IppException;
+import gnu.javax.print.ipp.IppMultiDocPrintService;
+import gnu.javax.print.ipp.IppResponse;
+
+import java.net.URI;
+
+import javax.print.DocFlavor;
+import javax.print.attribute.AttributeSet;
+
+/**
+ * Implementation of the PrintService/MultiDocPrintService
+ * interface for Cups printers (supports Cups 1.1 and up)
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CupsPrintService extends IppMultiDocPrintService
+{
+
+ /**
+ * Creates a <code>CupsPrintService</code> object.
+ *
+ * @param uri the URI of the IPP printer.
+ * @param username the user of this print service.
+ * @param password the password of the user.
+ *
+ * @throws IppException if an error during connection occurs.
+ */
+ public CupsPrintService(URI uri, String username, String password)
+ throws IppException
+ {
+ super(uri, username, password);
+ }
+
+ /**
+ * Overridden for CUPS specific handling of the media attribute.
+ */
+ protected Object handleSupportedAttributeValuesResponse(IppResponse response,
+ Class category)
+ {
+ // TODO Implement different behaviour of cups here - actually the Media
+ // printing attribute stuff. For now just use IPP reference implementation.
+ return super.handleSupportedAttributeValuesResponse(response, category);
+ }
+
+ /**
+ * Overridden for CUPS specific handling of the media attribute.
+ */
+ public Object getDefaultAttributeValue(Class category)
+ {
+ // TODO Implement media attribute behaviour for cups here
+ //if (category.equals(Media.class)
+
+ return super.getDefaultAttributeValue(category);
+ }
+
+ /**
+ * Overridden as CUPS does not implement Validate-Job correctly.
+ */
+ public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes)
+ {
+ // TODO Implement a heuristic unsupported attribute identification.
+ return super.getUnsupportedAttributes(flavor, attributes);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java
new file mode 100644
index 00000000000..1aa83218a8d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsPrintServiceLookup.java
@@ -0,0 +1,260 @@
+/* CupsPrintServiceLookup.java -- Implementation based on CUPS
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import gnu.javax.print.ipp.IppException;
+
+import java.util.ArrayList;
+
+import javax.print.DocFlavor;
+import javax.print.MultiDocPrintService;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+
+/**
+ * The platform default implementation based on CUPS.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class CupsPrintServiceLookup extends PrintServiceLookup
+{
+ private CupsServer server;
+
+ /**
+ * Default constructor checking security access.
+ */
+ public CupsPrintServiceLookup()
+ {
+ // security
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
+ // use the localhost cups server
+ server = new CupsServer(null, null);
+ }
+
+ /**
+ * This is the printer marked as default in CUPS.
+ *
+ * @return The default lookup service or
+ * <code>null</code> if there is no default.
+ */
+ public PrintService getDefaultPrintService()
+ {
+ try
+ {
+ return server.getDefaultPrinter();
+ }
+ catch (IppException e)
+ {
+ // if discovery fails treat as if there is none
+ return null;
+ }
+ }
+
+ /**
+ * All printers and printer classes of the CUPS server are checked.
+ * If flavors or attributes are null the constraint is not used.
+ *
+ * @param flavors the document flavors which have to be supported.
+ * @param attributes the attributes which have to be supported.
+ *
+ * @return The multidoc print services of the implementing lookup service
+ * for the given parameters, or an array of length 0 if none is available.
+ */
+ public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
+ AttributeSet attributes)
+ {
+ ArrayList result = new ArrayList();
+ PrintService[] services = getPrintServices();
+
+ for (int i=0; i < services.length; i++)
+ {
+ if (checkMultiDocPrintService(flavors, attributes, services[i]))
+ result.add(services[i]);
+ }
+
+ return (MultiDocPrintService[]) result.toArray(
+ new MultiDocPrintService[result.size()]);
+ }
+
+ /**
+ * These are all printers and printer classes of the CUPS server.
+ *
+ * @return All known print services regardless of supported features,
+ * or an array of length 0 if none is available.
+ */
+ public PrintService[] getPrintServices()
+ {
+ ArrayList result = new ArrayList();
+
+ try
+ {
+ result.addAll(server.getAllPrinters());
+ result.addAll(server.getAllClasses());
+ }
+ catch (IppException e)
+ {
+ // ignore as this method cannot throw exceptions
+ // if print service discovery fails - bad luck
+ }
+ return (PrintService[]) result.toArray(new PrintService[result.size()]);
+ }
+
+
+ /**
+ * All printers and printer classes of the CUPS server are checked.
+ * If flavor or attributes are null the constraint is not used.
+ *
+ * @param flavor the document flavor which has to be supported.
+ * @param attributes the attributes which have to be supported.
+ *
+ * @return The print services of the implementing lookup service
+ * for the given parameters, or an array of length 0 if none is available.
+ */
+ public PrintService[] getPrintServices(DocFlavor flavor,
+ AttributeSet attributes)
+ {
+ ArrayList result = new ArrayList();
+ PrintService[] services = getPrintServices();
+
+ for (int i=0; i < services.length; i++)
+ {
+ if (checkPrintService(flavor, attributes, services[i]))
+ result.add(services[i]);
+ }
+
+ return (PrintService[]) result.toArray(new PrintService[result.size()]);
+ }
+
+ /**
+ * Checks the given print service - own method so it can be used also
+ * to check application registered print services from PrintServiceLookup.
+ *
+ * @param flavor the document flavor which has to be supported.
+ * @param attributes the attributes which have to be supported.
+ * @param service the service to check
+ *
+ * @return <code>true</code> if all constraints match, <code>false</code>
+ * otherwise.
+ */
+ public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
+ PrintService service)
+ {
+ boolean allAttributesSupported = true;
+ if (flavor == null || service.isDocFlavorSupported(flavor))
+ {
+ if (attributes == null || attributes.size() == 0)
+ return allAttributesSupported;
+
+ Attribute[] atts = attributes.toArray();
+ for (int i = 0; i < atts.length; i++)
+ {
+ if (! service.isAttributeCategorySupported(atts[i].getCategory()))
+ {
+ allAttributesSupported = false;
+ break;
+ }
+ }
+ return allAttributesSupported;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks the given print service - own method so it can be used also
+ * to check application registered print services from PrintServiceLookup.
+ *
+ * @param flavors the document flavors which have to be supported.
+ * @param attributes the attributes which have to be supported.
+ * @param service the service to check
+ *
+ * @return <code>true</code> if all constraints match, <code>false</code>
+ * otherwise.
+ */
+ public boolean checkMultiDocPrintService(DocFlavor[] flavors,
+ AttributeSet attributes, PrintService service)
+ {
+ if (service instanceof MultiDocPrintService)
+ {
+ boolean allFlavorsSupported = true;
+ boolean allAttributesSupported = true;
+
+ if (flavors == null || flavors.length != 0)
+ allFlavorsSupported = true;
+ else
+ {
+ for (int k = 0; k < flavors.length; k++)
+ {
+ if (! service.isDocFlavorSupported(flavors[k]))
+ {
+ allFlavorsSupported = false;
+ break;
+ }
+ }
+ }
+
+ if (attributes == null || attributes.size() == 0)
+ allAttributesSupported = true;
+ else
+ {
+ Attribute[] atts = attributes.toArray();
+ for (int j = 0; j < atts.length; j++)
+ {
+ if (! service.isAttributeCategorySupported(
+ atts[j].getCategory()))
+ {
+ allAttributesSupported = false;
+ break;
+ }
+ }
+ }
+
+ if (allAttributesSupported && allFlavorsSupported)
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/CupsServer.java b/libjava/classpath/gnu/javax/print/CupsServer.java
new file mode 100644
index 00000000000..6d9601fb933
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/CupsServer.java
@@ -0,0 +1,269 @@
+/* CupsServer.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import gnu.javax.print.ipp.IppException;
+import gnu.javax.print.ipp.IppPrintService;
+import gnu.javax.print.ipp.IppRequest;
+import gnu.javax.print.ipp.IppResponse;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * <code>CupsServer</code> represents a host running a cups
+ * compatible server. It mainly consists of its URI and optional
+ * user and password combination if access is restricted.
+ * <p>
+ * It provides methods for retrival of valid CUPS printer uris
+ * that are used to construct IppPrintService objects.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class CupsServer
+{
+ /**
+ * The URI of the CUPS server.
+ * This is something like: http://localhost:631
+ */
+ private transient URI uri;
+
+ /**
+ * The optional username.
+ */
+ private transient String username;
+
+ /**
+ * The optional password for the user.
+ */
+ private transient String password;
+
+ /**
+ * Creates a <code>CupsServer</code> object which
+ * tries to connect to the cups server on localhost.
+ *
+ * @param username the username
+ * @param password the password for the username.
+ */
+ public CupsServer(String username, String password)
+ {
+ try
+ {
+ this.uri = new URI("http://localhost:631");
+ }
+ catch (URISyntaxException e)
+ {
+ // does not happen
+ }
+
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Creates a <code>CupsServer</code> object which
+ * tries to connect to a running cups server on the
+ * given URI.
+ *
+ * @param uri the URI of the server.
+ * @param username the username
+ * @param password the password for the username.
+ */
+ public CupsServer(URI uri, String username, String password)
+ {
+ this.uri = uri;
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Requests the default printer from this CUPS server.
+ * This is always returned as IppPrintService.
+ *
+ * @return The default printer.
+ * @throws IppException if problems during request/response processing occur.
+ */
+ public IppPrintService getDefaultPrinter() throws IppException
+ {
+ IppResponse response = null;
+
+ try
+ {
+ IppRequest request = new IppRequest(uri, username, password);
+ request.setOperationID((short)CupsIppOperation.CUPS_GET_DEFAULT);
+ request.setOperationAttributeDefaults();
+
+ RequestedAttributes requestedAttrs
+ = new RequestedAttributes("printer-uri-supported");
+ request.addOperationAttribute(requestedAttrs);
+
+ response = request.send();
+ }
+ catch (IOException e)
+ {
+ throw new IppException("IOException in IPP request/response.", e);
+ }
+
+ Map printerAttributes = (Map) response.getPrinterAttributes().get(0);
+ Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+ PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+
+ IppPrintService service
+ = new CupsPrintService(uri.getURI(), username, password);
+
+ return service;
+ }
+
+ /**
+ * Requests all printers from this CUPS server.
+ *
+ * @return The list of available printers.
+ * @throws IppException if problems during request/response processing occur.
+ */
+ public List getAllPrinters() throws IppException
+ {
+ IppResponse response = null;
+
+ try
+ {
+ IppRequest request = new IppRequest(uri, username, password);
+ request.setOperationID((short)CupsIppOperation.CUPS_GET_PRINTERS);
+ request.setOperationAttributeDefaults();
+
+ RequestedAttributes requestedAttrs
+ = new RequestedAttributes("printer-uri-supported");
+ request.addOperationAttribute(requestedAttrs);
+
+ response = request.send();
+ }
+ catch (IOException e)
+ {
+ throw new IppException("IOException in IPP request/response.", e);
+ }
+
+ List prAttr = response.getPrinterAttributes();
+ List services = new ArrayList();
+
+ for (int i=0; i < prAttr.size(); i++)
+ {
+ Map printerAttributes = (Map) prAttr.get(i);
+ Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+ PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+
+ try
+ {
+ CupsPrintService cups = new CupsPrintService(uri.getURI(),
+ username, password);
+ services.add(cups);
+ }
+ catch (IppException e)
+ {
+ // do nothing, we only catch the IppException which could be
+ // thrown during instantiation as single printers may be discovered
+ // correctly but not usable due to other security restrictions
+ }
+ }
+
+ return services;
+ }
+
+ /**
+ * Requests all classes from this CUPS server. Classes in cups are
+ * collections of printers. This means jobs directed to a class
+ * are forwarded to the first available printer of the collection.
+ *
+ * @return The list of available classes.
+ * @throws IppException if problems during request/response processing occur.
+ */
+ public List getAllClasses() throws IppException
+ {
+ IppResponse response = null;
+
+ try
+ {
+ IppRequest request = new IppRequest(uri, username, password);
+ request.setOperationID((short)CupsIppOperation.CUPS_GET_CLASSES);
+ request.setOperationAttributeDefaults();
+
+ RequestedAttributes requestedAttrs
+ = new RequestedAttributes("printer-uri-supported");
+ request.addOperationAttribute(requestedAttrs);
+
+ response = request.send();
+ }
+ catch (IOException e)
+ {
+ throw new IppException("IOException in IPP request/response.", e);
+ }
+
+ List prAttr = response.getPrinterAttributes();
+ List services = new ArrayList();
+
+ for (int i=0; i < prAttr.size(); i++)
+ {
+ Map printerAttributes = (Map) prAttr.get(i);
+ Set uris = (Set) printerAttributes.get(PrinterUriSupported.class);
+ PrinterUriSupported uri = (PrinterUriSupported) uris.toArray()[0];
+
+ try
+ {
+ CupsPrintService cups = new CupsPrintService(uri.getURI(),
+ username, password);
+ services.add(cups);
+ }
+ catch (IppException e)
+ {
+ // do nothing, we only catch the IppException which could be
+ // thrown during instantiation as single printers may be discovered
+ // correctly but not usable due to other security restrictions
+ }
+ }
+
+ return services;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintAttributeException.java b/libjava/classpath/gnu/javax/print/PrintAttributeException.java
new file mode 100644
index 00000000000..345193d93f7
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintAttributeException.java
@@ -0,0 +1,148 @@
+/* PrintAttributeException.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import javax.print.AttributeException;
+import javax.print.PrintException;
+import javax.print.attribute.Attribute;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>AttributeException</code>.
+ *
+ * @see javax.print.PrintException
+ * @see javax.print.AttributeException
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrintAttributeException extends PrintException
+ implements AttributeException
+{
+ private Class[] categories;
+ private Attribute[] values;
+
+ /**
+ * Constructs a <code>PrintAttributeException</code>
+ * with the given unsupported attributes and/or values.
+ *
+ * @param unsupportedAttributes the unsupported categories,
+ * may be <code>null</code>.
+ * @param unsupportedValues the unsupported attribute values,
+ * may be <code>null</code>.
+ */
+ public PrintAttributeException(Class[] unsupportedAttributes,
+ Attribute[] unsupportedValues)
+ {
+ super();
+ categories = unsupportedAttributes;
+ values = unsupportedValues;
+ }
+
+ /**
+ * Constructs a <code>PrintAttributeException</code>
+ * with the given unsupported attributes and/or values.
+ *
+ * @param e chained exception
+ * @param unsupportedAttributes the unsupported categories,
+ * may be <code>null</code>.
+ * @param unsupportedValues the unsupported attribute values,
+ * may be <code>null</code>.
+ */
+ public PrintAttributeException(Exception e,
+ Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+ {
+ super(e);
+ categories = unsupportedAttributes;
+ values = unsupportedValues;
+ }
+
+ /**
+ * Constructs a <code>PrintAttributeException</code>
+ * with the given unsupported attributes and/or values.
+ *
+ * @param s detailed message
+ * @param unsupportedAttributes the unsupported categories,
+ * may be <code>null</code>.
+ * @param unsupportedValues the unsupported attribute values,
+ * may be <code>null</code>.
+ */
+ public PrintAttributeException(String s,
+ Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+ {
+ super(s);
+ categories = unsupportedAttributes;
+ values = unsupportedValues;
+ }
+
+ /**
+ * Constructs a <code>PrintAttributeException</code>
+ * with the given unsupported attributes and/or values.
+ *
+ * @param s detailed message
+ * @param e chained exception
+ * @param unsupportedAttributes the unsupported categories,
+ * may be <code>null</code>.
+ * @param unsupportedValues the unsupported attribute values,
+ * may be <code>null</code>.
+ */
+ public PrintAttributeException(String s, Exception e,
+ Class[] unsupportedAttributes, Attribute[] unsupportedValues)
+ {
+ super(s, e);
+ categories = unsupportedAttributes;
+ values = unsupportedValues;
+ }
+
+ /**
+ * @see AttributeException#getUnsupportedAttributes()
+ */
+ public Class[] getUnsupportedAttributes()
+ {
+ return categories;
+ }
+
+ /**
+ * @see AttributeException#getUnsupportedValues()
+ */
+ public Attribute[] getUnsupportedValues()
+ {
+ return values;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintFlavorException.java b/libjava/classpath/gnu/javax/print/PrintFlavorException.java
new file mode 100644
index 00000000000..1885e9851a1
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintFlavorException.java
@@ -0,0 +1,120 @@
+/* PrintFlavorException.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import javax.print.DocFlavor;
+import javax.print.FlavorException;
+import javax.print.PrintException;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>FlavorException</code>.
+ *
+ * @see javax.print.PrintException
+ * @see javax.print.FlavorException
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class PrintFlavorException extends PrintException
+ implements FlavorException
+{
+ private DocFlavor[] flavors;
+
+ /**
+ * Constructs a <code>PrintFlavorException</code>
+ * with the given unsupported doc flavor array
+ *
+ * @param unsupportedFlavors the unsupported document flavors.
+ */
+ public PrintFlavorException(DocFlavor[] unsupportedFlavors)
+ {
+ super();
+ flavors = unsupportedFlavors;
+ }
+
+ /**
+ * Constructs a <code>PrintFlavorException</code>
+ * with the given unsupported doc flavor array
+ *
+ * @param e chained exception
+ * @param unsupportedFlavors the unsupported document flavors.
+ */
+ public PrintFlavorException(Exception e, DocFlavor[] unsupportedFlavors)
+ {
+ super(e);
+ flavors = unsupportedFlavors;
+ }
+
+ /**
+ * Constructs a <code>PrintFlavorException</code>
+ * with the given unsupported doc flavor array
+ *
+ * @param s detailed message
+ * @param unsupportedFlavors the unsupported document flavors.
+ */
+ public PrintFlavorException(String s, DocFlavor[] unsupportedFlavors)
+ {
+ super(s);
+ flavors = unsupportedFlavors;
+ }
+
+ /**
+ * Constructs a <code>PrintFlavorException</code>
+ * with the given unsupported doc flavor array
+ *
+ * @param s detailed message
+ * @param e chained exception
+ * @param unsupportedFlavors the unsupported document flavors.
+ */
+ public PrintFlavorException(String s, Exception e,
+ DocFlavor[] unsupportedFlavors)
+ {
+ super(s, e);
+ flavors = unsupportedFlavors;
+ }
+
+ /**
+ * @see FlavorException#getUnsupportedFlavors()
+ */
+ public DocFlavor[] getUnsupportedFlavors()
+ {
+ return flavors;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrintUriException.java b/libjava/classpath/gnu/javax/print/PrintUriException.java
new file mode 100644
index 00000000000..d031000cadb
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrintUriException.java
@@ -0,0 +1,140 @@
+/* PrintUriException.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print;
+
+import java.net.URI;
+
+import javax.print.PrintException;
+import javax.print.URIException;
+
+/**
+ * A <code>PrintException</code> further refining the exception
+ * cause by providing an implementation of the print exception
+ * interface <code>URIException</code>.
+ *
+ * @see javax.print.PrintException
+ * @see javax.print.URIException
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrintUriException extends PrintException
+ implements URIException
+{
+ private int reason;
+ private URI uri;
+
+ /**
+ * Constructs a <code>PrintUriException</code> with the given reason
+ * and unsupported URI instance.
+ *
+ * @param reason the reason for the exception.
+ * @param unsupportedUri the URI which is unsupported.
+ *
+ * @see URIException
+ */
+ public PrintUriException(int reason, URI unsupportedUri)
+ {
+ super();
+ this.reason = reason;
+ uri = unsupportedUri;
+ }
+
+ /**
+ * Constructs a <code>PrintUriException</code> with the given reason
+ * and unsupported URI instance.
+ *
+ * @param e chained exception
+ * @param reason the reason for the exception.
+ * @param unsupportedUri the URI which is unsupported.
+ */
+ public PrintUriException(Exception e, int reason, URI unsupportedUri)
+ {
+ super(e);
+ this.reason = reason;
+ uri = unsupportedUri;
+ }
+
+ /**
+ * Constructs a <code>PrintUriException</code> with the given reason
+ * and unsupported URI instance.
+ *
+ * @param s detailed message
+ * @param reason the reason for the exception.
+ * @param unsupportedUri the URI which is unsupported.
+ */
+ public PrintUriException(String s, int reason, URI unsupportedUri)
+ {
+ super(s);
+ this.reason = reason;
+ uri = unsupportedUri;
+ }
+
+ /**
+ * Constructs a <code>PrintUriException</code> with the given reason
+ * and unsupported URI instance.
+ *
+ * @param s detailed message
+ * @param e chained exception
+ * @param reason the reason for the exception.
+ * @param unsupportedUri the URI which is unsupported.
+ */
+ public PrintUriException(String s, Exception e,
+ int reason, URI unsupportedUri)
+ {
+ super(s, e);
+ this.reason = reason;
+ uri = unsupportedUri;
+ }
+
+ /**
+ * @see URIException#getReason()
+ */
+ public int getReason()
+ {
+ return reason;
+ }
+
+ /**
+ * @see URIException#getUnsupportedURI()
+ */
+ public URI getUnsupportedURI()
+ {
+ return uri;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/PrinterDialog.java b/libjava/classpath/gnu/javax/print/PrinterDialog.java
new file mode 100644
index 00000000000..d7598be3e5b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/PrinterDialog.java
@@ -0,0 +1,1722 @@
+/* PrinterDialog.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.HeadlessException;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.ArrayList;
+import java.util.ResourceBundle;
+
+import javax.print.DocFlavor;
+import javax.print.PrintService;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.Destination;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaPrintableArea;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterInfo;
+import javax.print.attribute.standard.PrinterIsAcceptingJobs;
+import javax.print.attribute.standard.PrinterMakeAndModel;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JSpinner;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+/**
+ * Implementation of the PrinterDialog used by
+ * {@link javax.print.ServiceUI} for visual selection
+ * of print services and its attributes.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterDialog extends JDialog implements ActionListener
+{
+
+ /**
+ * The General Panel used in the printing dialog.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class GeneralPanel extends JPanel
+ {
+ /**
+ * Handles the copies attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class CopiesAndSorted extends JPanel
+ implements ChangeListener, ActionListener
+ {
+ private JCheckBox sort;
+ private JSpinner copies;
+ private JLabel copies_lb;
+ private SpinnerNumberModel copiesModel;
+
+ CopiesAndSorted()
+ {
+ copies_lb = new JLabel(getLocalizedString("lb.copies"));
+ sort = new JCheckBox(getLocalizedString("cb.sort"));
+ sort.addActionListener(this);
+
+ copiesModel = new SpinnerNumberModel(1, 1, 9999, 1);
+ copies = new JSpinner(copiesModel);
+ copies.addChangeListener(this);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.insets = new Insets(5, 5, 5, 5);
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.copies")));
+
+ c.anchor = GridBagConstraints.WEST;
+
+ c.gridx = 0;
+ c.gridy = 0;
+ add(copies_lb, c);
+
+ c.gridx = 1;
+ c.gridy = 0;
+ add(copies, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(sort, c);
+ }
+
+ // copies jspinner state
+ public void stateChanged(ChangeEvent event)
+ {
+ int value = ((Integer) copies.getValue()).intValue();
+ atts.add(new Copies(value));
+
+ if (value > 1 && categorySupported(SheetCollate.class))
+ sort.setEnabled(true);
+ else
+ sort.setEnabled(false);
+ }
+
+ // sorted checkbox state
+ public void actionPerformed(ActionEvent event)
+ {
+ if (sort.isSelected())
+ atts.add(SheetCollate.COLLATED);
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(Copies.class))
+ {
+ copies.setEnabled(true);
+ copies_lb.setEnabled(true);
+
+ Copies copies = (Copies) attribute(Copies.class);
+ if (copies != null)
+ copiesModel.setValue(new Integer(copies.getValue()));
+
+ if (((Integer)copiesModel.getValue()).intValue() > 1
+ && categorySupported(SheetCollate.class))
+ {
+ sort.setEnabled(true);
+ Attribute collate = attribute(SheetCollate.class);
+ if (collate != null && collate.equals(SheetCollate.COLLATED))
+ sort.setSelected(true);
+ }
+ else
+ sort.setEnabled(false);
+ }
+ else
+ {
+ copies.setEnabled(false);
+ copies_lb.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ * Handles the print ranges attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class PrintRange extends JPanel
+ implements ActionListener, FocusListener
+ {
+ private JLabel to;
+ private JRadioButton all_rb, pages_rb;
+ private JTextField from_tf, to_tf;
+
+ PrintRange()
+ {
+ to = new JLabel(getLocalizedString("lb.to"));
+ to.setEnabled(false);
+
+ all_rb = new JRadioButton(getLocalizedString("rbt.all"));
+ all_rb.setSelected(true);
+ all_rb.setActionCommand("ALL");
+ all_rb.addActionListener(this);
+ pages_rb = new JRadioButton(getLocalizedString("rbt.pages"));
+ pages_rb.setActionCommand("PAGES");
+ pages_rb.setEnabled(false);
+ pages_rb.addActionListener(this);
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(all_rb);
+ group.add(pages_rb);
+
+ from_tf = new JTextField("1", 4);
+ from_tf.setEnabled(false);
+ from_tf.addFocusListener(this);
+ to_tf = new JTextField("1", 4);
+ to_tf.setEnabled(false);
+ to_tf.addFocusListener(this);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.printrange")));
+
+ c.insets = new Insets(15, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(all_rb, c);
+
+ c.insets = new Insets(5, 5, 15, 5);
+ c.gridx = 0;
+ c.gridy = 1;
+ add(pages_rb, c);
+
+ c.gridx = 1;
+ c.gridy = 1;
+ add(from_tf, c);
+
+ c.gridx = 2;
+ c.gridy = 1;
+ add(to, c);
+
+ c.insets = new Insets(5, 5, 15, 15);
+ c.gridx = 3;
+ c.gridy = 1;
+ add(to_tf, c);
+ }
+
+ // focus pagerange
+ public void focusGained(FocusEvent event)
+ {
+ updatePageRanges();
+ }
+
+ public void focusLost(FocusEvent event)
+ {
+ updatePageRanges();
+ }
+
+ // updates the range after user changed it
+ private void updatePageRanges()
+ {
+ int lower = Integer.parseInt(from_tf.getText());
+ int upper = Integer.parseInt(to_tf.getText());
+
+ if (lower > upper)
+ {
+ upper = lower;
+ to_tf.setText("" + lower);
+ }
+
+ PageRanges range = new PageRanges(lower, upper);
+ atts.add(range);
+ }
+
+ // page range change
+ public void actionPerformed(ActionEvent e)
+ {
+ // if ALL is selected we must use a full-range object
+ if (e.getActionCommand().equals("ALL"))
+ {
+ from_tf.setEnabled(false);
+ to.setEnabled(false);
+ to_tf.setEnabled(false);
+
+ atts.add(new PageRanges(1, Integer.MAX_VALUE));
+ }
+ else
+ {
+ from_tf.setEnabled(true);
+ to.setEnabled(true);
+ to_tf.setEnabled(true);
+ all_rb.setSelected(false);
+ }
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(PageRanges.class))
+ {
+ pages_rb.setEnabled(true);
+ PageRanges range = (PageRanges) attribute(PageRanges.class);
+ if (range != null)
+ {
+ from_tf.setEnabled(true);
+ to.setEnabled(true);
+ to_tf.setEnabled(true);
+ all_rb.setSelected(false);
+ pages_rb.setSelected(true);
+
+ int[][] members = range.getMembers();
+ // Although passed in attributes may contain more than one
+ // range we only take the first one
+ from_tf.setText("" + members[0][0]);
+ to_tf.setText("" + members[0][1]);
+ }
+ }
+ else
+ {
+ from_tf.setEnabled(false);
+ to.setEnabled(false);
+ to_tf.setEnabled(false);
+ all_rb.setSelected(true);
+ }
+ }
+ }
+
+ /**
+ * Handles the selection of the print services
+ * and its location and description attributes.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class PrintServices extends JPanel
+ implements ActionListener
+ {
+ private JLabel name, status, typ, info;
+ private JLabel statusValue, typValue, infoValue;
+ private JButton attributes;
+ private JComboBox services_cob;
+ private JCheckBox fileRedirection_cb;
+
+ PrintServices()
+ {
+ name = new JLabel(getLocalizedString("lb.name"));
+ status = new JLabel(getLocalizedString("lb.status"));
+ typ = new JLabel(getLocalizedString("lb.typ"));
+ info = new JLabel(getLocalizedString("lb.info"));
+ typValue = new JLabel();
+ infoValue = new JLabel();
+ statusValue = new JLabel();
+
+ attributes = new JButton(getLocalizedString("bt.attributes"));
+ attributes.setEnabled(false);
+ attributes.setActionCommand("ATTRIBUTES");
+ attributes.addActionListener(this);
+
+ services_cob = new JComboBox(getPrintServices());
+ services_cob.setActionCommand("SERVICE");
+ services_cob.addActionListener(this);
+
+ fileRedirection_cb = new JCheckBox(getLocalizedString("cb.output"));
+ fileRedirection_cb.setEnabled(false);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.printservice")));
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.anchor = GridBagConstraints.LINE_END;
+ c.gridx = 0;
+ c.gridy = 0;
+ add(name, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(status, c);
+
+ c.gridx = 0;
+ c.gridy = 2;
+ add(typ, c);
+
+ c.gridx = 0;
+ c.gridy = 3;
+ add(info, c);
+
+ c.gridx = 2;
+ c.gridy = 3;
+ c.weightx = 1;
+ add(fileRedirection_cb, c);
+
+ c.anchor = GridBagConstraints.LINE_START;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 1.5;
+ add(services_cob, c);
+
+ c.gridx = 1;
+ c.gridy = 1;
+ c.gridwidth = 2;
+ c.weightx = 1;
+ add(statusValue, c);
+
+ c.gridx = 1;
+ c.gridy = 2;
+ c.gridwidth = 2;
+ c.weightx = 1;
+ add(typValue, c);
+
+ c.gridx = 1;
+ c.gridy = 3;
+ c.gridwidth = 2;
+ c.weightx = 1;
+ add(infoValue, c);
+
+ c.gridx = 2;
+ c.gridy = 0;
+ c.weightx = 1.5;
+ add(attributes, c);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("SERVICE"))
+ {
+ setSelectedPrintService((PrintService) services_cob.getSelectedItem());
+ updateAll();
+ }
+ else if (e.getActionCommand().equals("ATTRIBUTES"))
+ {
+ // TODO LowPriority-Enhancement: As tests have shown this button
+ // is even gray and not enabled under Windows - Its a good place
+ // to provide a classpath specific browsing dialog for all
+ // attributes not in the default printing dialog.
+ }
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ PrinterMakeAndModel att1 = (PrinterMakeAndModel)
+ getSelectedPrintService().getAttribute(PrinterMakeAndModel.class);
+ typValue.setText(att1 == null ? "" : att1.getValue());
+
+ PrinterInfo att2 = (PrinterInfo)
+ getSelectedPrintService().getAttribute(PrinterInfo.class);
+ infoValue.setText(att2 == null ? "" : att2.getValue());
+
+ PrinterIsAcceptingJobs att3 = (PrinterIsAcceptingJobs)
+ getSelectedPrintService().getAttribute(PrinterIsAcceptingJobs.class);
+ PrinterState att4 = (PrinterState)
+ getSelectedPrintService().getAttribute(PrinterState.class);
+
+ String status = att4.toString();
+ if (att3 == PrinterIsAcceptingJobs.ACCEPTING_JOBS)
+ status += " - " + getLocalizedString("lb.acceptingjobs");
+ else if (att3 == PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS)
+ status += " - " + getLocalizedString("lb.notacceptingjobs");
+
+ statusValue.setText(status);
+
+ if (categorySupported(Destination.class))
+ {
+ fileRedirection_cb.setEnabled(false);
+ }
+ }
+
+ }
+
+ private PrintServices printserv_panel;
+ private PrintRange printrange_panel;
+ private CopiesAndSorted copies;
+
+ /**
+ * Constructs the General Panel.
+ */
+ public GeneralPanel()
+ {
+ setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ printserv_panel = new PrintServices();
+ printrange_panel = new PrintRange();
+ copies = new CopiesAndSorted();
+
+ JPanel layout_panel = new JPanel();
+ layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+ layout_panel.add(printrange_panel);
+ layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+ layout_panel.add(copies);
+
+ setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+ add(printserv_panel);
+ add(Box.createRigidArea(new Dimension(0, 12)));
+ add(layout_panel);
+ }
+
+ /**
+ * Calls update on all internal panels to adjust
+ * for a new selected print service.
+ */
+ void update()
+ {
+ printserv_panel.updateForSelectedService();
+ printrange_panel.updateForSelectedService();
+ copies.updateForSelectedService();
+ }
+ }
+
+ /**
+ * The Page setup Panel.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class PageSetupPanel extends JPanel
+ {
+ /**
+ * Handles the orientation attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class Orientation extends JPanel implements ActionListener
+ {
+ private JRadioButton portrait, landscape, rev_portrait, rev_landscape;
+
+ Orientation()
+ {
+ portrait = new JRadioButton(getLocalizedString("rbt.portrait"));
+ portrait.addActionListener(this);
+ landscape = new JRadioButton(getLocalizedString("rbt.landscape"));
+ landscape.addActionListener(this);
+ rev_portrait = new JRadioButton(getLocalizedString("rbt.revportrait"));
+ rev_portrait.addActionListener(this);
+ rev_landscape = new JRadioButton(getLocalizedString("rbt.revlandscape"));
+ rev_landscape.addActionListener(this);
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(portrait);
+ group.add(landscape);
+ group.add(rev_portrait);
+ group.add(rev_landscape);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.orientation")));
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(portrait, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(landscape, c);
+
+ c.gridx = 0;
+ c.gridy = 2;
+ add(rev_portrait, c);
+
+ c.gridx = 0;
+ c.gridy = 3;
+ add(rev_landscape, c);
+ }
+
+ // event handling orientation
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == portrait)
+ atts.add(OrientationRequested.PORTRAIT);
+ else if (e.getSource() == landscape)
+ atts.add(OrientationRequested.LANDSCAPE);
+ else if (e.getSource() == rev_portrait)
+ atts.add(OrientationRequested.REVERSE_PORTRAIT);
+ else
+ atts.add(OrientationRequested.REVERSE_LANDSCAPE);
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(OrientationRequested.class))
+ {
+ portrait.setEnabled(true);
+ landscape.setEnabled(true);
+ rev_landscape.setEnabled(true);
+ rev_portrait.setEnabled(true);
+
+ Attribute orientation = attribute(OrientationRequested.class);
+ if (orientation != null)
+ {
+ if (orientation.equals(OrientationRequested.LANDSCAPE))
+ landscape.setSelected(true);
+ else if (orientation.equals(OrientationRequested.PORTRAIT))
+ portrait.setSelected(true);
+ else if (orientation.equals(OrientationRequested.REVERSE_PORTRAIT))
+ rev_portrait.setSelected(true);
+ else
+ rev_landscape.setSelected(true);
+ }
+ else
+ {
+ Object defaultValue = defaultValue(OrientationRequested.class);
+ if (defaultValue.equals(OrientationRequested.LANDSCAPE))
+ landscape.setSelected(true);
+ else if (defaultValue.equals(OrientationRequested.PORTRAIT))
+ portrait.setSelected(true);
+ else if (defaultValue.equals(OrientationRequested.REVERSE_PORTRAIT))
+ rev_portrait.setSelected(true);
+ else
+ rev_landscape.setSelected(true);
+ }
+ }
+ else
+ {
+ portrait.setEnabled(false);
+ landscape.setEnabled(false);
+ rev_landscape.setEnabled(false);
+ rev_portrait.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ * Handles the media attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class MediaTypes extends JPanel implements ActionListener
+ {
+ private JLabel size_lb, source_lb;
+ private JComboBox size, source;
+
+ MediaTypes()
+ {
+ size_lb = new JLabel(getLocalizedString("lb.size"));
+ source_lb = new JLabel(getLocalizedString("lb.source"));
+
+ size = new JComboBox();
+ size.setEditable(false);
+ size.addActionListener(this);
+ source = new JComboBox();
+ source.setEditable(false);
+ size.addActionListener(this);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.medias")));
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.anchor = GridBagConstraints.LINE_END;
+ c.gridx = 0;
+ c.gridy = 0;
+ add(size_lb, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(source_lb, c);
+
+ c.anchor = GridBagConstraints.LINE_START;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 1.5;
+ add(size, c);
+
+ c.gridx = 1;
+ c.gridy = 1;
+ c.weightx = 1.5;
+ add(source, c);
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ if (event.getSource() == size)
+ {
+ Object obj = size.getSelectedItem();
+ if (obj instanceof Media)
+ atts.add((Media) obj);
+ }
+
+ // we ignore source events currently
+ // as only the automatic selection is used.
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(Media.class))
+ {
+ Media[] medias = (Media[]) getSelectedPrintService()
+ .getSupportedAttributeValues(Media.class, flavor, null);
+
+ size.removeAllItems();
+ if (medias.length == 0)
+ size.addItem(getLocalizedString("lb.automatically"));
+ else
+ for (int i=0; i < medias.length; i++)
+ size.addItem(medias[i]);
+
+ Media media = (Media) attribute(Media.class);
+ if (media != null)
+ size.setSelectedItem(media);
+
+ // this is currently ignored
+ source.removeAllItems();
+ source.addItem(getLocalizedString("lb.automatically"));
+ }
+ else
+ {
+ size.removeAllItems();
+ source.removeAllItems();
+
+ size.addItem(getLocalizedString("lb.automatically"));
+ source.addItem(getLocalizedString("lb.automatically"));
+ }
+ }
+ }
+
+ /**
+ * Handles the media printable area attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class Margins extends JPanel implements FocusListener
+ {
+ private JLabel left, right, top, bottom;
+ private JTextField left_tf, right_tf, top_tf, bottom_tf;
+
+ Margins()
+ {
+ left = new JLabel(getLocalizedString("lb.left"));
+ right = new JLabel(getLocalizedString("lb.right"));
+ top = new JLabel(getLocalizedString("lb.top"));
+ bottom = new JLabel(getLocalizedString("lb.bottom"));
+
+ left_tf = new JTextField(7);
+ left_tf.addFocusListener(this);
+ right_tf = new JTextField(7);
+ right_tf.addFocusListener(this);
+ top_tf = new JTextField(7);
+ top_tf.addFocusListener(this);
+ bottom_tf = new JTextField(7);
+ bottom_tf.addFocusListener(this);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.margins")));
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(left, c);
+
+ c.gridx = 1;
+ c.gridy = 0;
+ add(right, c);
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 1;
+ add(left_tf, c);
+
+ c.gridx = 1;
+ c.gridy = 1;
+ add(right_tf, c);
+
+ c.insets = new Insets(10, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 2;
+ add(top, c);
+
+ c.gridx = 1;
+ c.gridy = 2;
+ add(bottom, c);
+
+ c.insets = new Insets(0, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 3;
+ add(top_tf, c);
+
+ c.gridx = 1;
+ c.gridy = 3;
+ add(bottom_tf, c);
+ }
+
+ public void focusGained(FocusEvent event)
+ {
+ updateMargins();
+ }
+
+ public void focusLost(FocusEvent event)
+ {
+ updateMargins();
+ }
+
+ // updates the margins after user changed it
+ private void updateMargins()
+ {
+ // We currently do not support this attribute
+ // as it is not in the IPP spec and therefore not in CUPS
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(MediaPrintableArea.class))
+ {
+ left.setEnabled(true);
+ right.setEnabled(true);
+ top.setEnabled(true);
+ bottom.setEnabled(true);
+ left_tf.setEnabled(true);
+ right_tf.setEnabled(true);
+ top_tf.setEnabled(true);
+ bottom_tf.setEnabled(true);
+ }
+ else
+ {
+ left.setEnabled(false);
+ right.setEnabled(false);
+ top.setEnabled(false);
+ bottom.setEnabled(false);
+ left_tf.setEnabled(false);
+ right_tf.setEnabled(false);
+ top_tf.setEnabled(false);
+ bottom_tf.setEnabled(false);
+ }
+ }
+ }
+
+ private MediaTypes media_panel;
+ private Orientation orientation_panel;
+ private Margins margins_panel;
+
+ /**
+ * Constructs the page setup user interface.
+ */
+ public PageSetupPanel()
+ {
+ setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ media_panel = new MediaTypes();
+ orientation_panel = new Orientation();
+ margins_panel = new Margins();
+
+ JPanel layout_panel = new JPanel();
+ layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+ layout_panel.add(orientation_panel);
+ layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+ layout_panel.add(margins_panel);
+
+ setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+ add(media_panel);
+ add(Box.createRigidArea(new Dimension(0, 12)));
+ add(layout_panel);
+ }
+
+ /**
+ * Calls update on all internal panels to adjust
+ * for a new selected print service.
+ */
+ void update()
+ {
+ media_panel.updateForSelectedService();
+ orientation_panel.updateForSelectedService();
+ margins_panel.updateForSelectedService();
+ }
+ }
+
+ /**
+ * The Appearance panel for quality, color etc.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class AppearancePanel extends JPanel
+ {
+ /**
+ * Handles the print quality attribute.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class Quality extends JPanel implements ActionListener
+ {
+ private JRadioButton low, normal, high;
+ private ButtonGroup group;
+
+ Quality()
+ {
+ low = new JRadioButton(getLocalizedString("rbt.low"));
+ low.addActionListener(this);
+ normal = new JRadioButton(getLocalizedString("rbt.normal"));
+ normal.addActionListener(this);
+ high = new JRadioButton(getLocalizedString("rbt.high"));
+ high.addActionListener(this);
+
+ group = new ButtonGroup();
+ group.add(low);
+ group.add(normal);
+ group.add(high);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.quality")));
+
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(low, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(normal, c);
+
+ c.gridx = 0;
+ c.gridy = 2;
+ add(high, c);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == low)
+ atts.add(PrintQuality.DRAFT);
+ else if (e.getSource() == normal)
+ atts.add(PrintQuality.NORMAL);
+ else
+ atts.add(PrintQuality.HIGH);
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(PrintQuality.class))
+ {
+ low.setEnabled(true);
+ normal.setEnabled(true);
+ high.setEnabled(true);
+
+ Object defaultValue = defaultValue(PrintQuality.class);
+ Attribute quality = attribute(PrintQuality.class);
+
+ if (quality != null)
+ {
+ if (quality.equals(PrintQuality.DRAFT))
+ low.setSelected(true);
+ else if (quality.equals(PrintQuality.NORMAL))
+ normal.setSelected(true);
+ else
+ high.setSelected(true);
+ }
+ else
+ {
+ if (defaultValue.equals(PrintQuality.DRAFT))
+ low.setSelected(true);
+ else if (defaultValue.equals(PrintQuality.NORMAL))
+ normal.setSelected(true);
+ else
+ high.setSelected(true);
+ }
+ }
+ else
+ {
+ low.setEnabled(false);
+ normal.setEnabled(false);
+ high.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ * Handles the job attributes as requesting username, jobname etc.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class JobAttributes extends JPanel
+ implements ActionListener, ChangeListener, FocusListener
+ {
+ private JLabel jobname, username, priority_lb;
+ private JTextField jobname_tf, username_tf;
+ private JCheckBox cover;
+ private JSpinner priority;
+ private SpinnerNumberModel model;
+
+ JobAttributes()
+ {
+ jobname = new JLabel(getLocalizedString("lb.jobname"));
+ username = new JLabel(getLocalizedString("lb.username"));
+ priority_lb = new JLabel(getLocalizedString("lb.priority"));
+
+ cover = new JCheckBox(getLocalizedString("cb.cover"));
+ cover.addActionListener(this);
+
+ model = new SpinnerNumberModel(1, 1, 100, 1);
+ priority = new JSpinner(model);
+ priority.addChangeListener(this);
+
+ jobname_tf = new JTextField();
+ jobname_tf.addFocusListener(this);
+ username_tf = new JTextField();
+ username_tf.addFocusListener(this);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.jobattributes")));
+
+ c.insets = new Insets(10, 5, 10, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(cover, c);
+
+ c.anchor = GridBagConstraints.LINE_END;
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 2;
+ add(priority_lb, c);
+
+ c.gridx = 2;
+ c.gridy = 0;
+ c.weightx = 0.5;
+ add(priority, c);
+
+ c.anchor = GridBagConstraints.LINE_END;
+ c.gridx = 0;
+ c.gridy = 1;
+ add(jobname, c);
+
+ c.gridx = 0;
+ c.gridy = 2;
+ add(username, c);
+
+ c.anchor = GridBagConstraints.CENTER;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 1;
+ c.gridy = 1;
+ c.gridwidth = 2;
+ c.weightx = 1.5;
+ add(jobname_tf, c);
+
+ c.insets = new Insets(10, 5, 15, 5);
+ c.gridx = 1;
+ c.gridy = 2;
+ add(username_tf, c);
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ if (cover.isSelected())
+ atts.add(JobSheets.STANDARD);
+ else
+ atts.add(JobSheets.NONE);
+ }
+
+ public void stateChanged(ChangeEvent event)
+ {
+ int value = ((Integer) priority.getValue()).intValue();
+ atts.add(new JobPriority(value));
+ }
+
+ public void focusGained(FocusEvent event)
+ {
+ updateTextfields(event);
+ }
+
+ public void focusLost(FocusEvent event)
+ {
+ updateTextfields(event);
+ }
+
+ private void updateTextfields(FocusEvent event)
+ {
+ if (event.getSource() == jobname_tf)
+ atts.add(new JobName(jobname_tf.getText(), null));
+ else
+ atts.add(new RequestingUserName(username_tf.getText(), null));
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ // JobPriority
+ if (categorySupported(JobPriority.class))
+ {
+ JobPriority prio = (JobPriority) attribute(JobPriority.class);
+ JobPriority value = (JobPriority) defaultValue(JobPriority.class);
+ priority.setEnabled(true);
+ if (prio != null)
+ model.setValue(new Integer(prio.getValue()));
+ else
+ model.setValue(new Integer(value.getValue()));
+ }
+ else
+ priority.setEnabled(false);
+
+ // Requesting username
+ if (categorySupported(RequestingUserName.class))
+ {
+ Attribute user = attribute(RequestingUserName.class);
+ Object value = defaultValue(RequestingUserName.class);
+ username.setEnabled(true);
+ if (user != null)
+ username_tf.setText(user.toString());
+ else
+ username_tf.setText(value.toString());
+ }
+ else
+ username.setEnabled(false);
+
+ // Job Name
+ if (categorySupported(JobName.class))
+ {
+ Attribute job = attribute(JobName.class);
+ Object value = defaultValue(JobName.class);
+ jobname.setEnabled(true);
+ if (job != null)
+ jobname_tf.setText(job.toString());
+ else
+ jobname_tf.setText(value.toString());
+ }
+ else
+ jobname.setEnabled(false);
+
+ // Job sheets
+ if (categorySupported(JobSheets.class))
+ {
+ Attribute sheet = attribute(JobSheets.class);
+ Object value = defaultValue(JobSheets.class);
+ cover.setEnabled(true);
+ if (sheet != null)
+ {
+ if (sheet.equals(JobSheets.NONE))
+ cover.setSelected(false);
+ else
+ cover.setSelected(true);
+ }
+ else
+ {
+ if (value.equals(JobSheets.NONE))
+ cover.setSelected(false);
+ else
+ cover.setSelected(true);
+ }
+ }
+ else
+ cover.setEnabled(false);
+ }
+ }
+
+ /**
+ * Handles the sides attributes.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class SidesPanel extends JPanel implements ActionListener
+ {
+ private JRadioButton oneside, calendar, duplex;
+
+ SidesPanel()
+ {
+ oneside = new JRadioButton(getLocalizedString("rbt.onesided"));
+ oneside.addActionListener(this);
+ calendar = new JRadioButton(getLocalizedString("rbt.calendar"));
+ calendar.addActionListener(this);
+ duplex = new JRadioButton(getLocalizedString("rbt.duplex"));
+ duplex.addActionListener(this);
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(oneside);
+ group.add(calendar);
+ group.add(duplex);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.sides")));
+
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(oneside, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(calendar, c);
+
+ c.gridx = 0;
+ c.gridy = 2;
+ add(duplex, c);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == calendar)
+ atts.add(Sides.TWO_SIDED_SHORT_EDGE);
+ else if (e.getSource() == oneside)
+ atts.add(Sides.ONE_SIDED);
+ else
+ atts.add(Sides.TWO_SIDED_LONG_EDGE);
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(Sides.class))
+ {
+ oneside.setEnabled(true);
+ calendar.setEnabled(true);
+ duplex.setEnabled(true);
+
+ Object defaultValue = defaultValue(Sides.class);
+ Attribute sides = attribute(Sides.class);
+ if (sides != null)
+ {
+ if (sides.equals(Sides.TWO_SIDED_SHORT_EDGE))
+ calendar.setSelected(true);
+ else if (sides.equals(Sides.ONE_SIDED))
+ oneside.setSelected(true);
+ else
+ duplex.setSelected(true);
+ }
+ else
+ {
+ if (defaultValue.equals(Sides.TWO_SIDED_SHORT_EDGE))
+ calendar.setSelected(true);
+ else if (defaultValue.equals(Sides.ONE_SIDED))
+ oneside.setSelected(true);
+ else
+ duplex.setSelected(true);
+ }
+ }
+ else
+ {
+ oneside.setEnabled(false);
+ calendar.setEnabled(false);
+ duplex.setEnabled(false);
+ }
+ }
+ }
+
+ /**
+ * Handles the chromaticity attributes.
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ final class Color extends JPanel implements ActionListener
+ {
+ private JRadioButton bw, color;
+
+ Color()
+ {
+ bw = new JRadioButton(getLocalizedString("rbt.blackwhite"));
+ bw.addActionListener(this);
+ color = new JRadioButton(getLocalizedString("rbt.color"));
+ color.addActionListener(this);
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(bw);
+ group.add(color);
+
+ GridBagLayout layout = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ setLayout(layout);
+ setBorder(new TitledBorder(getLocalizedString("title.color")));
+
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.insets = new Insets(5, 5, 5, 5);
+ c.gridx = 0;
+ c.gridy = 0;
+ add(bw, c);
+
+ c.gridx = 0;
+ c.gridy = 1;
+ add(color, c);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == bw)
+ atts.add(Chromaticity.MONOCHROME);
+ else
+ atts.add(Chromaticity.COLOR);
+ }
+
+ /**
+ * Called to update for new selected
+ * print service. Tests if currently
+ * selected attributes are supported.
+ */
+ void updateForSelectedService()
+ {
+ if (categorySupported(Chromaticity.class))
+ {
+ bw.setEnabled(true);
+ color.setEnabled(true);
+
+ Object defaultValue = defaultValue(Chromaticity.class);
+ Attribute chromaticity = attribute(Chromaticity.class);
+ if (chromaticity != null)
+ {
+ if (chromaticity.equals(Chromaticity.MONOCHROME))
+ bw.setSelected(true);
+ else
+ color.setSelected(true);
+ }
+ else
+ {
+ if (defaultValue.equals(Chromaticity.MONOCHROME))
+ bw.setSelected(true);
+ else
+ color.setSelected(true);
+ }
+ }
+ else
+ {
+ bw.setEnabled(false);
+ color.setEnabled(false);
+ }
+ }
+ }
+
+ private Quality quality_panel;
+ private JobAttributes jobAttr_panel;
+ private SidesPanel sides_panel;
+ private Color chromaticy_panel;
+
+ /**
+ * Creates the panel for appearance attributes.
+ */
+ public AppearancePanel()
+ {
+ setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ quality_panel = new Quality();
+ jobAttr_panel = new JobAttributes();
+ sides_panel = new SidesPanel();
+ chromaticy_panel = new Color();
+
+ JPanel layout_panel = new JPanel();
+ layout_panel.setLayout(new BoxLayout(layout_panel, BoxLayout.LINE_AXIS));
+ layout_panel.add(chromaticy_panel);
+ layout_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+ layout_panel.add(quality_panel);
+
+ JPanel layout2_panel = new JPanel();
+ layout2_panel.setLayout(new BoxLayout(layout2_panel, BoxLayout.LINE_AXIS));
+ layout2_panel.add(sides_panel);
+ layout2_panel.add(Box.createRigidArea(new Dimension(10, 0)));
+ layout2_panel.add(jobAttr_panel);
+
+ setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+ add(layout_panel);
+ add(Box.createRigidArea(new Dimension(0, 12)));
+ add(layout2_panel);
+ }
+
+ /**
+ * Calls update on all internal panels to adjust
+ * for a new selected print service.
+ */
+ void update()
+ {
+ quality_panel.updateForSelectedService();
+ jobAttr_panel.updateForSelectedService();
+ sides_panel.updateForSelectedService();
+ chromaticy_panel.updateForSelectedService();
+ }
+ }
+
+ // on main contentpane
+ private JButton ok_bt;
+ private JButton cancel_bt;
+
+ // the tabs
+ private GeneralPanel general_panel;
+ private PageSetupPanel pagesetup_panel;
+ private AppearancePanel appearance_panel;
+
+ private PrintService[] services;
+ private PrintService defaultService;
+ private PrintService selectedService;
+ private DocFlavor flavor;
+ private PrintRequestAttributeSet attributes;
+
+ private boolean onlyPageDialog;
+ private PrintRequestAttributeSet atts;
+
+ private final static ResourceBundle messages;
+
+ static
+ {
+ messages = ResourceBundle.getBundle("gnu/javax/print/PrinterDialog");
+ }
+
+ // TODO LowPriority: Include checks so that if a specific value formerly
+ // selected is no more supported by the new service changes to the default.
+
+ /**
+ * Class private constructs a printer dialog.
+ *
+ * @param gc the screen to use. <code>null</code> is default screen.
+ * @param services the print services to browse (not null).
+ * @param defaultService the default service. If <code>null</code>
+ * the first of the print services in the services array will be used.
+ * @param flavor the flavours to be printed.
+ * @param attributes the attributes requested. Will be updated
+ * by selections done by the user in the dialog.
+ * @param onlyPageDialog if true a page settings only dialog is constructed.
+ *
+ * @throws HeadlessException if GraphicsEnvironment is headless
+ */
+ private PrinterDialog(GraphicsConfiguration gc, PrintService[] services,
+ PrintService defaultService, DocFlavor flavor,
+ PrintRequestAttributeSet attributes, boolean onlyPageDialog, String title)
+ throws HeadlessException
+ {
+ super((Frame)null, title, true, gc);
+
+ setResizable(false);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+
+ // check and remove service not supporting the flavor
+ if (flavor != null)
+ {
+ ArrayList list = new ArrayList(services.length);
+ for(int i=0; i < services.length; i++)
+ if (services[i].isDocFlavorSupported(flavor))
+ list.add(services[i]);
+
+ if (defaultService != null
+ && (! list.contains(defaultService)))
+ defaultService = (PrintService) list.get(0);
+
+ PrintService[] newServices = new PrintService[list.size()];
+ this.services = (PrintService[]) list.toArray(newServices);
+ }
+ else
+ this.services = services;
+
+ if (defaultService == null)
+ this.defaultService = services[0];
+ else
+ this.defaultService = defaultService;
+
+ this.selectedService = this.defaultService;
+ this.flavor = flavor;
+
+ // the attributes given by the user
+ this.attributes = attributes;
+ // the one to work with during browsing
+ this.atts = new HashPrintRequestAttributeSet(attributes);
+
+ this.onlyPageDialog = onlyPageDialog;
+
+ initUI(onlyPageDialog);
+ pack();
+ updateAll();
+ }
+
+ /**
+ * Constructs a page settings only dialog.
+ *
+ * @param gc the screen to use. <code>null</code> is default screen.
+ * @param service the print service for the page dialog.
+ * the first of the print services in the services array will be used.
+ * @param flavor the flavours to be printed.
+ * @param attributes the attributes requested. Will be updated
+ * by selections done by the user in the dialog.
+ *
+ * @throws HeadlessException if GraphicsEnvironment is headless
+ */
+ public PrinterDialog(GraphicsConfiguration gc, PrintService service,
+ DocFlavor flavor, PrintRequestAttributeSet attributes)
+ throws HeadlessException
+ {
+ this(gc, new PrintService[] {service}, service, flavor, attributes,
+ true, getLocalizedString("title.pagedialog"));
+ }
+
+ /**
+ * Constructs a printer dialog.
+ *
+ * @param gc the screen to use. <code>null</code> is default screen.
+ * @param services the print services to browse (not null).
+ * @param defaultService the default service. If <code>null</code>
+ * the first of the print services in the services array will be used.
+ * @param flavor the flavours to be printed.
+ * @param attributes the attributes requested. Will be updated
+ * by selections done by the user in the dialog.
+ *
+ * @throws HeadlessException if GraphicsEnvironment is headless
+ */
+ public PrinterDialog(GraphicsConfiguration gc, PrintService[] services,
+ PrintService defaultService, DocFlavor flavor,
+ PrintRequestAttributeSet attributes)
+ throws HeadlessException
+ {
+ this(gc, services, defaultService, flavor, attributes,
+ false, getLocalizedString("title.printdialog"));
+ }
+
+ // initializes the gui parts
+ private void initUI(boolean onlyPageDialog)
+ {
+ JPanel buttonPane = new JPanel();
+
+ if (onlyPageDialog)
+ {
+ JPanel pane = new JPanel();
+ pane.setLayout(new BorderLayout());
+ pagesetup_panel = new PageSetupPanel();
+ pane.add(pagesetup_panel, BorderLayout.CENTER);
+
+ ok_bt = new JButton(getLocalizedString("bt.OK"));
+ ok_bt.addActionListener(this);
+ cancel_bt = new JButton(getLocalizedString("bt.cancel"));
+ cancel_bt.addActionListener(this);
+
+ getContentPane().add(pane, BorderLayout.CENTER);
+ }
+ else
+ {
+ general_panel = new GeneralPanel();
+ pagesetup_panel = new PageSetupPanel();
+ appearance_panel = new AppearancePanel();
+
+ JTabbedPane pane = new JTabbedPane();
+ pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ ok_bt = new JButton(getLocalizedString("bt.print"));
+ ok_bt.addActionListener(this);
+ cancel_bt = new JButton(getLocalizedString("bt.cancel"));
+ cancel_bt.addActionListener(this);
+
+ // populate jtabbedpane
+ pane.addTab(getLocalizedString("tab.general"), general_panel);
+ pane.addTab(getLocalizedString("tab.pagesetup"), pagesetup_panel);
+ pane.addTab(getLocalizedString("tab.appearance"), appearance_panel);
+
+ // Put everything together
+ getContentPane().add(pane, BorderLayout.CENTER);
+ }
+
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ buttonPane.add(Box.createHorizontalGlue());
+ buttonPane.add(ok_bt);
+ buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
+ buttonPane.add(cancel_bt);
+
+ getContentPane().add(buttonPane, BorderLayout.PAGE_END);
+ }
+
+ /**
+ * Returns the modified attributes set.
+ * @return The attributes.
+ */
+ public PrintRequestAttributeSet getAttributes()
+ {
+ return attributes;
+ }
+
+ /**
+ * Returns the print service selected by the user.
+ * @return The selected print service.
+ */
+ public PrintService getSelectedPrintService()
+ {
+ return selectedService;
+ }
+
+ /**
+ * Sets the currently selected print service.
+ *
+ * @param service the service selected.
+ */
+ protected void setSelectedPrintService(PrintService service)
+ {
+ selectedService = service;
+ }
+
+ /**
+ * Returns the print service array.
+ * @return The print services.
+ */
+ protected PrintService[] getPrintServices()
+ {
+ return services;
+ }
+
+ /**
+ * Calls update on all panels to adjust
+ * for a new selected print service.
+ */
+ void updateAll()
+ {
+ pagesetup_panel.update();
+
+ if (! onlyPageDialog)
+ {
+ general_panel.update();
+ appearance_panel.update();
+ }
+ }
+
+ boolean categorySupported(Class category)
+ {
+ return getSelectedPrintService().
+ isAttributeCategorySupported(category);
+ }
+
+ Object defaultValue(Class category)
+ {
+ return getSelectedPrintService().
+ getDefaultAttributeValue(category);
+ }
+
+ Attribute attribute(Class category)
+ {
+ return atts.get(category);
+ }
+
+ /**
+ * Action handler for Print/Cancel buttons.
+ * If cancel is pressed we reset the attributes
+ * and the selected service.
+ *
+ * @param e the ActionEvent
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == ok_bt)
+ {
+ setVisible(false);
+ attributes.addAll(atts);
+ dispose();
+ }
+ else
+ {
+ setVisible(false);
+ selectedService = null;
+ dispose();
+ }
+ }
+
+ /**
+ * Retrieves localized messages from the resource bundle.
+ *
+ * @param key the key
+ * @return The localized value for the key.
+ */
+ static final String getLocalizedString(String key) {
+ return messages.getString(key);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java
new file mode 100644
index 00000000000..d391afc7e1a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/DocPrintJobImpl.java
@@ -0,0 +1,471 @@
+/* DocPrintJobImpl.java -- Implementation of DocPrintJob.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import gnu.javax.print.PrintFlavorException;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.print.CancelablePrintJob;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.DocAttributeSet;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintJobAttributeSet;
+import javax.print.attribute.PrintJobAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.event.PrintJobAttributeListener;
+import javax.print.event.PrintJobEvent;
+import javax.print.event.PrintJobListener;
+
+/**
+ * Implementation of the DocPrintJob interface. Implementation is
+ * specific to the <code>IppPrintService</code> implementation.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class DocPrintJobImpl implements CancelablePrintJob
+{
+ /** The print service this job is bound to. */
+ private IppPrintService service;
+
+ /** The set of print job listeners. */
+ private HashSet printJobListener = new HashSet();
+
+ /** The print job attributes listeners. */
+ private ArrayList attributesListener = new ArrayList();
+ /** The print job attributes listeners associated attribute set. */
+ private ArrayList attributesListenerAttributes = new ArrayList();
+
+ /** The username. */
+ private String username;
+ /** The password of the user. */
+ private String password;
+
+ /** Returned job uri. */
+ private JobUri jobUri = null;
+ /** Returned job id. */
+ private JobId jobId = null;
+
+ /** The requesting-username for later canceling */
+ private RequestingUserName requestingUser;
+
+ /** The print job sets. */
+ private PrintJobAttributeSet oldSet = new HashPrintJobAttributeSet();
+ private PrintJobAttributeSet currentSet = new HashPrintJobAttributeSet();
+
+ /**
+ * State variable if we already started printing.
+ */
+ private boolean printing = false;
+
+ // TODO Implement complete PrintJobListener notification
+ // TODO Implement PrintJobAttributeListener notification
+
+ /**
+ * Constructs a DocPrintJobImpl instance bound to the given print service.
+ *
+ * @param service the print service instance.
+ * @param user the user of this print service.
+ * @param passwd the password of the user.
+ */
+ public DocPrintJobImpl(IppPrintService service, String user, String passwd)
+ {
+ this.service = service;
+ username = user;
+ password = passwd;
+ }
+
+ /**
+ * @see DocPrintJob#addPrintJobAttributeListener(PrintJobAttributeListener, PrintJobAttributeSet)
+ */
+ public void addPrintJobAttributeListener(PrintJobAttributeListener listener,
+ PrintJobAttributeSet attributes)
+ {
+ if (listener == null)
+ return;
+
+ attributesListener.add(listener);
+ attributesListenerAttributes.add(attributes);
+ }
+
+ /**
+ * @see DocPrintJob#addPrintJobListener(PrintJobListener)
+ */
+ public void addPrintJobListener(PrintJobListener listener)
+ {
+ if (listener == null)
+ return;
+
+ printJobListener.add(listener);
+ }
+
+ /**
+ * @see javax.print.DocPrintJob#getAttributes()
+ */
+ public PrintJobAttributeSet getAttributes()
+ {
+ return AttributeSetUtilities.unmodifiableView(currentSet);
+ }
+
+ /**
+ * @see javax.print.DocPrintJob#getPrintService()
+ */
+ public PrintService getPrintService()
+ {
+ return service;
+ }
+
+ /**
+ * @see DocPrintJob#print(Doc, PrintRequestAttributeSet)
+ */
+ public void print(Doc doc, PrintRequestAttributeSet attributes)
+ throws PrintException
+ {
+ if (printing)
+ throw new PrintException("already printing");
+
+ printing = true;
+
+ DocAttributeSet docAtts = doc.getAttributes();
+ DocFlavor flavor = doc.getDocFlavor();
+
+ if (flavor == null || (!service.isDocFlavorSupported(flavor)))
+ {
+ notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+ throw new PrintFlavorException("Invalid flavor", new DocFlavor[] {flavor});
+ }
+
+ // merge attributes as doc attributes take precendence
+ // over the print request attributes
+ HashAttributeSet mergedAtts = new HashAttributeSet();
+
+ if (attributes != null)
+ mergedAtts.addAll(attributes);
+ if (docAtts != null)
+ mergedAtts.addAll(docAtts);
+
+ // check for requesting-user-name -add the
+ // executing username if no other is specified
+ // save user name so we can make a cancel operation under same user
+ if (! mergedAtts.containsKey(RequestingUserName.class))
+ {
+ mergedAtts.add(IppPrintService.REQUESTING_USER_NAME);
+ requestingUser = IppPrintService.REQUESTING_USER_NAME;
+ }
+ else
+ {
+ requestingUser = (RequestingUserName)
+ mergedAtts.get(RequestingUserName.class);
+ }
+
+ // same for job-name
+ if (! mergedAtts.containsKey(JobName.class))
+ mergedAtts.add(IppPrintService.JOB_NAME);
+
+ IppResponse response = null;
+
+ try
+ {
+ PrinterURI printerUri = service.getPrinterURI();
+ String printerUriStr = "http" + printerUri.toString().substring(3);
+
+ URI uri = null;
+ try
+ {
+ uri = new URI(printerUriStr);
+ }
+ catch (URISyntaxException e)
+ {
+ // does not happen
+ }
+
+ IppRequest request =
+ new IppRequest(uri, username, password);
+
+ request.setOperationID( (short) OperationsSupported.PRINT_JOB.getValue());
+ request.setOperationAttributeDefaults();
+ request.addOperationAttribute(printerUri);
+
+ if (mergedAtts != null)
+ {
+ request.addAndFilterJobOperationAttributes(mergedAtts);
+ request.addAndFilterJobTemplateAttributes(mergedAtts);
+ }
+
+ // DocFlavor getMimeType returns charset quoted
+ DocumentFormat format = DocumentFormat.createDocumentFormat(flavor);
+ request.addOperationAttribute(format);
+
+ // Get and set the printdata based on the
+ // representation classname
+ String className = flavor.getRepresentationClassName();
+
+ if (className.equals("[B"))
+ {
+ request.setData((byte[]) doc.getPrintData());
+ response = request.send();
+ }
+ else if (className.equals("java.io.InputStream"))
+ {
+ InputStream stream = (InputStream) doc.getPrintData();
+ request.setData(stream);
+ response = request.send();
+ stream.close();
+ }
+ else if (className.equals("[C"))
+ {
+ try
+ {
+ // CUPS only supports UTF-8 currently so we convert
+ // We also assume that char[] is always utf-16 - correct ?
+ String str = new String((char[]) doc.getPrintData());
+ request.setData(str.getBytes("utf-16"));
+ response = request.send();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+ throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+ }
+ }
+ else if (className.equals("java.io.Reader"))
+ {
+ try
+ {
+ // FIXME Implement
+ // Convert a Reader into a InputStream properly encoded
+ response = request.send();
+ throw new UnsupportedEncodingException("not supported yet");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+ throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+ }
+ }
+ else if (className.equals("java.lang.String"))
+ {
+ try
+ {
+ // CUPS only supports UTF-8 currently so we convert
+ // We also assume that String is always utf-16 - correct ?
+ String str = (String) doc.getPrintData();
+ request.setData(str.getBytes("utf-16"));
+ response = request.send();
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+ throw new PrintFlavorException("Invalid charset of flavor", e, new DocFlavor[] {flavor});
+ }
+ }
+ else if (className.equals("java.net.URL"))
+ {
+ URL url = (URL) doc.getPrintData();
+ InputStream stream = url.openStream();
+ request.setData(stream);
+ response = request.send();
+ stream.close();
+ }
+ else if (className.equals("java.awt.image.renderable.RenderableImage")
+ || className.equals("java.awt.print.Printable")
+ || className.equals("java.awt.print.Pageable"))
+ {
+ // For the future :-)
+ throw new PrintException("Not yet supported.");
+ }
+ else
+ {
+ // should not happen - however
+ notifyPrintJobListeners(new PrintJobEvent(this, PrintJobEvent.JOB_FAILED));
+ throw new PrintFlavorException("Invalid flavor", new DocFlavor[] {flavor});
+ }
+
+ // at this point the data is transfered
+ notifyPrintJobListeners(new PrintJobEvent(
+ this, PrintJobEvent.DATA_TRANSFER_COMPLETE));
+ }
+ catch (IOException e)
+ {
+ throw new PrintException("IOException occured.", e);
+ }
+
+ int status = response.getStatusCode();
+ if (! (status == IppStatusCode.SUCCESSFUL_OK
+ || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+ || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+ {
+ notifyPrintJobListeners(new PrintJobEvent(
+ this, PrintJobEvent.JOB_FAILED));
+ throw new PrintException("Printing failed - received statuscode " + Integer.toHexString(status));
+
+ // TODO maybe specific status codes may require to throw a specific
+ // detailed attribute exception
+ }
+ else
+ {
+ // start print job progress monitoring thread
+ // FIXME Implement
+
+ // for now we just notify as finished
+ notifyPrintJobListeners(
+ new PrintJobEvent(this, PrintJobEvent.JOB_COMPLETE));
+ }
+
+ List jobAtts = response.getJobAttributes();
+
+ // extract the uri and id of job for canceling and further monitoring
+ Map jobAttributes = (Map) jobAtts.get(0);
+ jobUri = (JobUri) ((HashSet)jobAttributes.get(JobUri.class)).toArray()[0];
+ jobId = (JobId) ((HashSet)jobAttributes.get(JobId.class)).toArray()[0];
+ }
+
+ /**
+ * @see DocPrintJob#removePrintJobAttributeListener(PrintJobAttributeListener)
+ */
+ public void removePrintJobAttributeListener(PrintJobAttributeListener listener)
+ {
+ if (listener == null)
+ return;
+
+ int index = attributesListener.indexOf(listener);
+ if (index != -1)
+ {
+ attributesListener.remove(index);
+ attributesListenerAttributes.remove(index);
+ }
+ }
+
+ /**
+ * @see DocPrintJob#removePrintJobListener(PrintJobListener)
+ */
+ public void removePrintJobListener(PrintJobListener listener)
+ {
+ if (listener == null)
+ return;
+
+ printJobListener.remove(listener);
+ }
+
+ /**
+ * @see CancelablePrintJob#cancel()
+ */
+ public void cancel() throws PrintException
+ {
+ if (jobUri == null)
+ {
+ throw new PrintException("print job is not yet send");
+ }
+
+ IppResponse response = null;
+
+ try
+ {
+ IppRequest request = new IppRequest(jobUri.getURI(), username, password);
+ request.setOperationID( (short) OperationsSupported.CANCEL_JOB.getValue());
+ request.setOperationAttributeDefaults();
+ request.addOperationAttribute(jobUri);
+ request.addOperationAttribute(requestingUser);
+ response = request.send();
+ }
+ catch (IOException e)
+ {
+ throw new IppException("IOException occured during cancel request.", e);
+ }
+
+ int status = response.getStatusCode();
+ if (! (status == IppStatusCode.SUCCESSFUL_OK
+ || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+ || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+ {
+ notifyPrintJobListeners(new PrintJobEvent(
+ this, PrintJobEvent.JOB_FAILED));
+ throw new PrintException("Canceling failed - received statuscode " + Integer.toHexString(status));
+ }
+ else
+ {
+ notifyPrintJobListeners(new PrintJobEvent(
+ this, PrintJobEvent.JOB_CANCELED));
+ }
+ }
+
+ private void notifyPrintJobListeners(PrintJobEvent e)
+ {
+ Iterator it = printJobListener.iterator();
+ while (it.hasNext())
+ {
+ PrintJobListener l = (PrintJobListener) it.next();
+ if (e.getPrintEventType() == PrintJobEvent.DATA_TRANSFER_COMPLETE)
+ l.printDataTransferCompleted(e);
+ else if (e.getPrintEventType() == PrintJobEvent.JOB_CANCELED)
+ l.printJobCanceled(e);
+ else if (e.getPrintEventType() == PrintJobEvent.JOB_COMPLETE)
+ l.printJobCompleted(e);
+ else if (e.getPrintEventType() == PrintJobEvent.JOB_FAILED)
+ l.printJobFailed(e);
+ else if (e.getPrintEventType() == PrintJobEvent.NO_MORE_EVENTS)
+ l.printJobNoMoreEvents(e);
+ else
+ l.printJobRequiresAttention(e);
+ }
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java
new file mode 100644
index 00000000000..ce6bb4f7e64
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppDelimiterTag.java
@@ -0,0 +1,99 @@
+/* IppDelimiterTag.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+
+/**
+ * IPP Delimiter Tags as described in RFC 2910 section 3.5.1.
+ * <p>
+ * Every delimiter tag value can occur in the protocol field
+ * begin-attribute-group-tag and indicates that the following
+ * attributes will be part of the named group.<br>
+ * The end-of-attributes-tag signals the end of the attributes
+ * section in the IPP request/response and therefore the beginning
+ * of the data section (if any).
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class IppDelimiterTag
+{
+ /** Start of the operation attributes group section. */
+ public static final byte OPERATION_ATTRIBUTES_TAG = 0x01;
+
+ /** Start of the job attributes group section. */
+ public static final byte JOB_ATTRIBUTES_TAG = 0x02;
+
+ /** End of the attributes section and begin of data section. */
+ public static final byte END_OF_ATTRIBUTES_TAG = 0x03;
+
+ /** Start of the printer attributes group section. */
+ public static final byte PRINTER_ATTRIBUTES_TAG = 0x04;
+
+ /** Start of the unsupported attributes group section. */
+ public static final byte UNSUPPORTED_ATTRIBUTES_TAG = 0x05;
+
+
+ // 0x00 reserved for definition in a future IETF
+ // standards track document
+
+ // 0x06-0x0f reserved for future delimiters in IETF
+ // standards track documents
+
+ private IppDelimiterTag()
+ {
+ // not to be instantiated
+ }
+
+ /**
+ * Tests if given value corresponds to a
+ * delimiter tag value.
+ *
+ * @param value the value to test for
+ * @return <code>true</code> if, <code>false</code> otherwise.
+ */
+ public static boolean isDelimiterTag(byte value)
+ {
+ if (value >= 0x01 && value <= 0x05)
+ return true;
+
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppException.java b/libjava/classpath/gnu/javax/print/ipp/IppException.java
new file mode 100644
index 00000000000..27b156fd857
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppException.java
@@ -0,0 +1,88 @@
+/* IppException.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import javax.print.PrintException;
+
+/**
+ * <code>IppException</code> signals exception thrown by
+ * the IPP implementation for various things like a failed
+ * ipp request or a wrapped io exception.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class IppException extends PrintException
+{
+ /**
+ * Creates an <code>IppException</code>.
+ */
+ public IppException()
+ {
+ super();
+ }
+
+ /**
+ * Creates an <code>IppException</code>.
+ * @param s the message of the exception.
+ */
+ public IppException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Creates an <code>IppException</code>.
+ * @param e the exception cause this one.
+ */
+ public IppException(Exception e)
+ {
+ super(e);
+ }
+
+ /**
+ * Creates an <code>IppException</code>.
+ * @param s the message of the exception.
+ * @param e the exception cause this one.
+ */
+ public IppException(String s, Exception e)
+ {
+ super(s, e);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java
new file mode 100644
index 00000000000..df2a4793c72
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppMultiDocPrintService.java
@@ -0,0 +1,87 @@
+/* IppMultiDocPrintService.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+
+import java.net.URI;
+
+import javax.print.MultiDocPrintJob;
+import javax.print.MultiDocPrintService;
+
+/**
+ * Implementation of the MultiDocPrintService interface
+ * for IPP based printers.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class IppMultiDocPrintService extends IppPrintService
+ implements MultiDocPrintService
+{
+ /** The username. */
+ private transient String user;
+
+ /** The password of the user. */
+ private transient String passwd;
+
+ /**
+ * Creates a <code>IppMultiDocPrintService</code> object.
+ *
+ * @param uri the URI of the IPP printer.
+ * @param username the user of this print service.
+ * @param password the password of the user.
+ *
+ * @throws IppException if an error during connection occurs.
+ */
+ public IppMultiDocPrintService(URI uri, String username, String password)
+ throws IppException
+ {
+ super(uri, username, password);
+ user = username;
+ passwd = password;
+ }
+
+ /**
+ * @see MultiDocPrintService#createMultiDocPrintJob()
+ */
+ public MultiDocPrintJob createMultiDocPrintJob()
+ {
+ return new MultiDocPrintJobImpl(this, user, passwd);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java b/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java
new file mode 100644
index 00000000000..ce3ef9e1538
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppPrintService.java
@@ -0,0 +1,916 @@
+/* IppPrintService.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import gnu.classpath.SystemProperties;
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.defaults.CopiesDefault;
+import gnu.javax.print.ipp.attribute.defaults.FinishingsDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobPriorityDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.MultipleDocumentHandlingDefault;
+import gnu.javax.print.ipp.attribute.defaults.NumberUpDefault;
+import gnu.javax.print.ipp.attribute.defaults.OrientationRequestedDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrintQualityDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrinterResolutionDefault;
+import gnu.javax.print.ipp.attribute.defaults.SidesDefault;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.supported.CompressionSupported;
+import gnu.javax.print.ipp.attribute.supported.DocumentFormatSupported;
+import gnu.javax.print.ipp.attribute.supported.FinishingsSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentHandlingSupported;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+import gnu.javax.print.ipp.attribute.supported.OrientationRequestedSupported;
+import gnu.javax.print.ipp.attribute.supported.PageRangesSupported;
+import gnu.javax.print.ipp.attribute.supported.PrintQualitySupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+import gnu.javax.print.ipp.attribute.supported.SidesSupported;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintService;
+import javax.print.ServiceUIFactory;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.AttributeSetUtilities;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressions;
+import javax.print.attribute.standard.JobImpressionsSupported;
+import javax.print.attribute.standard.JobKOctets;
+import javax.print.attribute.standard.JobKOctetsSupported;
+import javax.print.attribute.standard.JobMediaSheets;
+import javax.print.attribute.standard.JobMediaSheetsSupported;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobPrioritySupported;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.Sides;
+import javax.print.event.PrintServiceAttributeListener;
+
+
+/**
+ * Implementation of the PrintService interface
+ * for IPP based printers.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class IppPrintService implements PrintService
+{
+ /**
+ * A Map with sets of attributes.
+ * key: A attribute category
+ * value: A set with values
+ *
+ * IPP may return sets of attributes e.g. for supported
+ * compression methods so we need to map to sets here.
+ */
+ private Map printerAttr;
+
+ /** The set of listeners.*/
+ private HashSet printServiceAttributeListener;
+
+ /** The username. */
+ private transient String user;
+
+ /** The password of the user. */
+ private transient String passwd;
+
+ /** The name of this print service. */
+ private String name;
+
+ /** The list of supported document flavors. */
+ private List flavors;
+
+ /** The standard printer URI. */
+ private PrinterURI printerUri;
+
+ /** The list of all supported printer URIs. */
+ private ArrayList printerUris;
+
+ /**
+ * Logger for tracing - enable by passing
+ * -Dgnu.classpath.debug.components=ipp to the vm.
+ */
+ static final Logger logger = SystemLogger.SYSTEM;
+
+ /**
+ * requesting-user-name defaults to the executing user.
+ */
+ public static final RequestingUserName REQUESTING_USER_NAME;
+
+ /**
+ * job-name defaults to "Java Printing".
+ */
+ public static final JobName JOB_NAME;
+
+ static
+ {
+ JOB_NAME = new JobName("Java Printing", null);
+ REQUESTING_USER_NAME = new RequestingUserName(
+ SystemProperties.getProperty("user.name", ""), null);
+ }
+
+ // TODO Implement service listener notification and change detection.
+
+ /**
+ * Creates a <code>IppPrintService</code> object.
+ *
+ * @param uri the URI of the IPP printer.
+ * @param username the user of this print service.
+ * @param password the password of the user.
+ *
+ * @throws IppException if an error during connection occurs.
+ */
+ public IppPrintService(URI uri, String username, String password)
+ throws IppException
+ {
+ printerUri = new PrinterURI(uri);
+ user = username;
+ passwd = password;
+
+ printServiceAttributeListener = new HashSet();
+
+ printerAttr = getPrinterAttributes();
+ processResponse();
+ }
+
+ /**
+ * Fetches all printer attributes from the IPP printer.
+ *
+ * @return The Map with the printer attributes.
+ * @throws IppException if an error occurs.
+ */
+ private Map getPrinterAttributes() throws IppException
+ {
+ IppResponse response = null;
+
+ try
+ {
+ IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);
+
+ int operation = OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue();
+ request.setOperationID((short) operation);
+ request.setOperationAttributeDefaults();
+ request.addOperationAttribute(printerUri);
+
+ response = request.send();
+ }
+ catch (IOException e)
+ {
+ throw new IppException("IOException in IPP request/response.", e);
+ }
+
+ return (Map) response.getPrinterAttributes().get(0);
+ }
+
+ /**
+ * Extracts the set of attribute values for a given
+ * attribute category from the printer attributes map.
+ *
+ * @param attributeClass the category
+ * @return The set of attributes of the category.
+ */
+ private Set getPrinterAttributeSet(Class attributeClass)
+ {
+ return (Set) printerAttr.get(attributeClass);
+ }
+
+ /**
+ * Extracts the default attribute value for the given
+ * default attribute category from the printer attributes map.
+ *
+ * @param attributeClass the category
+ * @return The default attribute.
+ *
+ * @throws ClassCastException if attributClass is not an
+ * instance of <code>DefaultValueAttribute</code>.
+ */
+ private Attribute getPrinterDefaultAttribute(Class attributeClass)
+ {
+ Set set = (Set) printerAttr.get(attributeClass);
+ return ((DefaultValueAttribute) set.toArray()[0]).getAssociatedAttribute();
+ }
+
+ /**
+ * Processes the response, sorts and splits the attributes.
+ */
+ private void processResponse()
+ {
+ // printer name
+ PrinterName[] tmp = (PrinterName[]) getPrinterAttributeSet(
+ PrinterName.class).toArray(new PrinterName[1]);
+ name = tmp[0].getValue();
+
+ // supported flavors
+ // TODO Check if charsets-supported are charsets that are actually supported
+ // for text doc flavors as cups doesn't send charset parameters
+
+ // utf-8 is supported at least - so we go with this only for now
+ flavors = new ArrayList();
+ Set flavorAttributes = getPrinterAttributeSet(DocumentFormatSupported.class);
+ if (flavorAttributes != null)
+ {
+ for (Iterator it = flavorAttributes.iterator(); it.hasNext();)
+ {
+ String mimeType = ((DocumentFormatSupported) it.next()).getValue();
+
+ if (mimeType.equals("text/plain"))
+ {
+ flavors.add(DocFlavor.CHAR_ARRAY.TEXT_PLAIN);
+ flavors.add(DocFlavor.READER.TEXT_PLAIN);
+ flavors.add(DocFlavor.STRING.TEXT_PLAIN);
+
+ // add utf-8
+ mimeType = mimeType + "; charset=utf-8";
+ }
+ else if (mimeType.equals("text/html"))
+ {
+ flavors.add(DocFlavor.CHAR_ARRAY.TEXT_HTML);
+ flavors.add(DocFlavor.READER.TEXT_HTML);
+ flavors.add(DocFlavor.STRING.TEXT_HTML);
+
+ // add utf-8
+ mimeType = mimeType + "; charset=utf-8";
+ }
+
+ // Process the predefined DocFlavors and if mimetype is
+ // equal put them into the flavors array - otherwise
+ // just build them as binarie class representation.
+ boolean changed = false;
+ try
+ {
+ Class[] clazzes = new Class[] { DocFlavor.BYTE_ARRAY.class,
+ DocFlavor.INPUT_STREAM.class,
+ DocFlavor.URL.class };
+
+ for (int j = 0; j < clazzes.length; j++)
+ {
+ Field[] fields = clazzes[j].getDeclaredFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ if (fields[i].getType().equals(clazzes[j]))
+ {
+ DocFlavor flavor = (DocFlavor) fields[i].get(null);
+ if (flavor.getMimeType().equals(mimeType))
+ changed = flavors.add(flavor);
+ }
+ }
+ }
+ if (!changed) // not in predefined constants of DocFlavor
+ {
+ // everything should be supported as binary stuff
+ flavors.add(new DocFlavor(mimeType, "[B"));
+ flavors.add(new DocFlavor(mimeType, "java.io.InputStream"));
+ flavors.add(new DocFlavor(mimeType, "java.net.URL"));
+ }
+ }
+ catch (SecurityException e)
+ {
+ // should not happen
+ }
+ catch (IllegalArgumentException e)
+ {
+ // should not happen
+ }
+ catch (IllegalAccessException e)
+ {
+ // should not happen, all fields are public
+ }
+ }
+ }
+
+ // printer uris
+ Set uris = getPrinterAttributeSet(PrinterUriSupported.class);
+ printerUris = new ArrayList(uris.size());
+ Iterator it = uris.iterator();
+ while (it.hasNext())
+ {
+ PrinterUriSupported uri = (PrinterUriSupported) it.next();
+ printerUris.add( new PrinterURI(uri.getURI()));
+ }
+ }
+
+ /**
+ * We always return a implementation implementing CancelablePrintJob.
+ *
+ * @see javax.print.PrintService#createPrintJob()
+ */
+ public DocPrintJob createPrintJob()
+ {
+ return new DocPrintJobImpl(this, user, passwd);
+ }
+
+
+ /**
+ * @see javax.print.PrintService#getAttribute(java.lang.Class)
+ */
+ public PrintServiceAttribute getAttribute(Class category)
+ {
+ if (category == null)
+ throw new NullPointerException("category may not be null");
+
+ if (! PrintServiceAttribute.class.isAssignableFrom(category))
+ throw new IllegalArgumentException(
+ "category must be of type PrintServiceAttribute");
+
+ Set set = getPrinterAttributeSet(category);
+ if (set != null && set.size() > 0)
+ return (PrintServiceAttribute) set.toArray()[0];
+
+ return null;
+ }
+
+ /**
+ * @see javax.print.PrintService#getAttributes()
+ */
+ public PrintServiceAttributeSet getAttributes()
+ {
+ PrintServiceAttributeSet set = new HashPrintServiceAttributeSet();
+
+ Iterator it = printerAttr.values().iterator();
+ while (it.hasNext())
+ {
+ Iterator it2 = ((Set) it.next()).iterator();
+ while (it2.hasNext())
+ {
+ Attribute attr = (Attribute) it2.next();
+ if (attr instanceof PrintServiceAttribute)
+ set.add(attr);
+ }
+ }
+
+ return AttributeSetUtilities.unmodifiableView(set);
+ }
+
+ /**
+ * @see javax.print.PrintService#getDefaultAttributeValue(java.lang.Class)
+ */
+ public Object getDefaultAttributeValue(Class category)
+ {
+ // required attributes
+ if (category.equals(Fidelity.class))
+ return Fidelity.FIDELITY_FALSE;
+ if (category.equals(JobName.class))
+ return JOB_NAME;
+ if (category.equals(RequestingUserName.class))
+ return REQUESTING_USER_NAME;
+
+ // optional attributes
+ if (category.equals(JobPriority.class)
+ && printerAttr.containsKey(JobPriorityDefault.class))
+ return getPrinterDefaultAttribute(JobPriorityDefault.class);
+ if (category.equals(JobHoldUntil.class)
+ && printerAttr.containsKey(JobHoldUntilDefault.class))
+ return getPrinterDefaultAttribute(JobHoldUntilDefault.class);
+ if (category.equals(JobSheets.class)
+ && printerAttr.containsKey(JobSheetsDefault.class))
+ return getPrinterDefaultAttribute(JobSheetsDefault .class);
+ if (category.equals(MultipleDocumentHandling.class)
+ && printerAttr.containsKey(MultipleDocumentHandlingDefault.class))
+ return getPrinterDefaultAttribute(MultipleDocumentHandlingDefault.class);
+ if (category.equals(Copies.class)
+ && printerAttr.containsKey(CopiesDefault.class))
+ return getPrinterDefaultAttribute(CopiesDefault.class);
+ if (category.equals(Finishings.class)
+ && printerAttr.containsKey(FinishingsDefault.class))
+ return getPrinterDefaultAttribute(FinishingsDefault.class);
+ if (category.equals(Sides.class)
+ && printerAttr.containsKey(SidesDefault.class))
+ return getPrinterDefaultAttribute(SidesDefault.class);
+ if (category.equals(NumberUp.class)
+ && printerAttr.containsKey(NumberUpDefault.class))
+ return getPrinterDefaultAttribute(NumberUpDefault.class);
+ if (category.equals(OrientationRequested.class)
+ && printerAttr.containsKey(OrientationRequestedDefault.class))
+ return getPrinterDefaultAttribute(OrientationRequestedDefault.class);
+ if (category.equals(Media.class)
+ && printerAttr.containsKey(MediaDefault.class))
+ return getPrinterDefaultAttribute(MediaDefault.class);
+ if (category.equals(PrinterResolution.class)
+ && printerAttr.containsKey(PrinterResolutionDefault.class))
+ return getPrinterDefaultAttribute(PrinterResolutionDefault.class);
+ if (category.equals(PrintQuality.class)
+ && printerAttr.containsKey(PrintQualityDefault.class))
+ return getPrinterDefaultAttribute(PrintQualityDefault.class);
+ if (category.equals(Compression.class)
+ && printerAttr.containsKey(CompressionSupported.class))
+ return Compression.NONE;
+ if (category.equals(PageRanges.class))
+ return new PageRanges(1, Integer.MAX_VALUE);
+
+ return null;
+ }
+
+ /**
+ * We return the value of <code>PrinterName</code> here.
+ * @see javax.print.PrintService#getName()
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * We currently provide no factories - just returns null.
+ * @see javax.print.PrintService#getServiceUIFactory()
+ */
+ public ServiceUIFactory getServiceUIFactory()
+ {
+ // SUN does not provide any service factory for
+ // print services (tested on linux/windows)
+
+ // for the moment we do the same - just return null
+ // later on we could provide at least the about UI dialog
+ return null;
+ }
+
+ /**
+ * @see javax.print.PrintService#getSupportedAttributeCategories()
+ */
+ public Class[] getSupportedAttributeCategories()
+ {
+ Set categories = new HashSet();
+
+ // Should only be job template attributes as of section 4.2
+ if (printerAttr.containsKey(JobPrioritySupported.class))
+ categories.add(JobPriority.class);
+ if (printerAttr.containsKey(JobHoldUntilSupported.class))
+ categories.add(JobHoldUntil.class);
+ if (printerAttr.containsKey(JobSheetsSupported.class))
+ categories.add(JobSheets.class);
+ if (printerAttr.containsKey(MultipleDocumentHandlingSupported.class))
+ categories.add(MultipleDocumentHandling.class);
+ if (printerAttr.containsKey(CopiesSupported.class))
+ categories.add(Copies.class);
+ if (printerAttr.containsKey(FinishingsSupported.class))
+ {
+ // if only none finishing is supported - it does not count as supported
+ Set set = getPrinterAttributeSet(FinishingsSupported.class);
+ if (! (set.size() == 1 && set.contains(FinishingsSupported.NONE)))
+ categories.add(Finishings.class);
+ }
+ if (printerAttr.containsKey(PageRangesSupported.class))
+ categories.add(PageRanges.class);
+ if (printerAttr.containsKey(SidesSupported.class))
+ categories.add(Sides.class);
+ if (printerAttr.containsKey(NumberUpSupported.class))
+ categories.add(NumberUp.class);
+ if (printerAttr.containsKey(OrientationRequestedSupported.class))
+ categories.add(OrientationRequested.class);
+ if (printerAttr.containsKey(MediaSupported.class))
+ categories.add(Media.class);
+ if (printerAttr.containsKey(PrinterResolutionSupported.class))
+ categories.add(PrinterResolution.class);
+ if (printerAttr.containsKey(PrintQualitySupported.class))
+ categories.add(PrintQuality.class);
+
+ // Chromaticity, Destination, MediaPrintableArea,
+ // SheetCollate, PresentationDirection - not IPP attributes
+
+ // attributes outside section 4.2
+ if (printerAttr.containsKey(CompressionSupported.class))
+ categories.add(Compression.class);
+ if (printerAttr.containsKey(JobImpressionsSupported.class))
+ categories.add(JobImpressions.class);
+ if (printerAttr.containsKey(JobKOctetsSupported.class))
+ categories.add(JobKOctets.class);
+ if (printerAttr.containsKey(JobMediaSheetsSupported.class))
+ categories.add(JobMediaSheets.class);
+
+ // always supported as required by IPP specification
+ categories.add(Fidelity.class);
+ categories.add(JobName.class);
+ categories.add(RequestingUserName.class);
+
+ return (Class[]) categories.toArray(new Class[categories.size()]);
+ }
+
+ /**
+ * Implemented by a GetPrinterAttributes request. Subclasses providing supported
+ * attribute values totally different may override this methods. Subclass only in
+ * need of handling the response differently may override the method
+ * <code>handleSupportedAttributeValuesResponse(IppResponse, Class)</code> only.
+ *
+ * @see PrintService#getSupportedAttributeValues(Class, DocFlavor, AttributeSet)
+ * @see #handleSupportedAttributeValuesResponse(IppResponse, Class)
+ */
+ public Object getSupportedAttributeValues(Class category, DocFlavor flavor,
+ AttributeSet attributes)
+ {
+ // We currently ignore the attribute set - there is nothing in the IPP
+ // specification which would come closer to what we do here.
+
+ if (category == null)
+ throw new NullPointerException("category may not be null");
+
+ if (!Attribute.class.isAssignableFrom(category))
+ throw new IllegalArgumentException("category must be of type Attribute");
+
+ if (flavor != null && !isDocFlavorSupported(flavor))
+ throw new IllegalArgumentException("flavor is not supported");
+
+ if (!isAttributeCategorySupported(category))
+ return null;
+
+ // always supported
+ if (category.equals(Fidelity.class))
+ return new Fidelity[] { Fidelity.FIDELITY_FALSE, Fidelity.FIDELITY_TRUE };
+ if (category.equals(JobName.class))
+ return JOB_NAME;
+ if (category.equals(RequestingUserName.class))
+ return REQUESTING_USER_NAME;
+
+ // map category to category-supported
+ String categoryName = IppUtilities.getSupportedAttrName(category);
+
+ IppResponse response = null;
+ try
+ {
+ IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);
+ request.setOperationID(
+ (short) OperationsSupported.GET_PRINTER_ATTRIBUTES.getValue());
+ request.setOperationAttributeDefaults();
+ request.addOperationAttribute(new RequestedAttributes(categoryName));
+ request.addOperationAttribute(printerUri);
+
+ if (flavor != null)
+ {
+ DocumentFormat f = DocumentFormat.createDocumentFormat(flavor);
+ request.addOperationAttribute(f);
+ }
+
+ response = request.send();
+
+ int status = response.getStatusCode();
+ if (! (status == IppStatusCode.SUCCESSFUL_OK
+ || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+ || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+ {
+ logger.log(Component.IPP, "Statuscode not OK - got:" + status);
+ }
+ }
+ catch (IOException e)
+ {
+ // method cannot throw exception - just log
+ logger.log(Component.IPP, "IOException", e);
+ }
+ catch (IppException e)
+ {
+ // method cannot throw exception - just log
+ logger.log(Component.IPP, "IPPException", e);
+ }
+
+ return handleSupportedAttributeValuesResponse(response, category);
+ }
+
+ /**
+ * Called to handle the supported attribute values response for the given
+ * category. This might be overridden by subclasses with different requirements
+ * for parsing/handling the response from the GetPrinterAttributes.
+ *
+ * @param response the response of the GetPrinterAttributes IPP request
+ * @param category the category for which the supported values are requested
+ * @return A object indicating the supported values for the given attribute
+ * category, or <code>null</code> if this print service doesn't support the
+ * given attribute category at all.
+ *
+ * @see #getSupportedAttributeValues(Class, DocFlavor, AttributeSet)
+ */
+ protected Object handleSupportedAttributeValuesResponse(IppResponse response,
+ Class category)
+ {
+ List printerAtts = response.getPrinterAttributes();
+
+ // only one will be returned
+ Map printerAttribute = (Map) printerAtts.get(0);
+ Class suppCategory = IppUtilities.getSupportedCategory(category);
+ Set attr = (Set) printerAttribute.get(suppCategory);
+
+ // We sometime assume its a single instance with arbritrary value just indicating
+ // support or an array which is returned. This is because I sometimes just choosed
+ // what sounds right to me - as I have yet to find a printer which supports every
+ // special category in the SUN implementation to see what they return :-)
+
+ // Map whats in the JSP API
+ if (suppCategory.equals(JobPrioritySupported.class))
+ return (JobPrioritySupported) attr.toArray(new JobPrioritySupported[1])[0];
+ if (suppCategory.equals(JobHoldUntilSupported.class))
+ return new JobHoldUntil(new Date());
+ if (suppCategory.equals(JobSheetsSupported.class))
+ return JobSheetsSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(MultipleDocumentHandlingSupported.class))
+ return MultipleDocumentHandlingSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(CopiesSupported.class))
+ return (CopiesSupported) attr.toArray(new CopiesSupported[1])[0];
+ if (suppCategory.equals(FinishingsSupported.class))
+ return FinishingsSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(PageRangesSupported.class))
+ return new PageRanges[] { new PageRanges(1, Integer.MAX_VALUE) };
+ if (suppCategory.equals(OrientationRequestedSupported.class))
+ return OrientationRequestedSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(MediaSupported.class))
+ return MediaSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(PrinterResolutionSupported.class))
+ return PrinterResolutionSupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(PrintQualitySupported.class))
+ return PrintQualitySupported.getAssociatedAttributeArray(attr);
+ if (suppCategory.equals(CompressionSupported.class))
+ return CompressionSupported.getAssociatedAttributeArray(attr);
+ // Special handling as it might also be in range of integers
+ if (suppCategory.equals(NumberUpSupported.class))
+ {
+ NumberUpSupported[] tmp = (NumberUpSupported[])
+ attr.toArray(new NumberUpSupported[attr.size()]);
+
+ if (attr.size() == 1) // number-up maybe in rangeofintegers
+ return tmp[0];
+
+ int[][] members = new int[attr.size()][2];
+ for (int j = 0; j < attr.size(); j++)
+ {
+ int value = tmp[j].getMembers()[0][0];
+ members[j] = new int[] { value, value };
+ }
+
+ NumberUpSupported supported = new NumberUpSupported(members);
+ return supported;
+ }
+
+ return null;
+ }
+
+ /**
+ * @see javax.print.PrintService#getSupportedDocFlavors()
+ */
+ public DocFlavor[] getSupportedDocFlavors()
+ {
+ return (DocFlavor[]) flavors.toArray(new DocFlavor[flavors.size()]);
+ }
+
+ /**
+ * This is done by a validate-job operation and actually implemented in
+ * this generic IPP reference implementation. Subclasses which does
+ * not correctly support Validate-Job operation might want to override this.
+ *
+ * @see PrintService#getUnsupportedAttributes(DocFlavor, AttributeSet)
+ */
+ public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
+ AttributeSet attributes)
+ {
+ if (flavor != null && !isDocFlavorSupported(flavor))
+ throw new IllegalArgumentException("flavor is not supported");
+
+ IppResponse response = null;
+ try
+ {
+ IppRequest request = new IppRequest(printerUri.getURI(), user, passwd);
+ short operationId = (short) OperationsSupported.VALIDATE_JOB.getValue();
+ request.setOperationID(operationId);
+ request.setOperationAttributeDefaults();
+ request.addOperationAttribute(printerUri);
+ request.addOperationAttribute(Fidelity.FIDELITY_TRUE);
+
+ if (attributes != null && attributes.size() > 0)
+ {
+ request.addAndFilterJobOperationAttributes(attributes);
+ request.addAndFilterJobTemplateAttributes(attributes);
+ }
+
+ if (flavor != null)
+ {
+ DocumentFormat f = DocumentFormat.createDocumentFormat(flavor);
+ request.addOperationAttribute(f);
+ }
+
+ response = request.send();
+
+ int status = response.getStatusCode();
+ if (! (status == IppStatusCode.SUCCESSFUL_OK
+ || status == IppStatusCode.SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES
+ || status == IppStatusCode.SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES) )
+ {
+ logger.log(Component.IPP, "Statuscode not OK - got:" + status);
+ }
+ }
+ catch (IOException e)
+ {
+ // method cannot throw exception - just log
+ logger.log(Component.IPP, "IOException", e);
+ }
+ catch (IppException e)
+ {
+ // method cannot throw exception - just log
+ logger.log(Component.IPP, "IPPException", e);
+ }
+
+ // Validate Jobs returns only Unsupported and Operation
+ List unsupportedMaps = response.getUnsupportedAttributes();
+ if (unsupportedMaps.size() == 0)
+ return null;
+
+ Map unsupportedAttr = (Map) unsupportedMaps.get(0);
+ if (unsupportedAttr.size() == 0)
+ return null;
+
+ // Convert the return map with unsupported attributes
+ // into an AttribueSet instance
+ HashAttributeSet set = new HashAttributeSet();
+ Iterator it = unsupportedAttr.values().iterator();
+ while (it.hasNext())
+ {
+ Set unsupported = (Set) it.next();
+ Iterator it2 = unsupported.iterator();
+ while (it2.hasNext())
+ set.add((Attribute) it2.next());
+ }
+
+ return set;
+ }
+
+ /**
+ * @see PrintService#isAttributeCategorySupported(Class)
+ */
+ public boolean isAttributeCategorySupported(Class category)
+ {
+ if (category == null)
+ throw new NullPointerException("category may not be null");
+
+ if (! Attribute.class.isAssignableFrom(category))
+ throw new IllegalArgumentException("category must be of type Attribute");
+
+ return Arrays.asList(getSupportedAttributeCategories()).contains(category);
+ }
+
+ /**
+ * @see PrintService#isAttributeValueSupported(Attribute, DocFlavor, AttributeSet)
+ */
+ public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor,
+ AttributeSet attributes)
+ {
+ // just redirect to getSupportedAttributeValues
+ Object values = getSupportedAttributeValues(attrval.getCategory(),
+ flavor, attributes);
+ // null means none supported
+ if (values == null)
+ return false;
+
+ // object may be an array
+ if (values.getClass().isArray())
+ return Arrays.asList((Object[]) values).contains(attrval);
+
+ // may be a single instance of the category (value is irrelevant)
+ if (values.getClass().equals(attrval.getCategory()))
+ return true;
+
+ // a single instance of another class to give the bounds
+ // copies
+ if (values.getClass().equals(CopiesSupported.class))
+ return ((CopiesSupported) values).contains((IntegerSyntax) attrval);
+ // number up
+ if (values.getClass().equals(NumberUpSupported.class))
+ return ((NumberUpSupported) values).contains((IntegerSyntax) attrval);
+ // job priority
+ if (values.getClass().equals(JobPrioritySupported.class))
+ {
+ JobPriority priority = (JobPriority) attrval;
+ JobPrioritySupported maxSupported = (JobPrioritySupported) values;
+ if (priority.getValue() < maxSupported.getValue())
+ return true;
+ }
+
+ // I am unsure if these might also show up - not yet found a printer where
+ // Suns implementation supports them:
+ // JobImpressionsSupported, JobKOctetsSupported, JobMediaSheetsSupported
+
+ return false;
+ }
+
+
+ /**
+ * @see javax.print.PrintService#isDocFlavorSupported(DocFlavor)
+ */
+ public boolean isDocFlavorSupported(DocFlavor flavor)
+ {
+ if (flavor == null)
+ throw new NullPointerException("DocFlavor may not be null.");
+
+ return flavors.contains(flavor);
+ }
+
+
+ /**
+ * @see PrintService#addPrintServiceAttributeListener(PrintServiceAttributeListener)
+ */
+ public void addPrintServiceAttributeListener(
+ PrintServiceAttributeListener listener)
+ {
+ printServiceAttributeListener.add(listener);
+ }
+
+ /**
+ * @see PrintService#removePrintServiceAttributeListener(PrintServiceAttributeListener)
+ */
+ public void removePrintServiceAttributeListener(
+ PrintServiceAttributeListener listener)
+ {
+ printServiceAttributeListener.remove(listener);
+ }
+
+ /**
+ * Returns "IppPrinter: " + <code>getName()</code>
+ * @return The string representation.
+ */
+ public String toString()
+ {
+ return "IppPrinter: " + getName();
+ }
+
+ /**
+ * Returns the printer-uri of this print service.
+ *
+ * @return The printer-uri attribute.
+ */
+ public PrinterURI getPrinterURI()
+ {
+ return printerUri;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppRequest.java b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
new file mode 100644
index 00000000000..8abab519282
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppRequest.java
@@ -0,0 +1,857 @@
+/* IppRequest.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+import gnu.javax.print.ipp.attribute.RequestedAttributes;
+import gnu.javax.print.ipp.attribute.job.AttributesCharset;
+import gnu.javax.print.ipp.attribute.job.AttributesNaturalLanguage;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.DateTimeSyntax;
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.HashAttributeSet;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.SetOfIntegerSyntax;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.URISyntax;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.DocumentName;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressions;
+import javax.print.attribute.standard.JobKOctets;
+import javax.print.attribute.standard.JobMediaSheets;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobOriginatingUserName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterURI;
+import javax.print.attribute.standard.RequestingUserName;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+
+/**
+ * <code>IppRequest</code> models a request to an IPP compatible
+ * server as described in RFC 2910 - IPP/1.1: Encoding and Transport.
+ * <p>
+ * The byte stream is structured as follows (for an official description
+ * please have a look at the RFC document mentioned above):
+ * <ul>
+ * <li>version-number - 2 bytes - required</li>
+ * <li>operation-id - 2 bytes - required</li>
+ * <li>request-id - 4 bytes - required</li>
+ * <li>attribute-group - n bytes - 0 or more</li>
+ * <li>end-of-attributes-tag - 1 byte - required</li>
+ * <li>data - q bytes - optional</li>
+ * </ul>
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class IppRequest
+{
+
+ /**
+ * Helper class used to write the attributes of a request
+ * into the supplied data output stream in the correct way.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ class RequestWriter
+ {
+ private DataOutputStream out;
+
+ /**
+ * Creates a RequestWriter.
+ *
+ * @param stream the stream to write to.
+ */
+ RequestWriter(DataOutputStream stream)
+ {
+ out = stream;
+ }
+
+ /**
+ * Writes an attribute in IntegerSyntax into the stream.
+ * @param attribute the attribute
+ * @throws IOException if thrown by the stream
+ */
+ private void write(IntegerSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.INTEGER);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(4); // length, integer is 4 bytes
+ out.writeInt(attribute.getValue());
+ }
+
+ /**
+ * Writes an attribute in EnumSyntax into the stream.
+ * @param attribute the attribute
+ * @throws IOException if thrown by the stream
+ */
+ private void write(EnumSyntax attribute) throws IOException
+ {
+ // in JPS API enum syntax is used for enums, keyword and boolean types
+ String name = ((Attribute) attribute).getName();
+
+ // the enum value types
+ if (attribute instanceof Finishings
+ || attribute instanceof OrientationRequested
+ || attribute instanceof PrintQuality)
+ {
+ out.writeByte(IppValueTag.ENUM);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(4); // length, enum is 4 bytes
+ out.writeInt(attribute.getValue());
+ }
+ // the boolean value type
+ else if (attribute instanceof Fidelity)
+ {
+ out.writeByte(IppValueTag.BOOLEAN);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(1); // length, boolean is 1 bytes
+ out.writeByte(attribute.getValue() == 0 ? 0x00 : 0x01);
+ }
+ // the keyword value types
+ else
+ {
+ String keyword = attribute.toString();
+ out.writeByte(IppValueTag.KEYWORD);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(keyword.length());
+ out.write(keyword.getBytes());
+ }
+ }
+
+ /**
+ * Writes an attribute in SetOfIntegerSyntax into the stream.
+ * @param attribute the attribute
+ * @throws IOException if thrown by the stream
+ */
+ private void write(SetOfIntegerSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ int[][] ranges = attribute.getMembers();
+ for (int i = 0; i < ranges.length; i++)
+ {
+ out.writeByte(IppValueTag.RANGEOFINTEGER);
+ if (i == 0)
+ {
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ }
+ else
+ out.writeShort(0x0000); // only name-length
+
+ out.writeShort(8); // range is 8 bytes
+ out.writeInt(ranges[i][0]);
+ out.writeInt(ranges[i][1]);
+ }
+ }
+
+ /**
+ * Writes an attribute in ResolutionSyntax into the stream.
+ * @param attribute the attribute
+ * @throws IOException if thrown by the stream
+ */
+ private void write(ResolutionSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.RESOLUTION);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(9); // length fixed to 9
+ out.writeInt(attribute.getCrossFeedResolution(ResolutionSyntax.DPI));
+ out.writeInt(attribute.getFeedResolution(ResolutionSyntax.DPI));
+ out.writeByte(ResolutionSyntax.DPI);
+ }
+
+ /**
+ * Writes an attribute in DateTimeSyntax into the stream.
+ * <p>
+ * The syntax value is defined as 11 octets follwing the
+ * DateAndTime format of RFC 1903. (see IppResponse)
+ * </p>
+ *
+ * @param attribute the attribute
+ * @throws IOException if thrown by the stream
+ */
+ private void write(DateTimeSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.DATETIME);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(11); // length fixed to 11
+
+ Date date = attribute.getValue();
+ Calendar cal = new GregorianCalendar();
+ cal.setTime(date);
+
+ out.writeShort(cal.get(Calendar.YEAR));
+ out.writeByte(cal.get(Calendar.MONTH));
+ out.writeByte(cal.get(Calendar.DAY_OF_MONTH));
+ out.writeByte(cal.get(Calendar.HOUR_OF_DAY));
+ out.writeByte(cal.get(Calendar.MINUTE));
+ int second = cal.get(Calendar.SECOND);
+ out.writeByte(second == 0 ? 60 : second);
+ out.writeByte(cal.get(Calendar.MILLISECOND) / 100);
+
+ int offsetInMillis = cal.get(Calendar.ZONE_OFFSET);
+ char directionFromUTC = '+';
+ if (offsetInMillis < 0)
+ {
+ directionFromUTC = '-';
+ offsetInMillis = offsetInMillis * (-1);
+ }
+
+ out.writeByte(directionFromUTC);
+ out.writeByte(offsetInMillis / 3600000); // hours
+ out.writeByte((offsetInMillis % 3600000) / 60000); // minutes
+ }
+
+ /**
+ * Writes an attribute in TextSyntax into the stream.
+ * <p>
+ * By default attributes are qritten as TEXT_WITHOUT_LANGUAGE value-tag.
+ * As some attributes in the JPS are TextSyntax attributes but actually
+ * of NAME value-tag in IPP this method checks for these attributes and
+ * writes them as NAME_WITHOUT_LANGUAGE value-tag into the stream.
+ * </p>
+ *
+ * @param attribute the attribute
+ * @param out the stream to write to
+ * @throws IOException if thrown by the stream
+ */
+ private void write(TextSyntax attribute) throws IOException
+ {
+ // We only use *WithoutLanguage, correct according to spec.
+ String name = ((Attribute) attribute).getName();
+
+ if (attribute instanceof RequestingUserName
+ || attribute instanceof JobName
+ || attribute instanceof DocumentName
+ || attribute instanceof JobOriginatingUserName)
+ out.writeByte(IppValueTag.NAME_WITHOUT_LANGUAGE);
+ else if (attribute instanceof DocumentFormat)
+ out.writeByte(IppValueTag.MIME_MEDIA_TYPE);
+ else
+ out.writeByte(IppValueTag.TEXT_WITHOUT_LANGUAGE);
+
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(attribute.getValue().length());
+ out.write(attribute.getValue().getBytes());
+ }
+
+ /**
+ * Writes an attribute in URISyntax into the stream.
+ * @param attribute the attribute
+ * @param out the stream to write to
+ * @throws IOException if thrown by the stream
+ */
+ private void write(URISyntax attribute) throws IOException
+ {
+ // only uriScheme syntax type should not appear
+ // in a request (reference-uri-schemes-supported)
+ String name = ((Attribute) attribute).getName();
+ String uriAscii = attribute.getURI().toASCIIString();
+ out.writeByte(IppValueTag.URI);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(uriAscii.length());
+ out.write(uriAscii.getBytes());
+ }
+
+ /**
+ * Writes an attribute in CharsetSyntax into the stream.
+ * @param attribute the attribute
+ * @param out the stream to write to
+ * @throws IOException if thrown by the stream
+ */
+ private void write(CharsetSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.CHARSET);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(attribute.getValue().length());
+ out.write(attribute.getValue().getBytes());
+ }
+
+ /**
+ * Writes an attribute in NaturalLanguageSyntax into the stream.
+ * @param attribute the attribute
+ * @param out the stream to write to
+ * @throws IOException if thrown by the stream
+ */
+ private void write(NaturalLanguageSyntax attribute) throws IOException
+ {
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.NATURAL_LANGUAGE);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(attribute.getValue().length());
+ out.write(attribute.getValue().getBytes());
+ }
+
+ /**
+ * Writes an attribute in RequestedAttributes into the stream.
+ * @param attribute the attribute
+ * @param out the stream to write to
+ * @throws IOException if thrown by the stream
+ */
+ private void write(RequestedAttributes attribute) throws IOException
+ {
+ List values = attribute.getValues();
+
+ String name = ((Attribute) attribute).getName();
+ out.writeByte(IppValueTag.KEYWORD);
+ out.writeShort(name.length());
+ out.write(name.getBytes());
+ out.writeShort(((String) values.get(0)).length());
+ out.write(((String) values.get(0)).getBytes());
+
+ for (int i=1; i < values.size(); i++)
+ {
+ out.writeByte(IppValueTag.KEYWORD);
+ out.writeShort(0x0000); // length for additional value
+ out.writeShort(((String) values.get(i)).length());
+ out.write(((String) values.get(i)).getBytes());
+ }
+ }
+
+
+ /**
+ * Writes the given operation attribute group of the given map instance
+ * (key=group, values=set of attributes) into the supplied data
+ * output stream.
+ *
+ * @param attributes the set with the attributes.
+ *
+ * @throws IOException if thrown by the used DataOutputStream.
+ * @throws IppException if unknown attributes occur.
+ */
+ public void writeOperationAttributes(AttributeSet attributes)
+ throws IOException, IppException
+ {
+ out.write(IppDelimiterTag.OPERATION_ATTRIBUTES_TAG);
+
+ // its essential to write these two in this order and as first ones
+ Attribute att = attributes.get(AttributesCharset.class);
+ write((CharsetSyntax) att);
+
+ logger.log(Component.IPP, "Attribute: Name: <"
+ + att.getCategory().getName() + "> Value: <" + att.toString() + ">");
+
+ attributes.remove(AttributesCharset.class);
+
+ att = attributes.get(AttributesNaturalLanguage.class);
+ write((NaturalLanguageSyntax) att);
+ attributes.remove(AttributesNaturalLanguage.class);
+
+ logger.log(Component.IPP, "Attribute: Name: <"
+ + att.getCategory().getName() + "> Value: <" + att.toString() + ">");
+
+ // furthermore its essential to now write out the target attribute
+ PrinterURI printerUri = (PrinterURI) attributes.get(PrinterURI.class);
+ JobUri jobUri = (JobUri) attributes.get(JobUri.class);
+ JobId jobId = (JobId) attributes.get(JobId.class);
+ if (printerUri != null && jobId == null && jobUri == null)
+ {
+ write(printerUri);
+ attributes.remove(PrinterURI.class);
+ logger.log(Component.IPP, "Attribute: Name: <" + printerUri
+ .getCategory().getName() + "> Value: <" + printerUri.toString() + ">");
+ }
+ else if (jobUri != null && jobId == null && printerUri == null)
+ {
+ write(jobUri);
+ attributes.remove(JobUri.class);
+ logger.log(Component.IPP, "Attribute: Name: <" + jobUri
+ .getCategory().getName() + "> Value: <" + jobUri.toString() + ">");
+ }
+ else if (printerUri != null && jobId != null && jobUri == null)
+ {
+ write(printerUri); // must be third
+ write(jobId);
+ attributes.remove(PrinterURI.class);
+ attributes.remove(JobId.class);
+ logger.log(Component.IPP, "Attribute: Name: <" + printerUri
+ .getCategory().getName() + "> Value: <" + printerUri.toString() + ">");
+ logger.log(Component.IPP, "Attribute: Name: <" + jobId.getCategory()
+ .getName() + "> Value: <" + jobId.toString() + ">");
+ }
+ else if (jobUri != null && jobId != null)
+ {
+ write(jobUri);
+ attributes.remove(JobUri.class);
+ attributes.remove(JobId.class); // MUST NOT redundant
+ logger.log(Component.IPP, "Attribute: Name: <" + jobUri.getCategory()
+ .getName() + "> Value: <" + jobUri.toString() + ">");
+ }
+ else
+ {
+ new IppException("Unknown target operation attribute combination.");
+ }
+
+ writeAttributes(attributes);
+ }
+
+ /**
+ * Writes the given attribute groups of the given map instance
+ * (key=group, values=set of attributes) into the supplied data
+ * output stream.
+ *
+ * @param attributes the set with the attributes.
+ *
+ * @throws IOException if thrown by the used DataOutputStream.
+ * @throws IppException if unknown attributes occur.
+ */
+ public void writeAttributes(AttributeSet attributes)
+ throws IOException, IppException
+ {
+ Attribute[] attributeArray = attributes.toArray();
+ for (int i = 0; i < attributeArray.length; i++)
+ {
+ logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
+ .getCategory().getName() + "> Value: <"
+ + attributeArray[i].toString() + ">");
+
+ if (attributeArray[i] instanceof IntegerSyntax)
+ write((IntegerSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof TextSyntax)
+ write((TextSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof DateTimeSyntax)
+ write((DateTimeSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof ResolutionSyntax)
+ write((ResolutionSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof SetOfIntegerSyntax)
+ write((SetOfIntegerSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof EnumSyntax)
+ write((EnumSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof URISyntax)
+ write((URISyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof CharsetSyntax)
+ write((CharsetSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof NaturalLanguageSyntax)
+ write((NaturalLanguageSyntax) attributeArray[i]);
+ else if (attributeArray[i] instanceof RequestedAttributes)
+ write((RequestedAttributes) attributeArray[i]);
+ else
+ throw new IppException("Unknown syntax type");
+ }
+ }
+
+ }
+
+ /**
+ * Logger for tracing - enable by passing
+ * -Dgnu.classpath.debug.components=ipp to the vm.
+ */
+ static final Logger logger = SystemLogger.SYSTEM;
+
+ /**
+ * The request id counter simply counts up
+ * to give unique request ids per JVM instance.
+ */
+ private static int requestIdCounter = 1;
+
+ /** The IPP version defaults to 1.1 */
+ private static final short VERSION = 0x0101;
+
+ /** Signals if the request is already on its way */
+ private boolean alreadySent = false;
+
+ /** The operation type of this request. */
+ private short operation_id;
+
+ /**
+ * The request id of this request. This is
+ * assigned automatically by the constructor.
+ */
+ private final int request_id;
+
+ private AttributeSet operationAttributes;
+
+ private AttributeSet printerAttributes;
+
+ private AttributeSet jobAttributes;
+
+ private Object data;
+
+ private URI requestUri;
+
+ /** The underlying connection - IPP is http based */
+ private HttpURLConnection connection;
+
+ /**
+ * Creates an IPPRequest instance.
+ *
+ * @param uri the URI of the request
+ * @param user the user if any
+ * @param password the password of the supplied user
+ */
+ public IppRequest(URI uri, String user, String password)
+ {
+ request_id = incrementRequestIdCounter();
+ requestUri = uri;
+
+ try
+ {
+ URL url = new URL("http",
+ user == null
+ ? uri.getHost() : user + ":"
+ + password + "@" + uri.getHost(),
+ uri.getPort(), uri.getPath());
+
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setDoOutput(true);
+
+ connection.setRequestProperty("Content-type", "application/ipp");
+ connection.setRequestProperty("Accept", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
+ }
+ catch (IOException e)
+ {
+ // MalformedURLException - uri is already checked
+ // ProtocolException - POST is correct method type
+ // IOException -HTTPURLConnection constructor actually
+ // does never throw this exception.
+ logger.log(Component.IPP, "Unexpected IOException", e);
+ }
+
+ logger.log(Component.IPP, "[IppConnection] Host: " + uri.getHost()
+ + " Port: " + uri.getPort() + " Path: "
+ + uri.getPath());
+ }
+
+ /**
+ * Synchronized method to be called by the constructor
+ * to assign a unique request id to this request.
+ *
+ * @return The unique request id.
+ */
+ private synchronized int incrementRequestIdCounter()
+ {
+ return IppRequest.requestIdCounter++;
+ }
+
+ /**
+ * Returns the id of this request.
+ *
+ * @return The request ID.
+ */
+ public int getRequestID()
+ {
+ return request_id;
+ }
+
+ /**
+ * Sets the data of the request. The data used in this
+ * request will be the one of the supplied inputstream
+ * instead of the alternative byte array possibility.
+ *
+ * @param stream the input stream to use for the data.
+ */
+ public void setData(InputStream stream)
+ {
+ data = stream;
+ }
+
+ /**
+ * Sets the data of the request. The data used in this
+ * request will be the one of the supplied byte[]
+ * instead of the alternative input stream possibility.
+ *
+ * @param bytes the byte[] to use for the data.
+ */
+ public void setData(byte[] bytes)
+ {
+ data = bytes;
+ }
+
+ /**
+ * Sets the operation id for this request.
+ *
+ * @param id the operation id.
+ */
+ public void setOperationID(short id)
+ {
+ operation_id = id;
+ }
+
+ /**
+ * Adds the default values for the operation
+ * attributes "attributes-charset" and
+ * "attributes-natural-language"
+ */
+ public void setOperationAttributeDefaults()
+ {
+ if (operationAttributes == null)
+ operationAttributes = new HashAttributeSet();
+
+ operationAttributes.add(AttributesCharset.UTF8);
+ operationAttributes.add(AttributesNaturalLanguage.EN);
+ }
+
+ /**
+ * Add the job attribute of this request to the given
+ * attribute set.
+ *
+ * @param attribute the job attribute.
+ */
+ public void addJobAttribute(Attribute attribute)
+ {
+ if (jobAttributes == null)
+ jobAttributes = new HashAttributeSet();
+
+ jobAttributes.add(attribute);
+ }
+
+ /**
+ * Sets the printer attribute of this request to the given
+ * attribute set.
+ *
+ * @param attribute the printer attribute.
+ */
+ public void addPrinterAttributes(Attribute attribute)
+ {
+ if (printerAttributes == null)
+ printerAttributes = new HashAttributeSet();
+
+ printerAttributes.add(attribute);
+ }
+
+ /**
+ * Adds the given attribute to the operation attributes set.
+ *
+ * @param attribute the operation attribute to add.
+ */
+ public void addOperationAttribute(Attribute attribute)
+ {
+ if (operationAttributes == null)
+ operationAttributes = new HashAttributeSet();
+
+ operationAttributes.add(attribute);
+ }
+
+ /**
+ * Filters from the given attribute set the job operation out
+ * and adds them to the operation attributes set.
+ *
+ * @param set the attributes to filter, may not be <code>null</code>.
+ */
+ public void addAndFilterJobOperationAttributes(AttributeSet set)
+ {
+ if (operationAttributes == null)
+ operationAttributes = new HashAttributeSet();
+
+ // document-natural-language - not defined in JPS attributes
+ // document-format - specified outside, special treatment
+ Attribute[] tmp = set.toArray();
+ for (int i = 0; i < tmp.length; i++)
+ {
+ if (tmp[i].getCategory().equals(JobName.class)
+ || tmp[i].getCategory().equals(Fidelity.class)
+ || tmp[i].getCategory().equals(JobImpressions.class)
+ || tmp[i].getCategory().equals(JobKOctets.class)
+ || tmp[i].getCategory().equals(JobMediaSheets.class)
+ || tmp[i].getCategory().equals(Compression.class)
+ || tmp[i].getCategory().equals(DocumentName.class)
+ || tmp[i].getCategory().equals(RequestingUserName.class))
+
+ operationAttributes.add(tmp[i]);
+ }
+ }
+
+ /**
+ * Filters from the given attribute set the job template attributes
+ * out and adds them to the job attributes set.
+ *
+ * @param set the attributes to filter, may not be <code>null</code>.
+ */
+ public void addAndFilterJobTemplateAttributes(AttributeSet set)
+ {
+ if (jobAttributes == null)
+ jobAttributes = new HashAttributeSet();
+
+ // document-natural-language - not defined in JPS attributes
+ // document-format - specified outside, special treatment
+ Attribute[] tmp = set.toArray();
+ for (int i = 0; i < tmp.length; i++)
+ {
+ if (tmp[i].getCategory().equals(JobPriority.class)
+ || tmp[i].getCategory().equals(JobHoldUntil.class)
+ || tmp[i].getCategory().equals(JobSheets.class)
+ || tmp[i].getCategory().equals(MultipleDocumentHandling.class)
+ || tmp[i].getCategory().equals(Copies.class)
+ || tmp[i].getCategory().equals(Finishings.class)
+ || tmp[i].getCategory().equals(PageRanges.class)
+ || tmp[i].getCategory().equals(NumberUp.class)
+ || tmp[i].getCategory().equals(OrientationRequested.class)
+ || tmp[i].getCategory().equals(Media.class)
+ || tmp[i].getCategory().equals(PrinterResolution.class)
+ || tmp[i].getCategory().equals(PrintQuality.class)
+ || tmp[i].getCategory().equals(SheetCollate.class)
+ || tmp[i].getCategory().equals(Sides.class))
+
+ jobAttributes.add(tmp[i]);
+ }
+ }
+
+ /**
+ * Does some validation of the supplied parameters and then
+ * sends the request to the ipp server or service.
+ *
+ * @return The response if any.
+ *
+ * @throws IllegalStateException if request is already sent
+ * @throws IppException if connection or request failed.
+ * @throws IOException if writing of the header, attributes or footer fails.
+ */
+ public IppResponse send() throws IppException, IOException
+ {
+ if (alreadySent)
+ throw new IllegalStateException("Request is already sent");
+
+ alreadySent = true;
+
+ OutputStream stream = stream = connection.getOutputStream();
+ DataOutputStream out = new DataOutputStream(stream);
+
+ // the header 8 bytes long
+ out.writeShort(VERSION);
+ out.writeShort(operation_id);
+ out.writeInt(request_id);
+
+ logger.log(Component.IPP, "OperationID: " + Integer.toHexString(operation_id)
+ + " RequestID: " + request_id);
+
+ // Pass stuff the the attribute writer which knows how to
+ // write the attributes in correct order
+ logger.log(Component.IPP, "Operation Attributes");
+
+ RequestWriter writer = new RequestWriter(out);
+ writer.writeOperationAttributes(operationAttributes);
+
+ if (jobAttributes != null)
+ {
+ logger.log(Component.IPP, "Job Attributes");
+ out.write(IppDelimiterTag.JOB_ATTRIBUTES_TAG);
+ writer.writeAttributes(jobAttributes);
+ }
+ if (printerAttributes != null)
+ {
+ logger.log(Component.IPP, "Printer Attributes");
+ out.write(IppDelimiterTag.PRINTER_ATTRIBUTES_TAG);
+ writer.writeAttributes(printerAttributes);
+ }
+
+ // write the delimiter to the data
+ out.write(IppDelimiterTag.END_OF_ATTRIBUTES_TAG);
+
+ // check if data is byte[] or inputstream
+ if (data instanceof InputStream)
+ {
+ byte[] readbuf = new byte[2048];
+ int len = 0;
+ while( (len = ((InputStream) data).read(readbuf)) > 0)
+ out.write(readbuf, 0, len);
+ }
+ else if (data != null)
+ {
+ out.write((byte[]) data);
+ }
+
+ out.flush();
+ stream.flush();
+
+ int responseCode = responseCode = connection.getResponseCode();
+
+ if (responseCode == HttpURLConnection.HTTP_OK)
+ {
+ IppResponse response = new IppResponse(requestUri, operation_id);
+ response.setResponseData(connection.getInputStream());
+ return response;
+ }
+
+ logger.log(Component.IPP, "HTTP-Statuscode: " + responseCode);
+
+ throw new IppException("Request failed got HTTP status code "
+ + responseCode);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppResponse.java b/libjava/classpath/gnu/javax/print/ipp/IppResponse.java
new file mode 100644
index 00000000000..21784d0f076
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppResponse.java
@@ -0,0 +1,778 @@
+/* IppResponse.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import gnu.classpath.debug.Component;
+import gnu.classpath.debug.SystemLogger;
+import gnu.javax.print.ipp.attribute.UnknownAttribute;
+import gnu.javax.print.ipp.attribute.defaults.DocumentFormatDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrinterResolutionDefault;
+import gnu.javax.print.ipp.attribute.job.AttributesCharset;
+import gnu.javax.print.ipp.attribute.job.AttributesNaturalLanguage;
+import gnu.javax.print.ipp.attribute.job.JobMoreInfo;
+import gnu.javax.print.ipp.attribute.job.JobPrinterUri;
+import gnu.javax.print.ipp.attribute.job.JobUri;
+import gnu.javax.print.ipp.attribute.printer.CharsetConfigured;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+import gnu.javax.print.ipp.attribute.printer.NaturalLanguageConfigured;
+import gnu.javax.print.ipp.attribute.printer.PrinterCurrentTime;
+import gnu.javax.print.ipp.attribute.printer.PrinterDriverInstaller;
+import gnu.javax.print.ipp.attribute.supported.CharsetSupported;
+import gnu.javax.print.ipp.attribute.supported.DocumentFormatSupported;
+import gnu.javax.print.ipp.attribute.supported.GeneratedNaturalLanguageSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterUriSupported;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.DateTimeAtCompleted;
+import javax.print.attribute.standard.DateTimeAtCreation;
+import javax.print.attribute.standard.DateTimeAtProcessing;
+import javax.print.attribute.standard.JobImpressionsSupported;
+import javax.print.attribute.standard.JobKOctetsSupported;
+import javax.print.attribute.standard.JobMediaSheetsSupported;
+import javax.print.attribute.standard.JobStateReason;
+import javax.print.attribute.standard.JobStateReasons;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.PrinterMoreInfo;
+import javax.print.attribute.standard.PrinterMoreInfoManufacturer;
+import javax.print.attribute.standard.PrinterStateReason;
+import javax.print.attribute.standard.PrinterStateReasons;
+import javax.print.attribute.standard.Severity;
+
+/**
+ * <code>IppResponse</code> models a response received from an IPP
+ * compatible server as described in RFC 2910 IPP 1.1 Encoding and Transport.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class IppResponse
+{
+
+ /**
+ * <code>ResponseReader</code> is responsible for parsing an IPP 1.1
+ * response stream. It provides access to the attribute groups after parsing
+ * via getter methods.
+ * <p>
+ * The enconding of a response is structured as follows (for an official
+ * description please have a look at the RFC document mentioned above):
+ * <ul>
+ * <li>version-number - 2 bytes - required</li>
+ * <li>status-code - 2 bytes - required</li>
+ * <li>request-id - 4 bytes - required</li>
+ * <li>attribute-group - n bytes - 0 or more</li>
+ * <li>end-of-attributes-tag - 1 byte - required</li>
+ * <li>data - q bytes - optional</li>
+ * </ul>
+ * </p><p>
+ * Where each attribute-group (if any) is encoded as follows:
+ * <ul>
+ * <li>begin-attribute-group-tag - 1 byte</li>
+ * <li>attribute - p bytes - 0 or more</li>
+ * </ul>
+ * </p><p>
+ * Encoding of attributes:
+ * <ul>
+ * <li>attribute-with-one-value - q bytes</li>
+ * <li>additional-value - r bytes - 0 or more</li>
+ * </ul>
+ * </p><p>
+ * Encoding of attribute-with-one-value:
+ * <ul>
+ * <li>value-tag - 1 byte</li>
+ * <li>name-length (value is u) - 2 bytes</li>
+ * <li>name - u bytes</li>
+ * <li>value-length (value is v) - 2 bytes</li>
+ * <li>value - v bytes</li>
+ * </ul>
+ * </p><p>
+ * Encoding of additional value:
+ * <ul>
+ * <li>value-tag - 1 byte</li>
+ * <li>name-length (value is 0x0000) - 2 bytes</li>
+ * <li>value-length (value is w) - 2 bytes</li>
+ * <li>value - w bytes</li>
+ * </ul>
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+ class ResponseReader
+ {
+ /** The IPP version defaults to 1.1 */
+ private static final short VERSION = 0x0101;
+
+ /**
+ * Parses the inputstream containing the response of the IPP request.
+ * @param input the inputstream
+ * @throws IppException if unexpected exceptions occur.
+ * @throws IOException if IO problems with the underlying inputstream occur.
+ */
+ public void parseResponse(InputStream input)
+ throws IppException, IOException
+ {
+ DataInputStream stream = new DataInputStream(input);
+
+ short version = stream.readShort();
+ status_code = stream.readShort();
+ request_id = stream.readInt();
+
+ if (VERSION != version)
+ throw new IppException("Version mismatch - "
+ + "implementation does not support other versions than IPP 1.1");
+
+ logger.log(Component.IPP, "Statuscode: "
+ + Integer.toHexString(status_code) + " Request-ID: " + request_id);
+
+ byte tag = 0;
+ boolean proceed = true;
+ HashMap tmp;
+ // iterate over attribute-groups until end-of-attributes-tag is found
+ while (proceed)
+ {
+ if (tag == 0) // only at start time
+ tag = stream.readByte();
+
+ logger.log(Component.IPP, "DelimiterTag: " + Integer.toHexString(tag));
+
+ // check if end of attributes
+ switch (tag)
+ {
+ case IppDelimiterTag.END_OF_ATTRIBUTES_TAG:
+ proceed = false;
+ break;
+ case IppDelimiterTag.OPERATION_ATTRIBUTES_TAG:
+ tmp = new HashMap();
+ tag = parseAttributes(tmp, stream);
+ operationAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.JOB_ATTRIBUTES_TAG:
+ tmp = new HashMap();
+ tag = parseAttributes(tmp, stream);
+ jobAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.PRINTER_ATTRIBUTES_TAG:
+ tmp = new HashMap();
+ tag = parseAttributes(tmp, stream);
+ printerAttributes.add(tmp);
+ break;
+ case IppDelimiterTag.UNSUPPORTED_ATTRIBUTES_TAG:
+ System.out.println("Called");
+ tmp = new HashMap();
+ tag = parseAttributes(tmp, stream);
+ unsupportedAttributes.add(tmp);
+ break;
+ default:
+ throw new IppException("Unknown tag with value "
+ + Integer.toHexString(tag) + " occured.");
+ }
+ }
+
+ // if there are more bytes that has to be data.
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ byte[] readbuf = new byte[2048];
+ int len = 0;
+
+ while ((len = stream.read(readbuf)) > 0)
+ byteStream.write(readbuf, 0, len);
+
+ byteStream.flush();
+ data = byteStream.toByteArray();
+ }
+
+ /**
+ * The actual parsing of the attributes and further putting into the
+ * provided group maps.
+ * @param attributes the provided attribute group map.
+ * @param stream the provided stream to read from.
+ * @return The last read tag byte (normally a DelimiterTag)
+ * @throws IppException if unexpected exceptions occur.
+ * @throws IOException if IO problems with the underlying inputstream occur.
+ */
+ private byte parseAttributes(Map attributes, DataInputStream stream)
+ throws IppException, IOException
+ {
+ Attribute lastAttribute = null;
+ Attribute attribute = null;
+
+ // declaration of variables
+ short nameLength;
+ String name;
+ short valueLength;
+ byte[] value;
+
+ // tmp variables for parsing
+ // declared here so no name duplication occurs
+ URI uri;
+ String str;
+
+ while (true)
+ {
+ byte tag = stream.readByte();
+
+ if (IppDelimiterTag.isDelimiterTag(tag))
+ return tag;
+
+ // it must be a value tag now
+ // so we have either a attribute-with-one-value
+ // or (if setOf is possible) an additional-value
+
+ // (1) Length of the name
+ nameLength = stream.readShort();
+
+ // (2) The name itself
+ // may be an additional-value
+ if (nameLength == 0x0000)
+ name = lastAttribute.getName();
+ else
+ {
+ byte[] nameBytes = new byte[nameLength];
+ stream.read(nameBytes);
+ name = new String(nameBytes);
+ }
+
+ // (3) Length of the value
+ valueLength = stream.readShort();
+
+ // (4) The value itself
+ value = new byte[valueLength];
+ stream.read(value);
+
+ // the value itself
+ switch (tag)
+ {
+ // out-of-band values
+ case IppValueTag.UNSUPPORTED:
+ case IppValueTag.UNKNOWN:
+ case IppValueTag.NO_VALUE:
+ // TODO implement out-of-band handling
+ // We currently throw an exception to see when it occurs - not yet :-)
+ throw new IppException(
+ "Unexpected name value for out-of-band value tag");
+ case IppValueTag.INTEGER:
+ int intValue = IppUtilities.convertToInt(value);
+ attribute = IppUtilities.getIntegerAttribute(name, intValue);
+
+ break;
+ case IppValueTag.BOOLEAN:
+ // JPS API models boolean syntax type as enums
+ // 0x01 = true, 0x00 = false - all are enums
+ attribute = IppUtilities.getEnumAttribute(name, new Integer(value[0]));
+
+ break;
+ case IppValueTag.ENUM:
+ int intVal = IppUtilities.convertToInt(value);
+ attribute = IppUtilities.getEnumAttribute(name, new Integer(intVal));
+
+ break;
+ case IppValueTag.OCTECTSTRING_UNSPECIFIED:
+ // none exists according to spec
+ // so lets report as exception to see when it occurs
+ throw new IppException("Unspecified octet string occured.");
+
+ case IppValueTag.DATETIME:
+ Date date = parseDate(value);
+ if (name.equals("printer-current-time"))
+ attribute = new PrinterCurrentTime(date);
+ else if (name.equals("date-time-at-creation"))
+ attribute = new DateTimeAtCreation(date);
+ else if (name.equals("date-time-at-processing"))
+ attribute = new DateTimeAtProcessing(date);
+ else if (name.equals("date-time-at-completed"))
+ attribute = new DateTimeAtCompleted(date);
+
+ break;
+ case IppValueTag.RESOLUTION:
+ int crossFeed = IppUtilities.convertToInt(value[0], value[1], value[2], value[3]);
+ int feed = IppUtilities.convertToInt(value[4], value[5], value[6], value[7]);
+ int units = value[8];
+
+ if (name.equals("printer-resolution-default"))
+ attribute = new PrinterResolutionDefault(crossFeed, feed, units);
+ else if (name.equals("printer-resolution-supported")) // may be here also
+ attribute = new PrinterResolutionSupported(crossFeed, feed, units);
+
+ break;
+ case IppValueTag.RANGEOFINTEGER:
+ int lower = IppUtilities.convertToInt(value[0], value[1], value[2], value[3]);
+ int upper = IppUtilities.convertToInt(value[4], value[5], value[6], value[7]);
+
+ if (name.equals("copies-supported"))
+ attribute = new CopiesSupported(lower, upper);
+ else if (name.equals("number-up-supported"))
+ attribute = new NumberUpSupported(lower, upper);
+ else if (name.equals("job-k-octets-supported"))
+ attribute = new JobKOctetsSupported(lower, upper);
+ else if (name.equals("job-impressions-supported"))
+ attribute = new JobImpressionsSupported(lower, upper);
+ else if (name.equals("job-media-sheets-supported"))
+ attribute = new JobMediaSheetsSupported(lower, upper);
+
+ break;
+ case IppValueTag.TEXT_WITH_LANGUAGE:
+ case IppValueTag.TEXT_WITHOUT_LANGUAGE:
+ case IppValueTag.NAME_WITH_LANGUAGE:
+ case IppValueTag.NAME_WITHOUT_LANGUAGE:
+ attribute = IppUtilities.getTextAttribute(name, tag, value);
+
+ break;
+ case IppValueTag.KEYWORD:
+ str = new String(value);
+ if (name.equals("job-hold-until-supported")) // may also be name type
+ attribute = new JobHoldUntilSupported(str, null);
+ else if (name.equals("job-hold-until-default"))
+ attribute = new JobHoldUntilDefault(str, null);
+ else if (name.equals("media-supported"))
+ attribute = new MediaSupported(str, null);
+ else if (name.equals("media-default"))
+ attribute = new MediaDefault(str, null);
+ else if (name.equals("job-sheets-default"))
+ attribute = new JobSheetsDefault(str, null);
+ else if (name.equals("job-sheets-supported"))
+ attribute = new JobSheetsSupported(str, null);
+ else if (name.equals("job-state-reasons")) // setOf
+ attribute = parseJobStateReasons(value, lastAttribute);
+ else if (name.equals("printer-state-reasons")) // setOf
+ attribute = parsePrinterStateReasons(value, lastAttribute);
+ else
+ attribute = IppUtilities.getEnumAttribute(name, str);
+
+ // all other stuff is either an enum or needs to be mapped to an
+ // UnknownAttribute instance. Enums catched here are:
+ // ipp-versions-supported, pdl-override-supported, compression-supported
+ // uri-authentication-supported, uri-security-supported, sides-supported
+ // sides-default, multiple-document-handling-supported, multiple-document-handling-default
+
+ break;
+ case IppValueTag.URI:
+ try
+ {
+ uri = new URI(new String(value));
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IppException("Wrong URI syntax encountered.", e);
+ }
+
+ if (name.equals("job-uri"))
+ attribute = new JobUri(uri);
+ else if (name.equals("job-printer-uri"))
+ attribute = new JobPrinterUri(uri);
+ else if (name.equals("job-more-info"))
+ attribute = new JobMoreInfo(uri);
+ else if (name.equals("printer-uri-supported")) // setOf
+ attribute = new PrinterUriSupported(uri);
+ else if (name.equals("printer-more-info"))
+ attribute = new PrinterMoreInfo(uri);
+ else if (name.equals("printer-driver-installer"))
+ attribute = new PrinterDriverInstaller(uri);
+ else if (name.equals("printer-more-info-manufacturer"))
+ attribute = new PrinterMoreInfoManufacturer(uri);
+
+ break;
+ case IppValueTag.URI_SCHEME:
+ // only one uri-scheme exists - and its an enum
+ if (name.equals("reference-uri-schemes-supported"))
+ attribute = IppUtilities.getEnumAttribute(name, new String(value));
+
+ break;
+ case IppValueTag.CHARSET:
+ str = new String(value);
+ if (name.equals("attributes-charset"))
+ attribute = new AttributesCharset(str);
+ else if (name.equals("charset-configured"))
+ attribute = new CharsetConfigured(str);
+ else if (name.equals("charset-supported")) // setOf
+ attribute = new CharsetSupported(str);
+
+ break;
+ case IppValueTag.NATURAL_LANGUAGE:
+ str = new String(value);
+ if (name.equals("attributes-natural-language"))
+ attribute = new AttributesNaturalLanguage(str);
+ else if (name.equals("natural-language-configured"))
+ attribute = new NaturalLanguageConfigured(str);
+ else if (name.equals("generated-natural-language-supported")) // setOf
+ attribute = new GeneratedNaturalLanguageSupported(str);
+
+ break;
+ case IppValueTag.MIME_MEDIA_TYPE:
+ str = new String(value);
+ if (name.equals("document-format-default"))
+ attribute = new DocumentFormatDefault(str, null);
+ else if (name.equals("document-format-supported")) // setOf
+ attribute = new DocumentFormatSupported(str, null);
+ else if (name.equals("document-format")) // setOf
+ attribute = new DocumentFormat(str, null);
+
+ break;
+ default:
+ throw new IppException("Unknown tag with value "
+ + Integer.toHexString(tag) + " found.");
+ }
+
+ if (attribute == null)
+ attribute = new UnknownAttribute(tag, name, value);
+
+ addAttribute(attributes, attribute);
+ lastAttribute = attribute;
+
+ logger.log(Component.IPP, "Attribute: " + name
+ + " Value: " + attribute.toString());
+ }
+ }
+
+ /**
+ * Adds a new attribute to the given attribute group. If this is the fist
+ * occurence of this attribute category a new set is created and associated
+ * with its category as key.
+ * @param attributeGroup
+ * the attribute group
+ * @param attribute
+ * the attribute to add
+ */
+ private void addAttribute(Map attributeGroup, Attribute attribute)
+ {
+ Class clazz = attribute.getCategory();
+ Set attributeValues = (Set) attributeGroup.get(clazz);
+
+ if (attributeValues == null) // first attribute of this category
+ {
+ attributeValues = new HashSet();
+ attributeGroup.put(clazz, attributeValues);
+ }
+
+ attributeValues.add(attribute);
+ }
+
+ /**
+ * Parses a name with or without language attribute value from the byte[]
+ * and returns the result as an object[].
+ * @param value the byte[]
+ * @param lastAttr the last attribute
+ * @return The attribute.
+ */
+ private PrinterStateReasons parsePrinterStateReasons(byte[] value, Attribute lastAttr)
+ {
+ String str = new String(value);
+ PrinterStateReasons attribute;
+
+ if (lastAttr instanceof PrinterStateReasons)
+ attribute = (PrinterStateReasons) lastAttr;
+ else
+ attribute = new PrinterStateReasons();
+
+ // special case indicating no reasons
+ if (str.equals("none"))
+ return attribute;
+
+ Severity severity = null;
+ PrinterStateReason reason = null;
+
+ if (str.endsWith(Severity.WARNING.toString()))
+ severity = Severity.WARNING;
+ else if (str.endsWith(Severity.REPORT.toString()))
+ severity = Severity.REPORT;
+ else if (str.endsWith(Severity.ERROR.toString()))
+ severity = Severity.ERROR;
+
+ if (severity != null)
+ str = str.substring(0, str.lastIndexOf('-'));
+ else // we must associate a severity
+ severity = Severity.REPORT;
+
+ reason = (PrinterStateReason)
+ IppUtilities.getEnumAttribute("printer-state-reason", str);
+
+ attribute.put(reason , severity);
+ return attribute;
+ }
+
+ /**
+ * Parses a name with or without language attribute value from the byte[]
+ * and returns the result as an object[].
+ * @param value the byte[]
+ * @param lastAttr the last attribute
+ * @return The attribute.
+ */
+ private JobStateReasons parseJobStateReasons(byte[] value, Attribute lastAttr)
+ {
+ String str = new String(value);
+ JobStateReasons attribute;
+
+ if (lastAttr instanceof JobStateReasons)
+ attribute = (JobStateReasons) lastAttr;
+ else
+ attribute = new JobStateReasons();
+
+ // special case indicating no reasons
+ if (str.equals("none"))
+ return attribute;
+
+ JobStateReason reason = (JobStateReason)
+ IppUtilities.getEnumAttribute("job-state-reason", str);
+
+ attribute.add(reason);
+ return attribute;
+ }
+
+ /**
+ * Parses a DateTime syntax attribute and returns the constructed Date
+ * object.
+ * <p>
+ * The syntax value is defined as 11 octets follwing the DateAndTime format
+ * of RFC 1903:
+ * <ul>
+ * <li>field | octets | contents | range</li>
+ * <li>1 | 1-2 | year | 0..65536</li>
+ * <li>2 | 3 | month | 1..12</li>
+ * <li>3 | 4 | day | 1..31</li>
+ * <li>4 | 5 | hour | 0..23</li>
+ * <li>5 | 6 | minutes | 0..59</li>
+ * <li>6 | 7 | seconds | 0..60 (use 60 for leap-second)</li>
+ * <li>7 | 8 | deci-seconds | 0..9</li>
+ * <li>8 | 9 | direction from UTC | '+' / '-'</li>
+ * <li>9 | 10 | hours from UTC | 0..11</li>
+ * <li>10 | 11 | minutes from UTC | 0..59</li>
+ * </ul>
+ * </p>
+ *
+ * @param value the byte[]
+ * @return The date object.
+ */
+ private Date parseDate(byte[] value)
+ {
+ short year = IppUtilities.convertToShort(value[0], value[1]);
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, value[2]);
+ cal.set(Calendar.DAY_OF_MONTH, value[3]);
+ cal.set(Calendar.HOUR_OF_DAY, value[4]);
+ cal.set(Calendar.MINUTE, value[5]);
+ cal.set(Calendar.SECOND, value[6]);
+ cal.set(Calendar.MILLISECOND, value[7] * 100); // deci-seconds
+
+ // offset from timezone
+ int offsetMilli = value[9] * 3600000; // hours to millis
+ offsetMilli = offsetMilli + value[10] * 60000; // minutes to millis
+
+ if (((char) value[8]) == '-')
+ offsetMilli = offsetMilli * (-1);
+
+ cal.set(Calendar.ZONE_OFFSET, offsetMilli);
+ return cal.getTime();
+ }
+ }
+
+ /**
+ * Logger for tracing - enable by passing
+ * -Dgnu.classpath.debug.components=ipp to the vm.
+ */
+ static final Logger logger = SystemLogger.SYSTEM;
+
+ URI uri;
+ short operation_id;
+ short status_code;
+ int request_id;
+
+ List operationAttributes;
+ List printerAttributes;
+ List jobAttributes;
+ List unsupportedAttributes;
+
+ byte[] data;
+
+ /**
+ * Creates an <code>IppResponse</code> instance.
+ *
+ * @param uri the uri the request was directy to.
+ * @param operation_id the operation id of the request.
+ */
+ public IppResponse(URI uri, short operation_id)
+ {
+ this.uri = uri;
+ this.operation_id = operation_id;
+ operationAttributes = new ArrayList();
+ jobAttributes = new ArrayList();
+ printerAttributes = new ArrayList();
+ unsupportedAttributes = new ArrayList();
+ }
+
+ /**
+ * Sets the data received from the request sent.
+ *
+ * @param input the input stream received.
+ * @throws IppException if parsing fails.
+ */
+ protected void setResponseData(InputStream input) throws IppException
+ {
+ ResponseReader reader = new ResponseReader();
+
+ try
+ {
+ reader.parseResponse(input);
+ }
+ catch (IOException e)
+ {
+ throw new IppException(
+ "Exception during response parsing caused by IOException", e);
+ }
+ }
+
+ /**
+ * Returns the uri of the original request.
+ * @return The URI of the request.
+ */
+ public URI getURI()
+ {
+ return uri;
+ }
+
+ /**
+ * Returns the operation id of the original request.
+ * @return The operation id of the request.
+ */
+ public int getOperationID()
+ {
+ return operation_id;
+ }
+
+ /**
+ * Returns the set of job attributes group maps.
+ * There may occur more than one group of type job attribute in a response
+ * because of e.g. multiple job or print service informations requested.
+ *
+ * @return The list of job attribute grou maps.
+ */
+ public List getJobAttributes()
+ {
+ return jobAttributes;
+ }
+
+ /**
+ * Returns the set of operation attributes group maps.
+ * There may occur more than one group of type job attribute in a response
+ * because of e.g. multiple job or print service informations requested.
+ *
+ * @return The list of operation attribute grou maps.
+ */
+ public List getOperationAttributes()
+ {
+ return operationAttributes;
+ }
+
+ /**
+ * Returns the set of printer attributes group maps.
+ * There may occur more than one group of type job attribute in a response
+ * because of e.g. multiple job or print service informations requested.
+ *
+ * @return The list of printer attribute grou maps.
+ */
+ public List getPrinterAttributes()
+ {
+ return printerAttributes;
+ }
+
+ /**
+ * Returns the ID of the initial request.
+ *
+ * @return The request ID.
+ */
+ public int getRequestID()
+ {
+ return request_id;
+ }
+
+ /**
+ * Returns the status code of the response.
+ * Defined in {@link IppStatusCode}.
+ *
+ * @return The status code.
+ */
+ public short getStatusCode()
+ {
+ return status_code;
+ }
+
+ /**
+ * Returns the set of unsupported attributes group maps.
+ * There may occur more than one group of type job attribute in a response
+ * because of e.g. multiple job or print service informations requested.
+ *
+ * @return The list of unsupported attribute grou maps.
+ */
+ public List getUnsupportedAttributes()
+ {
+ return unsupportedAttributes;
+ }
+
+ /**
+ * Returns the data of the response.
+ *
+ * @return The data as byte[].
+ */
+ public byte[] getData()
+ {
+ return data;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java
new file mode 100644
index 00000000000..d2cb8391f45
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppStatusCode.java
@@ -0,0 +1,185 @@
+/* IppStatusCode.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+/**
+ * IPP Status codes as described in RFC 2911 APPENDIX B
+ * (Status Codes and Suggested Status Code Messages)
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class IppStatusCode
+{
+ /**
+ * Indicates a successful request with no attributes being
+ * ignored or substituted.
+ */
+ public static final int SUCCESSFUL_OK = 0x0000;
+
+ /**
+ * Indicates a successful request, however some of the supplied
+ * attributes are ignored or substituted.
+ */
+ public static final int SUCCESSFUL_OK_IGNORED_OR_SUBSTITUED_ATTRIBUTES = 0x0001;
+
+ /**
+ * Indicates a successful request, however some of the supplied
+ * attributes conflicted and therefore were ignored or substituted.
+ */
+ public static final int SUCCESSFUL_OK_CONFLICTING_ATTRIBUTES = 0x0002;
+
+ // Client Error Status Codes
+ // Indicates that the client has done something wrong in its
+ // requests send to the IPP server object
+
+ /** Indicates a bad request e.g. malformed syntax. */
+ public static final int CLIENT_ERROR_BAD_REQUEST = 0x0400;
+
+ /** Indicates that the client is forbidden to access the server. */
+ public static final int CLIENT_ERROR_FORBIDDEN = 0x0401;
+
+ /** Indicates that the client needs to authenticate. */
+ public static final int CLIENT_ERROR_NOT_AUTHENTICATED = 0x0402;
+
+ /** Indicates that the client is not authorized. */
+ public static final int CLIENT_ERROR_NOT_AUTHORIZED = 0x0403;
+
+ /**
+ * Indicates a request which is not possible to process.
+ * For example if the request is directed at a job already finished.
+ */
+ public static final int CLIENT_ERROR_NOT_POSSIBLE = 0x0404;
+
+ /** Indicates that the client got a timeout for additional action. */
+ public static final int CLIENT_ERROR_TIMEOUT = 0x0405;
+
+ /** Indicates that nothing was found for the request uri. */
+ public static final int CLIENT_ERROR_NOT_FOUND = 0x0406;
+
+ /** Indicates that the requested object is gone. */
+ public static final int CLIENT_ERROR_GONE = 0x0407;
+
+ /** Indicates that the request entities are too long. */
+ public static final int CLIENT_ERROR_REQUEST_ENTITY_TOO_LONG = 0x0408;
+
+ /** Indicates that a request value is too long. */
+ public static final int CLIENT_ERROR_REQUEST_VALUE_TOO_LONG = 0x0409;
+
+ /** Indicates that the supplied document format is not supported. */
+ public static final int CLIENT_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED = 0x040A;
+
+ /**
+ * Indicates that the supplied attributes or values of attributes are not
+ * supported by the printer object. Returning this code depends on the
+ * given "ipp-attribute-fidelity" operation attribute value.
+ */
+ public static final int CLIENT_ERROR_ATTRIBUTES_OR_VALUES_NOT_SUPPORTED
+ = 0x040B;
+
+ /**
+ * Indicates the the URI scheme in a supplied print-uri or send-uri attribute
+ * is not supported.
+ */
+ public static final int CLIENT_ERROR_URI_SCHEME_NOT_SUPPORTED = 0x040C;
+
+ /** Indicates that a supplied attributes-charset is not supported. */
+ public static final int CLIENT_ERROR_CHARSET_NOT_SUPPORTED = 0x040D;
+
+ /** Indicates that conflicting attributes are in the request. */
+ public static final int CLIENT_ERROR_CONFLICTING_ATTRIBUTES = 0x040E;
+
+ /** Indicates that the specified algorithm is not supported. */
+ public static final int CLIENT_ERROR_COMPRESSION_NOT_SUPPORTED = 0x040F;
+
+ /**
+ * Indicates that the document cannot be decompressed with the client
+ * compression algorithm specified by the client.
+ */
+ public static final int CLIENT_ERROR_COMPRESSION_ERROR = 0x0410;
+
+ /** Indicates an error in the document format of the document. */
+ public static final int CLIENT_ERROR_DOCUMENT_FORMAT_ERROR = 0x0411;
+
+ /**
+ * Indicates that the document supplied via print-uri or send-uri cannot be
+ * accessed by the printer object.
+ */
+ public static final int CLIENT_ERROR_DOCUMENT_ACCESS_ERROR = 0x0412;
+
+
+ /** Indicates an internal server error. */
+ public static final int SERVER_ERROR_INTERNAL_ERROR = 0x0500;
+
+ /** Indicates that the server does not support the operation. */
+ public static final int SERVER_ERROR_OPERATION_NOT_SUPPORTED = 0x0501;
+
+ /** Indicates that the server' service is not available. */
+ public static final int SERVER_ERROR_SERVICE_UNAVAILABLE = 0x0502;
+
+ /** Indicates that the server does not support the IPP version. */
+ public static final int SERVER_ERROR_VERSION_NOT_SUPPORTED = 0x0503;
+
+ /** Indicates that the server has a device error e.g. paper jam. */
+ public static final int SERVER_ERROR_DEVICE_ERROR = 0x0504;
+
+ /** Indicates that the server has a temporary error. */
+ public static final int SERVER_ERROR_TEMPORARY_ERROR = 0x0505;
+
+ /** Indicates that the server is currently not accepting jobs. */
+ public static final int SERVER_ERROR_NOT_ACCEPTING_JOBS = 0x0506;
+
+ /**
+ * Indicates that the server is currently busy with processing.
+ * Requests may be tried later again.
+ */
+ public static final int SERVER_ERROR_BUSY = 0x0507;
+
+ /** Indicates that the server has canceled the job for various reasons. */
+ public static final int SERVER_ERROR_JOB_CANCELED = 0x0508;
+
+ /** Indicates that the server does not support multidocument jobs. */
+ public static final int SERVER_ERROR_MULTIPLE_DOCUMENT_JOBS_NOT_SUPPORTED
+ = 0x0509;
+
+ private IppStatusCode()
+ {
+ // not to be instantiated
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java b/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java
new file mode 100644
index 00000000000..3038998879c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppUtilities.java
@@ -0,0 +1,551 @@
+/* IppUtilities.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+import gnu.javax.print.ipp.attribute.DetailedStatusMessage;
+import gnu.javax.print.ipp.attribute.DocumentAccessError;
+import gnu.javax.print.ipp.attribute.StatusMessage;
+import gnu.javax.print.ipp.attribute.defaults.CopiesDefault;
+import gnu.javax.print.ipp.attribute.defaults.FinishingsDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobHoldUntilDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobPriorityDefault;
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+import gnu.javax.print.ipp.attribute.defaults.MediaDefault;
+import gnu.javax.print.ipp.attribute.defaults.MultipleDocumentHandlingDefault;
+import gnu.javax.print.ipp.attribute.defaults.NumberUpDefault;
+import gnu.javax.print.ipp.attribute.defaults.OrientationRequestedDefault;
+import gnu.javax.print.ipp.attribute.defaults.PrintQualityDefault;
+import gnu.javax.print.ipp.attribute.defaults.SidesDefault;
+import gnu.javax.print.ipp.attribute.job.JobDetailedStatusMessages;
+import gnu.javax.print.ipp.attribute.job.JobDocumentAccessErrors;
+import gnu.javax.print.ipp.attribute.job.JobId;
+import gnu.javax.print.ipp.attribute.job.JobStateMessage;
+import gnu.javax.print.ipp.attribute.printer.MultipleOperationTimeOut;
+import gnu.javax.print.ipp.attribute.printer.PrinterStateMessage;
+import gnu.javax.print.ipp.attribute.printer.PrinterUpTime;
+import gnu.javax.print.ipp.attribute.supported.CompressionSupported;
+import gnu.javax.print.ipp.attribute.supported.FinishingsSupported;
+import gnu.javax.print.ipp.attribute.supported.IppVersionsSupported;
+import gnu.javax.print.ipp.attribute.supported.JobHoldUntilSupported;
+import gnu.javax.print.ipp.attribute.supported.JobSheetsSupported;
+import gnu.javax.print.ipp.attribute.supported.MediaSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentHandlingSupported;
+import gnu.javax.print.ipp.attribute.supported.MultipleDocumentJobsSupported;
+import gnu.javax.print.ipp.attribute.supported.OperationsSupported;
+import gnu.javax.print.ipp.attribute.supported.OrientationRequestedSupported;
+import gnu.javax.print.ipp.attribute.supported.PageRangesSupported;
+import gnu.javax.print.ipp.attribute.supported.PrintQualitySupported;
+import gnu.javax.print.ipp.attribute.supported.PrinterResolutionSupported;
+import gnu.javax.print.ipp.attribute.supported.SidesSupported;
+import gnu.javax.print.ipp.attribute.supported.UriAuthenticationSupported;
+import gnu.javax.print.ipp.attribute.supported.UriSecuritySupported;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Chromaticity;
+import javax.print.attribute.standard.ColorSupported;
+import javax.print.attribute.standard.Compression;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.CopiesSupported;
+import javax.print.attribute.standard.Fidelity;
+import javax.print.attribute.standard.Finishings;
+import javax.print.attribute.standard.JobHoldUntil;
+import javax.print.attribute.standard.JobImpressionsCompleted;
+import javax.print.attribute.standard.JobKOctetsProcessed;
+import javax.print.attribute.standard.JobMediaSheetsCompleted;
+import javax.print.attribute.standard.JobMessageFromOperator;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.JobOriginatingUserName;
+import javax.print.attribute.standard.JobPriority;
+import javax.print.attribute.standard.JobPrioritySupported;
+import javax.print.attribute.standard.JobSheets;
+import javax.print.attribute.standard.JobState;
+import javax.print.attribute.standard.JobStateReason;
+import javax.print.attribute.standard.Media;
+import javax.print.attribute.standard.MediaSizeName;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+import javax.print.attribute.standard.NumberOfInterveningJobs;
+import javax.print.attribute.standard.NumberUp;
+import javax.print.attribute.standard.NumberUpSupported;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.OutputDeviceAssigned;
+import javax.print.attribute.standard.PDLOverrideSupported;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.PagesPerMinute;
+import javax.print.attribute.standard.PagesPerMinuteColor;
+import javax.print.attribute.standard.PresentationDirection;
+import javax.print.attribute.standard.PrintQuality;
+import javax.print.attribute.standard.PrinterInfo;
+import javax.print.attribute.standard.PrinterIsAcceptingJobs;
+import javax.print.attribute.standard.PrinterLocation;
+import javax.print.attribute.standard.PrinterMakeAndModel;
+import javax.print.attribute.standard.PrinterMessageFromOperator;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterResolution;
+import javax.print.attribute.standard.PrinterState;
+import javax.print.attribute.standard.PrinterStateReason;
+import javax.print.attribute.standard.QueuedJobCount;
+import javax.print.attribute.standard.ReferenceUriSchemesSupported;
+import javax.print.attribute.standard.Severity;
+import javax.print.attribute.standard.SheetCollate;
+import javax.print.attribute.standard.Sides;
+
+/**
+ * Collection of static utilities methods used in
+ * IPP response parsing and all over the place.
+ * <p>
+ * Also provides mapping from the attribute name values to
+ * the actual class object. Used to construct objects via reflection.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class IppUtilities
+{
+ // These are reused in the reflection code to not instantiate an array everytime
+ private static Object[] INTEGER_ATT_VALUE = new Object[1];
+ private static Class[] INTEGER_CLASS_ARRAY = new Class[] {int.class};
+ private static Object[] TEXT_ATT_VALUE = new Object[2];
+ private static Class[] TEXT_CLASS_ARRAY = new Class[] {String.class, Locale.class};
+
+ // The map -> Attribute name to Attribute class
+ private static HashMap classesByName = new HashMap();
+ // The map -> StandardAttribute class to SupportedAttribute category name
+ private static HashMap instanceByClass = new HashMap();
+
+ /**
+ * All the currently needed attributes
+ */
+ static
+ {
+ // enums
+ classesByName.put(JobState.ABORTED.getName(), JobState.class);
+ classesByName.put(Sides.DUPLEX.getName(), Sides.class);
+ classesByName.put(SheetCollate.COLLATED.getName(), SheetCollate.class);
+ classesByName.put(Severity.ERROR.getName(), Severity.class);
+ classesByName.put(JobSheets.NONE.getName(), JobSheets.class);
+ classesByName.put(Finishings.BIND.getName(), Finishings.class);
+ classesByName.put(Fidelity.FIDELITY_FALSE.getName(), Fidelity.class);
+ classesByName.put(Compression.GZIP.getName(), Compression.class);
+ classesByName.put(Chromaticity.COLOR.getName(), Chromaticity.class);
+ classesByName.put(PrintQuality.DRAFT.getName(), PrintQuality.class);
+ classesByName.put(PrinterState.IDLE.getName(), PrinterState.class);
+ classesByName.put(SidesDefault.ONE_SIDED.getName(), SidesDefault.class);
+ classesByName.put(ReferenceUriSchemesSupported.FILE.getName(),
+ ReferenceUriSchemesSupported.class);
+ classesByName.put(PrinterStateReason.DOOR_OPEN.getName(),
+ PrinterStateReason.class);
+ classesByName.put(PresentationDirection.TOLEFT_TOTOP.getName(),
+ PresentationDirection.class);
+ classesByName.put(PDLOverrideSupported.ATTEMPTED.getName(),
+ PDLOverrideSupported.class);
+ classesByName.put(OrientationRequested.PORTRAIT.getName(),
+ OrientationRequested.class);
+ classesByName.put(MultipleDocumentHandling.SINGLE_DOCUMENT.getName(),
+ MultipleDocumentHandling.class);
+ classesByName.put(JobStateReason.JOB_QUEUED.getName(),
+ JobStateReason.class);
+ classesByName.put(UriAuthenticationSupported.NONE.getName(),
+ UriAuthenticationSupported.class);
+ classesByName.put(OperationsSupported.GET_JOBS.getName(),
+ OperationsSupported.class);
+ classesByName.put(UriSecuritySupported.NONE.getName(),
+ UriSecuritySupported.class);
+ classesByName.put(FinishingsSupported.NONE.getName(),
+ FinishingsSupported.class);
+ classesByName.put(FinishingsDefault.NONE.getName(),
+ FinishingsDefault.class);
+ classesByName.put(IppVersionsSupported.V_1_0.getName(),
+ IppVersionsSupported.class);
+ classesByName.put(MultipleDocumentHandlingSupported.SINGLE_DOCUMENT.getName(),
+ MultipleDocumentHandlingSupported.class);
+ classesByName.put(MultipleDocumentHandlingDefault.SINGLE_DOCUMENT.getName(),
+ MultipleDocumentHandlingDefault.class);
+ classesByName.put(CompressionSupported.NONE.getName(),
+ CompressionSupported.class);
+ classesByName.put(OrientationRequestedSupported.PORTRAIT.getName(),
+ OrientationRequestedSupported.class);
+ classesByName.put(OrientationRequestedDefault.PORTRAIT.getName(),
+ OrientationRequestedDefault.class);
+ classesByName.put(SidesSupported.ONE_SIDED.getName(),
+ SidesSupported.class);
+ classesByName.put(PrintQualityDefault.DRAFT.getName(),
+ PrintQualityDefault.class);
+ classesByName.put(PrintQualitySupported.DRAFT.getName(),
+ PrintQualitySupported.class);
+ classesByName.put(ReferenceUriSchemesSupported.FTP.getName(),
+ ReferenceUriSchemesSupported.class);
+
+ // the boolean types
+ classesByName.put(ColorSupported.SUPPORTED.getName(), ColorSupported.class);
+ classesByName.put(PrinterIsAcceptingJobs.ACCEPTING_JOBS.getName(),
+ PrinterIsAcceptingJobs.class);
+ classesByName.put(MultipleDocumentJobsSupported.SUPPORTED.getName(),
+ MultipleDocumentJobsSupported.class);
+ classesByName.put(PageRangesSupported.SUPPORTED.getName(),
+ PageRangesSupported.class);
+
+ // TextSyntax derived attributes
+ classesByName.put("media-default", MediaDefault.class);
+ classesByName.put("media-supported", MediaSupported.class);
+ classesByName.put("media", MediaSizeName.class);
+ classesByName.put("printer-location", PrinterLocation.class);
+ classesByName.put("printer-info", PrinterInfo.class);
+ classesByName.put("printer-make-and-model", PrinterMakeAndModel.class);
+ classesByName.put("printer-state-message", PrinterStateMessage.class);
+ classesByName.put("job-state-message", JobStateMessage.class);
+ classesByName.put("job-sheets-default", JobSheetsDefault.class);
+ classesByName.put("job-sheets-supported", JobSheetsSupported.class);
+ classesByName.put("job-name", JobName.class);
+ classesByName.put("printer-name", PrinterName.class);
+ classesByName.put("status-message", StatusMessage.class);
+ classesByName.put("detailed-status-message", DetailedStatusMessage.class);
+ classesByName.put("document-access-error", DocumentAccessError.class);
+ classesByName.put("output-device-assigned", OutputDeviceAssigned.class);
+ classesByName.put("job-hold-until-default", JobHoldUntilDefault.class);
+ classesByName.put("job-originating-user-name",
+ JobOriginatingUserName.class);
+ classesByName.put("job-hold-until-supported",
+ JobHoldUntilSupported.class);
+ classesByName.put("job-message-from-operator",
+ JobMessageFromOperator.class);
+ classesByName.put("printer-message-from-operator",
+ PrinterMessageFromOperator.class);
+ classesByName.put("job-detailed-status-messages",
+ JobDetailedStatusMessages.class);
+ classesByName.put("job-document-access-errors",
+ JobDocumentAccessErrors.class);
+
+ // IntegerSyntax derived Attributes
+ classesByName.put("copies-default", CopiesDefault.class);
+ classesByName.put("job-id", JobId.class);
+ classesByName.put("job-priority-supported", JobPrioritySupported.class);
+ classesByName.put("job-priority-default", JobPriorityDefault.class);
+ classesByName.put("number-up-supported", NumberUpSupported.class);
+ classesByName.put("number-up-default", NumberUpDefault.class);
+ classesByName.put("queued-job-count", QueuedJobCount.class);
+ classesByName.put("printer-up-time", PrinterUpTime.class);
+ classesByName.put("pages-per-minute", PagesPerMinute.class);
+ classesByName.put("pages-per-minute-color", PagesPerMinuteColor.class);
+ classesByName.put("job-k-octets-processed", JobKOctetsProcessed.class);
+ classesByName.put("number-of-intervening-jobs",
+ NumberOfInterveningJobs.class);
+ classesByName.put("job-impressions-completed",
+ JobImpressionsCompleted.class);
+ classesByName.put("job-media-sheets-completed",
+ JobMediaSheetsCompleted.class);
+ classesByName.put("multiple-operation-time-out",
+ MultipleOperationTimeOut.class);
+
+
+ // 4.2 job template attributes
+ instanceByClass.put(JobPriority.class, new JobPrioritySupported(1));
+ instanceByClass.put(JobHoldUntil.class, new JobHoldUntilSupported("", null));
+ instanceByClass.put(JobSheets.class, new JobSheetsSupported("", null));
+ instanceByClass.put(MultipleDocumentHandling.class, MultipleDocumentHandlingSupported.SINGLE_DOCUMENT);
+ instanceByClass.put(Copies.class, new CopiesSupported(1));
+ instanceByClass.put(Finishings.class, FinishingsSupported.BIND);
+ instanceByClass.put(PageRanges.class, PageRangesSupported.SUPPORTED);
+ instanceByClass.put(Sides.class, SidesSupported.DUPLEX);
+ instanceByClass.put(NumberUp.class, new NumberUpSupported(1));
+ instanceByClass.put(OrientationRequested.class, OrientationRequestedSupported.LANDSCAPE);
+ instanceByClass.put(Media.class, new MediaSupported("", null));
+ instanceByClass.put(PrinterResolution.class, new PrinterResolutionSupported(1,1,1));
+ instanceByClass.put(PrintQuality.class, PrintQualitySupported.DRAFT);
+
+ // 4.4 printer attributes
+ instanceByClass.put(Compression.class, CompressionSupported.COMPRESS);
+ }
+
+ private IppUtilities()
+ {
+ // not to be instantiated
+ }
+
+ /**
+ * Returns the implementing class object for given
+ * attribute name objects.
+ *
+ * @param name the attribute name
+ * @return The <code>Class</code> object.
+ */
+ public static Class getClass(String name)
+ {
+ return (Class) classesByName.get(name);
+ }
+
+ /**
+ * Returns the name of the supported attribute
+ * based on the given standard attribute category.
+ *
+ * @param clazz the standard attribute category
+ * @return The name of the supported attribute category.
+ */
+ public static String getSupportedAttrName(Class clazz)
+ {
+ return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getName();
+ }
+
+ /**
+ * Returns the category of the supported attribute
+ * based on the given standard attribute category.
+ *
+ * @param clazz the standard attribute category
+ * @return The supported attribute category.
+ */
+ public static Class getSupportedCategory(Class clazz)
+ {
+ return ((SupportedValuesAttribute) instanceByClass.get(clazz)).getCategory();
+ }
+
+ /**
+ * Helper method to convert to an int.
+ * @param b the byte array
+ * @return The converted int.
+ */
+ public static int convertToInt(byte[] b)
+ {
+ return (((b[0] & 0xff) << 24) | ((b[1] & 0xff) << 16)
+ | ((b[2] & 0xff) << 8) | (b[3] & 0xff));
+ }
+
+ /**
+ * Helper method to convert to an int.
+ * @param b1 the 1th byte
+ * @param b2 the 2th byte
+ * @param b3 the 3th byte
+ * @param b4 the 4th byte
+ * @return The converted int.
+ */
+ public static int convertToInt(byte b1, byte b2, byte b3, byte b4)
+ {
+ return (((b1 & 0xff) << 24) | ((b2 & 0xff) << 16)
+ | ((b3 & 0xff) << 8) | (b4 & 0xff));
+ }
+
+ /**
+ * Helper method to convert to a short.
+ * @param b1 the 1th byte
+ * @param b2 the 2th byte
+ * @return The converted short.
+ */
+ public static short convertToShort(byte b1, byte b2)
+ {
+ return (short) ((b1 << 8) | (b2 & 0xff));
+ }
+
+ /**
+ * Instantiates an <code>EnumSyntax</code> based attribute with the given IPP
+ * name and the given value (Enums maybe int or String based).
+ *
+ * @param name the attribute name of the subclass.
+ * @param value the integer value of the specific enum.
+ * @return The Attribute (a subclass of EnumSyntax)
+ */
+ public static Attribute getEnumAttribute(String name, Object value)
+ {
+ Class attrClass = getClass(name);
+
+ // There might be unknown enums we have no mapped class for
+ if (attrClass == null)
+ return null;
+
+ try
+ {
+ Field[] fields = attrClass.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ Field field = fields[i];
+ if (field.getType().equals(attrClass))
+ {
+ EnumSyntax attr = (EnumSyntax) field.get(null);
+ if (value instanceof Integer
+ && attr.getValue() == ((Integer) value).intValue())
+ return (Attribute) attr;
+ else if (value instanceof String
+ && attr.toString().equals(value))
+ return (Attribute) attr;
+ }
+ }
+ }
+ catch (SecurityException e)
+ {
+ // should not happen
+ }
+ catch (IllegalArgumentException e)
+ {
+ // should not happen
+ }
+ catch (IllegalAccessException e)
+ {
+ // should not happen, all fields are public
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Instantiates an <code>IntegerSyntax</code> based attribute with the
+ * given IPP name for the given int value.
+ *
+ * @param name the attribute name of the subclass.
+ * @param value the integer value
+ * @return The Attribute (a subclass of IntegerSyntax)
+ */
+ public static Attribute getIntegerAttribute(String name, int value)
+ {
+ Class attrClass = getClass(name);
+
+ // There might be unknown attributes we have no mapped class for
+ if (attrClass == null)
+ return null;
+
+ try
+ {
+ INTEGER_ATT_VALUE[0] = new Integer(value);
+ Constructor c = attrClass.getDeclaredConstructor(INTEGER_CLASS_ARRAY);
+ return (Attribute) c.newInstance(INTEGER_ATT_VALUE);
+ }
+ catch (SecurityException e)
+ {
+ // should not happen
+ }
+ catch (NoSuchMethodException e)
+ {
+ // should not happen
+ }
+ catch (IllegalAccessException e)
+ {
+ // should not happen, all fields are public
+ }
+ catch (InstantiationException e)
+ {
+ // should not happen, all fields are public
+ }
+ catch (InvocationTargetException e)
+ {
+ // should not happen, all fields are public
+ }
+
+ return null;
+ }
+
+ /**
+ * Instantiates an <code>TextSyntax</code> based attribute with the given
+ * IPP name for the given text value (will be decoded).
+ *
+ * @param name the attribute name of the subclass.
+ * @param tag the tag defined in {@link IppValueTag}
+ * @param value the byte[] value to be decoded based on the tag value.
+ * @return The Attribute (a subclass of TextSyntax)
+ */
+ public static Attribute getTextAttribute(String name, byte tag, byte[] value)
+ {
+ // without language tag is rather easy - default locale
+ if (tag == IppValueTag.NAME_WITHOUT_LANGUAGE
+ || tag == IppValueTag.TEXT_WITHOUT_LANGUAGE)
+ {
+ TEXT_ATT_VALUE[0] = new String(value);
+ TEXT_ATT_VALUE[1] = Locale.getDefault();
+ }
+ else
+ {
+ short langLength = convertToShort(value[0], value[1]);
+ byte[] tmp = new byte[langLength];
+ byte[] tmp2 = new byte[value.length - 4 - langLength];
+ System.arraycopy(value, 2, tmp, 0, langLength);
+
+ // parse into language/region
+ String language = new String(tmp);
+ String text = new String(tmp2);
+ Locale locale = null;
+
+ if (language.length() > 2)
+ locale = new Locale(language.substring(0, 2), language.substring(3));
+ else
+ locale = new Locale(language);
+
+ TEXT_ATT_VALUE[0] = text;
+ TEXT_ATT_VALUE[1] = locale;
+ }
+
+ Class attrClass = getClass(name);
+
+ // There might be unknown attributes we have no mapped class for
+ if (attrClass == null)
+ return null;
+
+ try
+ {
+ Constructor c = attrClass.getDeclaredConstructor(TEXT_CLASS_ARRAY);
+ return (Attribute) c.newInstance(TEXT_ATT_VALUE);
+ }
+ catch (SecurityException e)
+ {
+ // should not happen
+ }
+ catch (NoSuchMethodException e)
+ {
+ // should not happen
+ }
+ catch (IllegalAccessException e)
+ {
+ // should not happen, all fields are public
+ }
+ catch (InstantiationException e)
+ {
+ // should not happen, all fields are public
+ }
+ catch (InvocationTargetException e)
+ {
+ // should not happen, all fields are public
+ }
+
+ return null;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java b/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java
new file mode 100644
index 00000000000..0c81befca08
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/IppValueTag.java
@@ -0,0 +1,170 @@
+/* IppValueTag.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+/**
+ * IPP Value Tags as described in RFC 2910 section 3.5.2.
+ * <p>
+ * Attributes are always of a special type syntax (e.g. boolean or
+ * interger attribute). These value types are specified by the tag
+ * constants provided in this class. Beside the syntax types some
+ * out of band values for reporting requested attributes as
+ * unsupported, unknown etc. back to the client.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class IppValueTag
+{
+
+ /** Out of band value for unsupported attributes. */
+ public static final byte UNSUPPORTED = 0x10;
+
+ // 0x11 reserved for 'default' for definition in a future
+ // IETF standards track document
+
+ /** Out of band value for unknown attributes. */
+ public static final byte UNKNOWN = 0x12;
+
+ /** Out of band value for attribute without a value. */
+ public static final byte NO_VALUE = 0x13;
+
+ // 0x14-0x1F reserved for "out-of-band" values in future IETF
+ // standards track documents.
+
+ // 0x20 reserved for definition in a future IETF
+ // standards track document
+
+ /** Indicates a value of syntax type integer. */
+ public static final byte INTEGER = 0x21;
+
+ /** Indicates a value of syntax type boolean. */
+ public static final byte BOOLEAN = 0x22;
+
+ /** Indicates a value of syntax type enum (enumeration). */
+ public static final byte ENUM = 0x23;
+
+ // 0x24-0x2F reserved for integer types for definition in
+ // future IETF standards track documents
+
+ /** Indicates a value of syntax type octect string. */
+ public static final byte OCTECTSTRING_UNSPECIFIED = 0x30;
+
+ /** Indicates a value of syntax type datetime. */
+ public static final byte DATETIME = 0x31;
+
+ /** Indicates a value of syntax type resolution. */
+ public static final byte RESOLUTION = 0x32;
+
+ /** Indicates a value of syntax type range of integers. */
+ public static final byte RANGEOFINTEGER = 0x33;
+
+ // 0x34 reserved for definition in a future IETF
+ // standards track document
+
+ /** Indicates a value of syntax type text with language. */
+ public static final byte TEXT_WITH_LANGUAGE = 0x35;
+
+ /** Indicates a value of syntax type name with language. */
+ public static final byte NAME_WITH_LANGUAGE = 0x36;
+
+ // 0x37-0x3F reserved for octetString type definitions in
+ // future IETF standards track documents
+
+ // 0x40 reserved for definition in a future IETF
+ // standards track document
+
+ /** Indicates a value of syntax type text without language. */
+ public static final byte TEXT_WITHOUT_LANGUAGE = 0x41;
+
+ /** Indicates a value of syntax type name without language. */
+ public static final byte NAME_WITHOUT_LANGUAGE = 0x42;
+
+ // 0x43 reserved for definition in a future IETF
+ // standards track document
+
+ /** Indicates a value of syntax type keyword. */
+ public static final byte KEYWORD = 0x44;
+
+ /** Indicates a value of syntax type URI. */
+ public static final byte URI = 0x45;
+
+ /** Indicates a value of syntax type URI scheme. */
+ public static final byte URI_SCHEME = 0x46;
+
+ /** Indicates a value of syntax type charset. */
+ public static final byte CHARSET = 0x47;
+
+ /** Indicates a value of syntax type language. */
+ public static final byte NATURAL_LANGUAGE =0x48;
+
+ /** Indicates a value of syntax type mime media. */
+ public static final byte MIME_MEDIA_TYPE = 0x49;
+
+ // 0x4A-0x5F reserved for character string type definitions
+ // in future IETF standards track documents
+
+
+ private IppValueTag()
+ {
+ // not to be instantiated;
+ }
+
+ /**
+ * Tests if given value corresponds to a
+ * value tag value.
+ *
+ * @param value the value to test for
+ * @return <code>true</code> if, <code>false</code> otherwise.
+ */
+ public static boolean isValueTag(byte value)
+ {
+ if(value == 0x10 || value == 0x12 || value == 0x13
+ || value == 0x21 || value == 0x22 || value == 0x23
+ || value == 0x30 || value == 0x31 || value == 0x32
+ || value == 0x33 || value == 0x35 || value == 0x36
+ || value == 0x41 || value == 0x42 || value == 0x44
+ || value == 0x45 || value == 0x46 || value == 0x47
+ || value == 0x48 || value == 0x49 )
+ return true;
+
+ return false;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java b/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java
new file mode 100644
index 00000000000..1167f52c3b7
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/MultiDocPrintJobImpl.java
@@ -0,0 +1,80 @@
+/* MultiDocPrintJobImpl.java -- GNU implementation of MultiDocPrintJob
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp;
+
+
+import javax.print.MultiDoc;
+import javax.print.MultiDocPrintJob;
+import javax.print.PrintException;
+import javax.print.attribute.PrintRequestAttributeSet;
+
+/**
+ * Implementation of the MultiDocPrintJob interface. Implementation
+ * is specific to the <code>IppPrintService</code> implementation.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class MultiDocPrintJobImpl extends DocPrintJobImpl
+ implements MultiDocPrintJob
+{
+
+ /**
+ * Constructor forwarding arguments to the super constructor.
+ *
+ * @param service the print service instance.
+ * @param user the user of this print service.
+ * @param passwd the password of the user.
+ */
+ public MultiDocPrintJobImpl(IppPrintService service, String user,
+ String passwd)
+ {
+ super(service, user, passwd);
+ }
+
+ /**
+ * @see MultiDocPrintJob#print(MultiDoc, PrintRequestAttributeSet)
+ */
+ public void print(MultiDoc multiDoc, PrintRequestAttributeSet attributes)
+ throws PrintException
+ {
+ // FIXME Implement
+ throw new PrintException("Multidoc not yet supported by implementation.");
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java
new file mode 100644
index 00000000000..0db846cbab9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/CharsetSyntax.java
@@ -0,0 +1,115 @@
+/* CharsetSyntax.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.io.Serializable;
+
+/**
+ * <code>CharsetSyntax</code> is the abstract base class of all attribute
+ * classes which provide a charset (US-ASCII) string as value.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public abstract class CharsetSyntax implements Cloneable, Serializable
+{
+ private final String value;
+
+ /**
+ * Creates a <code>CharsetSyntax</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ *
+ * @exception NullPointerException if value is null
+ */
+ protected CharsetSyntax(String value)
+ {
+ if (value == null)
+ throw new NullPointerException("value may not be null");
+
+ this.value = value;
+ }
+
+ /**
+ * Returns the value of this syntax object.
+ *
+ * @return The value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the hashcode for this object.
+ *
+ * @return The hashcode.
+ */
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return true if both objects are equal, false otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof CharsetSyntax))
+ return false;
+
+ CharsetSyntax tmp = (CharsetSyntax) obj;
+ return value.equals(tmp.getValue());
+ }
+
+ /**
+ * Returns a string representing the object. The returned
+ * string is the underlying text value of this object.
+ *
+ * @return The string representation.
+ */
+ public String toString()
+ {
+ return getValue();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java
new file mode 100644
index 00000000000..0f1084f4958
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DefaultValueAttribute.java
@@ -0,0 +1,59 @@
+/* DefaultValueAttribute.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * Marker interface for all attribute classes describing attributes
+ * providing default values. Often there exist a sequence of an
+ * attribute name like: Name - &gt; Name-default -&gt; Name-supported.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public interface DefaultValueAttribute extends Attribute
+{
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute();
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java
new file mode 100644
index 00000000000..433b6f35a38
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DetailedStatusMessage.java
@@ -0,0 +1,93 @@
+/* DetailedStatusMessage.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * DetailedStatusMessage attribute as described in RFC 2911 section
+ * 3.1.6 Operation Response Status Codes and Status Message
+ * provides a short description of the status of the operation.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class DetailedStatusMessage extends TextSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>DetailedStatusMessage</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public DetailedStatusMessage(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DetailedStatusMessage</code> itself.
+ */
+ public Class getCategory()
+ {
+ return DetailedStatusMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "detailed-status-message".
+ */
+ public String getName()
+ {
+ return "detailed-status-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java
new file mode 100644
index 00000000000..3433e3ed731
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/DocumentAccessError.java
@@ -0,0 +1,93 @@
+/* DocumentAccessError.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * DocumentAccessError attribute as described in RFC 2911 section
+ * 3.1.6 Operation Response Status Codes and Status Message
+ * provides additional information for document access errors.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class DocumentAccessError extends TextSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>DocumentAccessError</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public DocumentAccessError(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentAccessError</code> itself.
+ */
+ public Class getCategory()
+ {
+ return DocumentAccessError.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-access-error".
+ */
+ public String getName()
+ {
+ return "document-access-error";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java
new file mode 100644
index 00000000000..c90af3eb8e5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java
@@ -0,0 +1,117 @@
+/* NaturalLanguageSyntax.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.io.Serializable;
+
+/**
+ * <code>NaturalLanguageSyntax</code> is the abstract base class of all
+ * attribute classes which provide a natural language (US-ASCII)
+ * string as value.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public abstract class NaturalLanguageSyntax
+ implements Cloneable, Serializable
+{
+ private final String value;
+
+ /**
+ * Creates a <code>NaturalLanguageSyntax</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ *
+ * @exception NullPointerException if value is null
+ */
+ protected NaturalLanguageSyntax(String value)
+ {
+ if (value == null)
+ throw new NullPointerException("value may not be null");
+
+ this.value = value;
+ }
+
+ /**
+ * Returns the value of this syntax object.
+ *
+ * @return The value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the hashcode for this object.
+ *
+ * @return The hashcode.
+ */
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return true if both objects are equal, false otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof NaturalLanguageSyntax))
+ return false;
+
+ NaturalLanguageSyntax tmp = (NaturalLanguageSyntax) obj;
+ return value.equals(tmp.getValue());
+ }
+
+ /**
+ * Returns a string representing the object. The returned
+ * string is the underlying text value of this object.
+ *
+ * @return The string representation.
+ */
+ public String toString()
+ {
+ return getValue();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java
new file mode 100644
index 00000000000..ae9d32dfdbd
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/RequestedAttributes.java
@@ -0,0 +1,130 @@
+/* RequestedAttributes.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * <code>RequestedAttributes</code> specifies the requested
+ * attributes in an IPP request operation.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class RequestedAttributes implements Attribute
+{
+ private ArrayList attributes;
+
+ /**
+ * Creates a <code>RequestedAttributes</code> object with
+ * the initial value.
+ *
+ * @param value the string for the ipp name
+ *
+ * @exception NullPointerException if value is null
+ */
+ public RequestedAttributes(String value)
+ {
+ if (value == null)
+ throw new NullPointerException();
+
+ attributes = new ArrayList();
+ attributes.add(value);
+ }
+
+ /**
+ * Adds the IPP name value to the set.
+ *
+ * @param value the string for the ipp name
+ */
+ public void addValue(String value)
+ {
+ attributes.add(value);
+ }
+
+ /**
+ * Returns the values.
+ *
+ * @return The values as list.
+ */
+ public List getValues()
+ {
+ return attributes;
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentFormat</code> itself.
+ */
+ public Class getCategory()
+ {
+ return RequestedAttributes.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "requested-attributes".
+ */
+ public String getName()
+ {
+ return "requested-attributes";
+ }
+
+ /**
+ * Returns the string representation for this object.
+ *
+ * @return The string representation.
+ */
+ public String toString()
+ {
+ StringBuffer b = new StringBuffer();
+
+ if (attributes.size() > 0)
+ b.append(attributes.get(0));
+
+ for (int i=1; i < attributes.size(); i++)
+ b.append(", " + attributes.get(i));
+
+ return b.toString();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java
new file mode 100644
index 00000000000..692b26ed562
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/StatusMessage.java
@@ -0,0 +1,92 @@
+/* StatusMessage.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * StatusMessage attribute as described in RFC 2911 section
+ * 3.1.6 Operation Response Status Codes and Status Message
+ * provides a short description of the status of the operation.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class StatusMessage extends TextSyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>StatusMessage</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public StatusMessage(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>StatusMessage</code> itself.
+ */
+ public Class getCategory()
+ {
+ return StatusMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "status-message".
+ */
+ public String getName()
+ {
+ return "status-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java
new file mode 100644
index 00000000000..233431ad39c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/UnknownAttribute.java
@@ -0,0 +1,190 @@
+/* UnknownAttribute.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.IppValueTag;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * UnknownAttribute holds all the parsed Attribute information.
+ * It provides methods to get the value-tag, name and value.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class UnknownAttribute implements Attribute
+{
+ private byte tag;
+ private String name;
+ private byte[] value;
+
+ /**
+ * Creates a <code>UnknownAttribute</code> object with the given values.
+ *
+ * @param tag the value tag
+ * @param name the attribute name
+ * @param value the byte[] with the value
+ */
+ public UnknownAttribute(byte tag, String name, byte[] value)
+ {
+ this.tag = tag;
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>UnknownAttribute</code> itself.
+ */
+ public Class getCategory()
+ {
+ return UnknownAttribute.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name attributes IPP name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the value tag
+ * @return The tag.
+ *
+ * @see gnu.javax.print.ipp.IppValueTag
+ */
+ public byte getValueTag()
+ {
+ return tag;
+ }
+
+ /**
+ * Returns the name of the attribute.
+ * @return The name.
+ */
+ public String getAttributeName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the attribute value origin byte array.
+ * @return The value.
+ */
+ public byte[] getAttributeValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the attribute value decoded as String.
+ * @return The value as String.
+ */
+ public String getAttributeValueAsString()
+ {
+ return new String(value);
+ }
+
+ /**
+ * Returns the attribute value decoded as int.
+ * @return The value as int.
+ */
+ public int getAttributeValueAsInt()
+ {
+ return IppUtilities.convertToInt(value);
+ }
+
+ /**
+ * Returns the attribute value decoded as an URI.
+ * @return The value as URI.
+ */
+ public URI getAttributeValueAsUri()
+ {
+ try
+ {
+ return new URI(new String(value));
+ }
+ catch (URISyntaxException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Provides a string representation for some default
+ * tag types (e.g. int, rangeofinteger, string, uri).
+ * For other more complex types "No conversion found."
+ * is returned.
+ */
+ public String toString()
+ {
+ switch (tag)
+ {
+ case IppValueTag.INTEGER:
+ return "" + getAttributeValueAsInt();
+ case IppValueTag.RANGEOFINTEGER:
+ int lower = IppUtilities.convertToInt(value[0], value[1],
+ value[2], value[3]);
+ int upper = IppUtilities.convertToInt(value[4], value[5],
+ value[6], value[7]);
+ return lower + "-" + upper;
+ case IppValueTag.URI:
+ return getAttributeValueAsUri().toString();
+ case IppValueTag.KEYWORD:
+ case IppValueTag.URI_SCHEME:
+ case IppValueTag.CHARSET:
+ case IppValueTag.NATURAL_LANGUAGE:
+ case IppValueTag.MIME_MEDIA_TYPE:
+ case IppValueTag.NAME_WITHOUT_LANGUAGE:
+ case IppValueTag.TEXT_WITHOUT_LANGUAGE:
+ return getAttributeValueAsString();
+ default:
+ return "No conversion found.";
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java
new file mode 100644
index 00000000000..225a0895a0f
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java
@@ -0,0 +1,118 @@
+/* CopiesDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.Copies;
+
+/**
+ * <code>CopiesDefault</code> provides the default value
+ * for the copies attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CopiesDefault extends IntegerSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>CopiesDefault</code> object.
+ *
+ * @param value the number of copies
+ *
+ * @exception IllegalArgumentException if value &lt; 1
+ */
+ public CopiesDefault(int value)
+ {
+ super(value);
+
+ if (value < 1)
+ throw new IllegalArgumentException("value may not be less than 1");
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof CopiesDefault))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>CopiesDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return CopiesDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "copies-default".
+ */
+ public String getName()
+ {
+ return "copies-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ * <p>May return null if no value exists in JPS API.</p>
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return new Copies(getValue());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java
new file mode 100644
index 00000000000..fe40aee7222
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java
@@ -0,0 +1,106 @@
+/* DocumentFormatDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+import gnu.javax.print.ipp.attribute.printer.DocumentFormat;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatDefault</code> specifies the default document
+ * format of a printer.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ *
+ */
+public final class DocumentFormatDefault extends TextSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>DocumentFormatDefault</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public DocumentFormatDefault(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentFormatDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return DocumentFormatDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-format-default".
+ */
+ public String getName()
+ {
+ return "document-format-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return new DocumentFormat(getValue(), getLocale());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java
new file mode 100644
index 00000000000..d3dd99c06d2
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java
@@ -0,0 +1,263 @@
+/* FinishingsDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * The <code>FinishingsDefault</code> attribute provides the supported
+ * values for finishings of a job.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class FinishingsDefault extends EnumSyntax
+ implements DefaultValueAttribute
+{
+
+ /** No finishing. */
+ public static final FinishingsDefault NONE = new FinishingsDefault(3);
+
+ /** Staple the document(s) */
+ public static final FinishingsDefault STAPLE = new FinishingsDefault(4);
+
+ /** Cover a document */
+ public static final FinishingsDefault COVER = new FinishingsDefault(6);
+
+ /**
+ * This value indicates that a binding is to be applied to the document.
+ * The type and placement of the binding is site-defined.
+ */
+ public static final FinishingsDefault BIND = new FinishingsDefault(7);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along the middle fold.
+ */
+ public static final FinishingsDefault SADDLE_STITCH = new FinishingsDefault(8);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along one edge.
+ */
+ public static final FinishingsDefault EDGE_STITCH = new FinishingsDefault(9);
+
+ /**
+ * Bind the document(s) with one or more staples in the top left
+ * corner.
+ */
+ public static final FinishingsDefault STAPLE_TOP_LEFT = new FinishingsDefault(20);
+
+ /**
+ * Bind the document(s) with one or more staples in the bottom
+ * left corner.
+ */
+ public static final FinishingsDefault STAPLE_BOTTOM_LEFT = new FinishingsDefault(21);
+
+ /**
+ * Bind the document(s) with one or more staples in the top right corner.
+ */
+ public static final FinishingsDefault STAPLE_TOP_RIGHT = new FinishingsDefault(22);
+
+ /**
+ * Bind the document(s) with one or more staples in the bottom right corner.
+ */
+ public static final FinishingsDefault STAPLE_BOTTOM_RIGHT = new FinishingsDefault(23);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along the left edge.
+ */
+ public static final FinishingsDefault EDGE_STITCH_LEFT = new FinishingsDefault(24);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the top edge.
+ */
+ public static final FinishingsDefault EDGE_STITCH_TOP = new FinishingsDefault(25);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the right edge.
+ */
+ public static final FinishingsDefault EDGE_STITCH_RIGHT = new FinishingsDefault(26);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the bottom edge.
+ */
+ public static final FinishingsDefault EDGE_STITCH_BOTTOM = new FinishingsDefault(27);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * left edge assuming a portrait document.
+ */
+ public static final FinishingsDefault STAPLE_DUAL_LEFT = new FinishingsDefault(28);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * top edge assuming a portrait document.
+ */
+ public static final FinishingsDefault STAPLE_DUAL_TOP = new FinishingsDefault(29);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * right edge assuming a portrait document.
+ */
+ public static final FinishingsDefault STAPLE_DUAL_RIGHT = new FinishingsDefault(30);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * bottom edge assuming a portrait document.
+ */
+ public static final FinishingsDefault STAPLE_DUAL_BOTTOM = new FinishingsDefault(31);
+
+ private static final String[] stringTable = { "none", "staple", null,
+ "cover", "bind", "saddle-stitch",
+ "edge-stitch", null, null, null,
+ null, null, null, null, null,
+ null, null, "staple-top-left",
+ "staple-bottom-left",
+ "staple-top-right",
+ "staple-bottom-right",
+ "edge-stitch-left",
+ "edge-stitch-top",
+ "edge-stitch-right",
+ "edge-stitch-bottom",
+ "staple-dual-left",
+ "staple-dual-top",
+ "staple-dual-right",
+ "staple-dual-bottom" };
+
+ private static final FinishingsDefault[] enumValueTable = { NONE, STAPLE, null,
+ COVER, BIND,
+ SADDLE_STITCH,
+ EDGE_STITCH, null,
+ null, null, null,
+ null, null, null,
+ null, null, null,
+ STAPLE_TOP_LEFT,
+ STAPLE_BOTTOM_LEFT,
+ STAPLE_TOP_RIGHT,
+ STAPLE_BOTTOM_RIGHT,
+ EDGE_STITCH_LEFT,
+ EDGE_STITCH_TOP,
+ EDGE_STITCH_RIGHT,
+ EDGE_STITCH_BOTTOM,
+ STAPLE_DUAL_LEFT,
+ STAPLE_DUAL_TOP,
+ STAPLE_DUAL_RIGHT,
+ STAPLE_DUAL_BOTTOM };
+
+ /**
+ * Constructs a <code>FinishingsDefault</code> object.
+ *
+ * @param value the value
+ */
+ protected FinishingsDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return the class <code>FinishingsDefault</code> itself
+ */
+ public Class getCategory()
+ {
+ return FinishingsDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "finishings-default".
+ */
+ public String getName()
+ {
+ return "finishings-default";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute("finishings", new Integer(getValue()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java
new file mode 100644
index 00000000000..a0baac7273a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java
@@ -0,0 +1,149 @@
+/* JobHoldUntilDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobHoldUntil;
+
+/**
+ * JobHoldUntilDefault attribute provides the default value
+ * for the attribute type job-hold-until.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobHoldUntilDefault extends TextSyntax
+ implements DefaultValueAttribute
+{
+
+ // a keyword/name based attribute in IPP
+ // can be extended by administrators
+ // standard values are predefined
+
+ /** Job should be printed immediately. */
+ public static final JobHoldUntilDefault NO_HOLD =
+ new JobHoldUntilDefault("no-hold", null);
+
+ /** Job should be hold indefinitely. */
+ public static final JobHoldUntilDefault INDEFINITE =
+ new JobHoldUntilDefault("indefinite", null);
+
+ /** Job should be processed during the day. */
+ public static final JobHoldUntilDefault DAY_TIME =
+ new JobHoldUntilDefault("day-time", null);
+
+ /** Job should be processed in the evening. */
+ public static final JobHoldUntilDefault EVENING =
+ new JobHoldUntilDefault("evening", null);
+
+ /** Job should be processed during night. */
+ public static final JobHoldUntilDefault NIGHT =
+ new JobHoldUntilDefault("night", null);
+
+ /** Job should be processed during the weekend. */
+ public static final JobHoldUntilDefault WEEKEND =
+ new JobHoldUntilDefault("weekend", null);
+
+ /**
+ * Job should be processed as second-shift
+ * (after close of business).
+ */
+ public static final JobHoldUntilDefault SECOND_SHIFT =
+ new JobHoldUntilDefault("second-shift", null);
+
+ /**
+ * Job should be processed as third-shift
+ * (after midnight).
+ */
+ public static final JobHoldUntilDefault THIRD_SHIFT =
+ new JobHoldUntilDefault("third-shift", null);
+
+ /**
+ * Creates a <code>JobHoldUntilDefault</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public JobHoldUntilDefault(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobHoldUntilDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobHoldUntilDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-hold-until-default".
+ */
+ public String getName()
+ {
+ return "job-hold-until-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ // FIXME Same Mapping problem as in IppPrintService
+ return new JobHoldUntil(new Date());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java
new file mode 100644
index 00000000000..de6ad5a8af2
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java
@@ -0,0 +1,118 @@
+/* JobPriorityDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.JobPriority;
+
+
+/**
+ * JobPriorityDefault attribute provides the default value of
+ * the printer object for the job-priority attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobPriorityDefault extends IntegerSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>JobPriorityDefault</code> object.
+ *
+ * @param value the priority
+ *
+ * @exception IllegalArgumentException if value &lt; 1 or value &gt; 100
+ */
+ public JobPriorityDefault(int value)
+ {
+ super(value);
+
+ if (value < 1 || value > 100)
+ throw new IllegalArgumentException("value out of range");
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof JobPriorityDefault))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobPriorityDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobPriorityDefault.class;
+ }
+
+ /**
+ * Returns name of this class.
+ *
+ * @return The anme "job-priority-default".
+ */
+ public String getName()
+ {
+ return "job-priority-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return new JobPriority(getValue());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java
new file mode 100644
index 00000000000..8f92891238b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java
@@ -0,0 +1,122 @@
+/* JobSheetsDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobSheets;
+
+/**
+ * JobSheetsDefault attribute provides the default value of
+ * the printer object for the job-sheets attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobSheetsDefault extends TextSyntax
+ implements DefaultValueAttribute
+{
+ //a keyword/name based attribute in IPP
+ // can be extended by administrators
+ // standard values are predefined
+
+ /** No job sheet is the default */
+ public static final JobSheetsDefault NONE =
+ new JobSheetsDefault("none", Locale.getDefault());
+
+ /** A job sheet is the default */
+ public static final JobSheetsDefault STANDARD =
+ new JobSheetsDefault("standard", Locale.getDefault());
+
+ /**
+ * Creates a <code>JobSheetsDefault</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public JobSheetsDefault(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobSheetsDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobSheetsDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-sheets-default".
+ */
+ public String getName()
+ {
+ return "job-sheets-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ * <p>May return null if no value exists in JPS API.</p>
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ if (this.equals(JobSheetsDefault.NONE))
+ return JobSheets.NONE;
+ if (this.equals(JobSheetsDefault.STANDARD))
+ return JobSheets.STANDARD;
+
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java
new file mode 100644
index 00000000000..b4e626da6b0
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MediaDefault.java
@@ -0,0 +1,105 @@
+/* MediaDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * MediaDefault attribute provides the default value of
+ * the printer object for the media attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class MediaDefault extends TextSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>MediaDefault</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public MediaDefault(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MediaDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MediaDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "media-default".
+ */
+ public String getName()
+ {
+ return "media-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute("media" , getValue());
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java
new file mode 100644
index 00000000000..0cc324352d8
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java
@@ -0,0 +1,152 @@
+/* MultipleDocumentHandlingDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>MultipleDocumentHandlingDefault</code> provides the
+ * default value for the MultipleDocumentHandling attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class MultipleDocumentHandlingDefault extends EnumSyntax
+ implements DefaultValueAttribute
+{
+
+ //a keyword based attribute in IPP - int values just starting at 0
+
+ /**
+ * Supports only multiple documents treated as a single document. This
+ * applies to attributes which specify treatment of multiple document jobs.
+ */
+ public static final MultipleDocumentHandlingDefault SINGLE_DOCUMENT =
+ new MultipleDocumentHandlingDefault(0);
+
+ /** Supports multiple documents as uncollated copies */
+ public static final MultipleDocumentHandlingDefault SEPARATE_DOCUMENTS_UNCOLLATED_COPIES =
+ new MultipleDocumentHandlingDefault(1);
+
+ /** Supports multiple documents as collated copies */
+ public static final MultipleDocumentHandlingDefault SEPARATE_DOCUMENTS_COLLATED_COPIES =
+ new MultipleDocumentHandlingDefault(2);
+
+ /**
+ * Supports multiple documents where every single document starts
+ * with a new sheet.
+ */
+ public static final MultipleDocumentHandlingDefault SINGLE_DOCUMENT_NEW_SHEET =
+ new MultipleDocumentHandlingDefault(3);
+
+ private static final String[] stringTable = { "single-document",
+ "separate-documents-uncollated-copies",
+ "separate-documents-collated-copies",
+ "single-document-new-sheet" };
+
+ private static final MultipleDocumentHandlingDefault[] enumValueTable =
+ { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
+ SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET};
+
+ /**
+ * Constructs a <code>MultipleDocumentHandlingDefault</code> object.
+ *
+ * @param value the enum value
+ */
+ protected MultipleDocumentHandlingDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MultipleDocumentHandlingDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MultipleDocumentHandlingDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "multiple-document-handling-default".
+ */
+ public String getName()
+ {
+ return "multiple-document-handling-default";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute("multiple-document-handling",
+ new Integer(getValue()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java
new file mode 100644
index 00000000000..6689f2d1c98
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java
@@ -0,0 +1,114 @@
+/* NumberUpDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.standard.NumberUp;
+
+/**
+ * NumberUpDefault attribute provides the default value of
+ * the numper up attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class NumberUpDefault extends IntegerSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>NumberUpDefault</code> object.
+ *
+ * @param value the value
+ * @throws IllegalArgumentException if value &lt; 1
+ */
+ public NumberUpDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof NumberUpDefault))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>NumberUpDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return NumberUpDefault.class;
+ }
+
+ /**
+ * Returns name of this class.
+ *
+ * @return The name "number-up-default".
+ */
+ public String getName()
+ {
+ return "number-up-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ * <p>May return null if no value exists in JPS API.</p>
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return new NumberUp(getValue());
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java
new file mode 100644
index 00000000000..14d26555984
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java
@@ -0,0 +1,154 @@
+/* OrientationRequestedDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * The <code>OrientationRequestedDefault</code> attribute provides
+ * the default value for the job attribute orientation-requested.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class OrientationRequestedDefault extends EnumSyntax
+ implements DefaultValueAttribute
+{
+
+ /** Orientation as portrait. */
+ public static final OrientationRequestedDefault PORTRAIT =
+ new OrientationRequestedDefault(3);
+
+ /** Orientation as landscape. */
+ public static final OrientationRequestedDefault LANDSCAPE =
+ new OrientationRequestedDefault(4);
+
+ /** Orientation as reversed landscape. */
+ public static final OrientationRequestedDefault REVERSE_LANDSCAPE =
+ new OrientationRequestedDefault(5);
+
+ /** Orientation as reversed portrait. */
+ public static final OrientationRequestedDefault REVERSE_PORTRAIT =
+ new OrientationRequestedDefault(6);
+
+
+ private static final String[] stringTable = { "portrait", "landscape",
+ "reverse-landscape",
+ "reverse-portrait" };
+
+ private static final OrientationRequestedDefault[]
+ enumValueTable = { PORTRAIT, LANDSCAPE,
+ REVERSE_LANDSCAPE, REVERSE_PORTRAIT };
+
+ /**
+ * Constructs a <code>OrientationRequestedDefault</code> object.
+ *
+ * @param value the value
+ */
+ protected OrientationRequestedDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>OrientationRequestedDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return OrientationRequestedDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "orientation-requested-default".
+ */
+ public String getName()
+ {
+ return "orientation-requested-default";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute("orientation-requested",
+ new Integer(getValue()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java
new file mode 100644
index 00000000000..707d11de0cd
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java
@@ -0,0 +1,141 @@
+/* PrintQualityDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>PrintQualityDefault</code> provides the
+ * default value for the print-quality attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrintQualityDefault extends EnumSyntax
+ implements DefaultValueAttribute
+{
+ /** Draft quality of the printer. */
+ public static final PrintQualityDefault DRAFT = new PrintQualityDefault(3);
+
+ /** Normal quality of the printer. */
+ public static final PrintQualityDefault NORMAL = new PrintQualityDefault(4);
+
+ /** High quality of the printer. */
+ public static final PrintQualityDefault HIGH = new PrintQualityDefault(5);
+
+ private static final String[] stringTable = { "draft", "normal", "high" };
+
+ private static final PrintQualityDefault[] enumValueTable = { DRAFT, NORMAL, HIGH };
+
+ /**
+ * Constructs a <code>PrintQualityDefault</code> object.
+ *
+ * @param value the value of the enum
+ */
+ protected PrintQualityDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrintQualityDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrintQualityDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "print-quality-default".
+ */
+ public String getName()
+ {
+ return "print-quality-default";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute(
+ "print-quality", new Integer(getValue()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java
new file mode 100644
index 00000000000..baa00c6e9c7
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java
@@ -0,0 +1,119 @@
+/* PrinterResolutionDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.standard.PrinterResolution;
+
+
+/**
+ * The <code>PrinterResolutionDefault</code> attribute provides
+ * the default value for the job attribute printer-resolution.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterResolutionDefault extends ResolutionSyntax
+ implements DefaultValueAttribute
+{
+
+ /**
+ * Creates a <code>ResolutionSyntax</code> object with the given arguments.
+ *
+ * @param crossFeedResolution the cross feed resolution
+ * @param feedResolution the feed resolution
+ * @param units the unit to use (e.g. {@link #DPCM} or {@link #DPI})
+ *
+ * @exception IllegalArgumentException if preconditions fail
+ */
+ public PrinterResolutionDefault(int crossFeedResolution, int feedResolution,
+ int units)
+ {
+ super(crossFeedResolution, feedResolution, units);
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof PrinterResolutionDefault))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterResolutionDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterResolutionDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-resolution-default".
+ */
+ public String getName()
+ {
+ return "printer-resolution-default";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return new PrinterResolution(getCrossFeedResolutionDphi(),
+ getFeedResolutionDphi(), 1);
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java
new file mode 100644
index 00000000000..3c5b0cb864c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/defaults/SidesDefault.java
@@ -0,0 +1,150 @@
+/* SidesDefault.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.defaults;
+
+import gnu.javax.print.ipp.IppUtilities;
+import gnu.javax.print.ipp.attribute.DefaultValueAttribute;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.EnumSyntax;
+
+
+/**
+ * <code>SidesDefault</code> provides the
+ * default for the sides attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class SidesDefault extends EnumSyntax
+ implements DefaultValueAttribute
+{
+
+ /** Specifies that each page should be printed on one sheet. */
+ public static final SidesDefault ONE_SIDED = new SidesDefault(0);
+
+ /**
+ * Specifies that two following pages should be printed on the
+ * front and back of one sheet for binding on the long edge.
+ */
+ public static final SidesDefault TWO_SIDED_LONG_EDGE =
+ new SidesDefault(1);
+
+ /**
+ * Specifies that two following pages should be printed on the
+ * front and back of one sheet for binding on the short edge.
+ */
+ public static final SidesDefault TWO_SIDED_SHORT_EDGE =
+ new SidesDefault(2);
+
+ /** An alias constant for "two sided long edge". */
+ public static final SidesDefault DUPLEX = new SidesDefault(1);
+
+ /** An alias constant for "two sided short edge". */
+ public static final SidesDefault TUMBLE = new SidesDefault(2);
+
+ private static final String[] stringTable = { "one-sided",
+ "two-sided-long-edge",
+ "two-sided-short-edge" };
+
+ private static final SidesDefault[] enumValueTable = { ONE_SIDED,
+ TWO_SIDED_LONG_EDGE,
+ TWO_SIDED_SHORT_EDGE };
+
+
+ /**
+ * Creates a <code>SidesDefault</code> object.
+ *
+ * @param value the value of the enum
+ */
+ protected SidesDefault(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>SidesDefault</code> itself.
+ */
+ public Class getCategory()
+ {
+ return SidesDefault.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "sides-default".
+ */
+ public String getName()
+ {
+ return "sides-default";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this DefaultValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Attribute getAssociatedAttribute()
+ {
+ return IppUtilities.getEnumAttribute("sides", new Integer(getValue()));
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java
new file mode 100644
index 00000000000..057db9bf6a9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesCharset.java
@@ -0,0 +1,93 @@
+/* AttributesCharset.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * AttributesCharset attribute as described in RFC 2911 chapter
+ * 3.1.4 Character Set and Natural Language Operation Attributes.
+ * <p>
+ * This operation attribute identifies the charset used by any text
+ * and name attribute supplied by the client in the request. This
+ * charset must be used by the printer object in the response.<br>
+ * All clients and IPP objects must support the 'utf-8' charset.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class AttributesCharset extends CharsetSyntax
+ implements Attribute
+{
+
+ /** Defines a default UTF-8 charset instance */
+ public static final AttributesCharset UTF8 = new AttributesCharset("utf-8");
+
+ /**
+ * Creates a <code>AttributesCharset</code> object.
+ *
+ * @param value the charset string value.
+ */
+ public AttributesCharset(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>AttributesCharset</code> itself.
+ */
+ public Class getCategory()
+ {
+ return AttributesCharset.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "attributes-charset".
+ */
+ public String getName()
+ {
+ return "attributes-charset";
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java
new file mode 100644
index 00000000000..8a41711ac8b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java
@@ -0,0 +1,95 @@
+/* AttributesNaturalLanguage.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * AttributesNaturalLanguage attribute as described in RFC 2911 chapter
+ * 3.1.4 Character Set and Natural Language Operation Attributes.
+ * <p>
+ * This operation attribute identifies the natural language used
+ * by any text and name attribute supplied by the client in the request.
+ * The printer object should use this natural language for the response
+ * to this request.
+ * </p>
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class AttributesNaturalLanguage extends NaturalLanguageSyntax
+ implements Attribute
+{
+
+ /** Defines the default language EN */
+ public static final AttributesNaturalLanguage EN =
+ new AttributesNaturalLanguage("en");
+
+ /**
+ * Creates a <code>AttributesNaturalLanguage</code> object.
+ *
+ * @param value the language string value.
+ */
+ public AttributesNaturalLanguage(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>AttributesNaturalLanguage</code> itself.
+ */
+ public Class getCategory()
+ {
+ return AttributesNaturalLanguage.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "attributes-natural-language".
+ */
+ public String getName()
+ {
+ return "attributes-natural-language";
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java
new file mode 100644
index 00000000000..29f47b7fa95
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java
@@ -0,0 +1,92 @@
+/* JobDetailedStatusMessages.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobDetailedStatusMessages provides additional detailed and
+ * technical job informations.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobDetailedStatusMessages
+ extends TextSyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobDetailedStatusMessages</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public JobDetailedStatusMessages(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobDetailedStatusMessages</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobDetailedStatusMessages.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-detailed-status-messages".
+ */
+ public String getName()
+ {
+ return "job-detailed-status-messages";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java
new file mode 100644
index 00000000000..46083bed7dc
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java
@@ -0,0 +1,93 @@
+/* JobDocumentAccessErrors.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobDocumentAccessErrors provides additional information
+ * for each access error for print-uri or document-uri jobs.
+ * technical job informations.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobDocumentAccessErrors
+ extends TextSyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobDocumentAccessErrors</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public JobDocumentAccessErrors(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobDocumentAccessErrors</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobDocumentAccessErrors.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-document-access-errors".
+ */
+ public String getName()
+ {
+ return "job-document-access-errors";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java
new file mode 100644
index 00000000000..f1d85fa50ba
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobId.java
@@ -0,0 +1,87 @@
+/* JobId.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * The <code>JobId</code> attribute contains the ID of a
+ * print job created or currently being processed.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobId extends IntegerSyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>IntegerSyntax</code> with the given value.
+ *
+ * @param value the integer to set
+ * @throws IllegalArgumentException if value is &lt; 1
+ */
+ public JobId(int value)
+ {
+ super(value);
+
+ if (value < 1)
+ throw new IllegalArgumentException("job-id may not be less than 1");
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobId</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobId.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-id".
+ */
+ public String getName()
+ {
+ return "job-id";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java
new file mode 100644
index 00000000000..a2fe322a887
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobMoreInfo.java
@@ -0,0 +1,87 @@
+/* JobMoreInfo.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobMoreInfo attribute as described in RFC 2911 section
+ * 4.3.4 contains the URI where more information about a job
+ * (e.g. through a HTML page) can be found.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobMoreInfo extends URISyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobMoreInfo</code> object.
+ *
+ * @param uri the URI value for the syntax
+ * @throws NullPointerException if uri is null
+ */
+ public JobMoreInfo(URI uri)
+ {
+ super(uri);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobMoreInfo</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobMoreInfo.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-more-info".
+ */
+ public String getName()
+ {
+ return "job-more-info";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java
new file mode 100644
index 00000000000..dce552020f2
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobPrinterUri.java
@@ -0,0 +1,87 @@
+/* JobPrinterUri.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobPrinterUri attribute as described in RFC 2911 section
+ * 4.3.3 contains the URI of the printer which created and
+ * processes a job.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobPrinterUri extends URISyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobPrinterUri</code> object.
+ *
+ * @param uri the URI value for the syntax
+ * @throws NullPointerException if uri is null
+ */
+ public JobPrinterUri(URI uri)
+ {
+ super(uri);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobPrinterUri</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobPrinterUri.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-printer-uri".
+ */
+ public String getName()
+ {
+ return "job-printer-uri";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java
new file mode 100644
index 00000000000..0cf652307b6
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobStateMessage.java
@@ -0,0 +1,92 @@
+/* JobStateMessage.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.util.Locale;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobStateMessage attribute describes information about the
+ * job-state and job-state-reasons in human readable form.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobStateMessage
+ extends TextSyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobStateMessage</code> object with the given value
+ * and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public JobStateMessage(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobStateMessage</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobStateMessage.class;
+ }
+
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-state-message".
+ */
+ public String getName()
+ {
+ return "job-state-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java
new file mode 100644
index 00000000000..fa7e3f7b5a5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/job/JobUri.java
@@ -0,0 +1,87 @@
+/* JobUri.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.job;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * JobUri attribute as described in RFC 2911 section
+ * 4.3.1 contains the URI for a job generated by the printer
+ * after a create request.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobUri extends URISyntax implements Attribute
+{
+
+ /**
+ * Creates a <code>JobUri</code> object.
+ *
+ * @param uri the URI value for the syntax
+ * @throws NullPointerException if uri is null
+ */
+ public JobUri(URI uri)
+ {
+ super(uri);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobUri</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobUri.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-uri".
+ */
+ public String getName()
+ {
+ return "job-uri";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java
new file mode 100644
index 00000000000..7c87545880c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java
@@ -0,0 +1,86 @@
+/* CharsetConfigured.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * CharsetConfigured attribute as described in RFC 2911 section
+ * 4.4.17 provides the charset which is configured by the
+ * server to be used in the name and text syntax attribute types.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CharsetConfigured extends CharsetSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>CharsetConfigured</code> object.
+ *
+ * @param value the charset string value.
+ */
+ public CharsetConfigured(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>CharsetConfigured</code> itself.
+ */
+ public Class getCategory()
+ {
+ return CharsetConfigured.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "charset-configured".
+ */
+ public String getName()
+ {
+ return "charset-configured";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java
new file mode 100644
index 00000000000..e9abab464f1
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/DocumentFormat.java
@@ -0,0 +1,110 @@
+/* DocumentFormat.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Locale;
+
+import javax.print.DocFlavor;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatSupported</code> specifies the supported document
+ * formats of a printer. Printer are supplying a set of this attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class DocumentFormat extends TextSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>DocumentFormat</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public DocumentFormat(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Constructs a document format object for the given flavor.
+ * The constructor reworkes the mimetype of the given flavor
+ * to remove the quoted charset parameter if present.
+ *
+ * @param flavor the flavor with the mimetype
+ * @return The created document format.
+ */
+ public static DocumentFormat createDocumentFormat(DocFlavor flavor)
+ {
+ String charset = flavor.getParameter("charset");
+ String mimetype = flavor.getMediaType() + "/" + flavor.getMediaSubtype();
+ if (charset != null)
+ mimetype += "; charset=" + charset;
+
+ return new DocumentFormat(mimetype, null);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentFormat</code> itself.
+ */
+ public Class getCategory()
+ {
+ return DocumentFormat.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-format".
+ */
+ public String getName()
+ {
+ return "document-format";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java
new file mode 100644
index 00000000000..8e54e05658a
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java
@@ -0,0 +1,86 @@
+/* MultipleOperationTimeOut.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * MultipleOperationTimeOut attribute as described in RFC 2911 section
+ * 4.4.31 provides the minimum time ins second a printer object waits
+ * before time out and recovery. The printer object waits e.g. for
+ * additional SendDocument or SendUri operations.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class MultipleOperationTimeOut extends IntegerSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>MultipleOperationTimeOut</code> with the given value.
+ *
+ * @param value the integer to set
+ */
+ public MultipleOperationTimeOut(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MultipleOperationTimeOut</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MultipleOperationTimeOut.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "multiple-operation-time-out".
+ */
+ public String getName()
+ {
+ return "multiple-operation-time-out";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java
new file mode 100644
index 00000000000..8032c3aa7f3
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java
@@ -0,0 +1,86 @@
+/* NaturalLanguageConfigured.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.Attribute;
+
+/**
+ * NaturalLanguageConfigured attribute as described in RFC 2911
+ * section 4.4.19 provides the natural language which is configured
+ * by the server to be used in the name and text syntax attribute types.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class NaturalLanguageConfigured extends NaturalLanguageSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>NaturalLanguageConfigured</code> object.
+ *
+ * @param value the charset string value.
+ */
+ public NaturalLanguageConfigured(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>NaturalLanguageConfigured</code> itself.
+ */
+ public Class getCategory()
+ {
+ return NaturalLanguageConfigured.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "natural-language-configured".
+ */
+ public String getName()
+ {
+ return "natural-language-configured";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java
new file mode 100644
index 00000000000..fe64ab0f778
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java
@@ -0,0 +1,106 @@
+/* PrinterCurrentTime.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Date;
+
+import javax.print.attribute.DateTimeSyntax;
+import javax.print.attribute.PrintServiceAttribute;
+
+/**
+ * PrinterCurrentTime attribute as described in RFC 2911 section
+ * 4.4.30 provides the current time of the print service.
+ * Its to be used by other attributes like the date-time-at-xxx
+ * attributes in the creation process.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterCurrentTime extends DateTimeSyntax
+ implements PrintServiceAttribute
+{
+
+ /**
+ * Creates a <code>PrinterCurrentTime</code> object.
+ *
+ * @param value the date at creation time
+ *
+ * @exception NullPointerException if value is null
+ */
+ public PrinterCurrentTime(Date value)
+ {
+ super(value);
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof PrinterCurrentTime))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterCurrentTime</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterCurrentTime.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-current-time".
+ */
+ public String getName()
+ {
+ return "printer-current-time";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java
new file mode 100644
index 00000000000..8a70edf349c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java
@@ -0,0 +1,88 @@
+/* PrinterDriverInstaller.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import java.net.URI;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * PrinterDriverInstaller attribute as described in RFC 2911 section
+ * 4.4.81 provides the URI where a printer driver installer
+ * can be found.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterDriverInstaller extends URISyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>PrinterDriverInstaller</code> object.
+ *
+ * @param uri the URI value for the syntax
+ * @throws NullPointerException if uri is null
+ */
+ public PrinterDriverInstaller(URI uri)
+ {
+ super(uri);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterDriverInstaller</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterDriverInstaller.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-driver-installer".
+ */
+ public String getName()
+ {
+ return "printer-driver-installer";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java
new file mode 100644
index 00000000000..da463c4c9fb
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java
@@ -0,0 +1,93 @@
+/* PrinterStateMessage.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import java.util.Locale;
+
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * PrinterStateMessage attribute as described in RFC 2911 section
+ * 4.4.13 provides a textual representation of the attributes
+ * printer-state and printer-state-reasons for consumption by
+ * humans.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterStateMessage extends TextSyntax
+ implements PrintServiceAttribute
+{
+
+ /**
+ * Creates a <code>PrinterStateMessage</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public PrinterStateMessage(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterStateMessage</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterStateMessage.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-state-message".
+ */
+ public String getName()
+ {
+ return "printer-state-message";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java
new file mode 100644
index 00000000000..7f9b1113ff6
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java
@@ -0,0 +1,86 @@
+/* PrinterUpTime.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.printer;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.IntegerSyntax;
+
+/**
+ * PrinterUpTime attribute as described in RFC 2911 section
+ * 4.4.29 provides the uptime of the printer object. This
+ * is a value in second starting at 1 after a initialization
+ * or reboot of the printer object.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterUpTime extends IntegerSyntax
+ implements Attribute
+{
+
+ /**
+ * Creates a <code>PrinterUpTime</code> with the given value.
+ *
+ * @param value the integer to set
+ */
+ public PrinterUpTime(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterUpTime</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterUpTime.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-up-time".
+ */
+ public String getName()
+ {
+ return "printer-up-time";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java
new file mode 100644
index 00000000000..75804b5a46b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CharsetSupported.java
@@ -0,0 +1,87 @@
+/* CharsetSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.CharsetSyntax;
+
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * CharsetSupported attribute as described in RFC 2911 section
+ * 4.4.18 provides the charset which are supported by the
+ * IPP implementation to be used in the name and text syntax
+ * attribute types.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CharsetSupported extends CharsetSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>CharsetSupported</code> object.
+ *
+ * @param value the charset string value.
+ */
+ public CharsetSupported(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>CharsetSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return CharsetSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "charset-supported".
+ */
+ public String getName()
+ {
+ return "charset-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java
new file mode 100644
index 00000000000..648167a938d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/CompressionSupported.java
@@ -0,0 +1,162 @@
+/* CompressionSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Compression;
+
+
+/**
+ * <code>CompressionSupported</code> provides the values which are
+ * supported for the compression attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class CompressionSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ /** The print data is not compressed. */
+ public static final CompressionSupported NONE = new CompressionSupported(0);
+
+ /** The print data is ZIP compressed. */
+ public static final CompressionSupported DEFLATE = new CompressionSupported(1);
+
+ /** The print data is GNU Zip compressed. */
+ public static final CompressionSupported GZIP = new CompressionSupported(2);
+
+ /** The print data is UNIX compressed. */
+ public static final CompressionSupported COMPRESS = new CompressionSupported(3);
+
+ private static final String[] stringTable = { "none", "deflate",
+ "gzip", "compress" };
+
+ private static final CompressionSupported[] enumValueTable = { NONE, DEFLATE,
+ GZIP, COMPRESS };
+
+ /**
+ * Constructs a <code>CompressionSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ protected CompressionSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>CompressionSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return CompressionSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "compression-supported".
+ */
+ public String getName()
+ {
+ return "compression-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Compression getAssociatedAttribute()
+ {
+ return (Compression) IppUtilities.getEnumAttribute(
+ "compression", new Integer(getValue()));
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static Compression[] getAssociatedAttributeArray(Set set)
+ {
+ CompressionSupported tmp;
+ Compression[] result = new Compression[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (CompressionSupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java
new file mode 100644
index 00000000000..6bd63dcfc72
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java
@@ -0,0 +1,91 @@
+/* DocumentFormatSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Locale;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * <code>DocumentFormatSupported</code> specifies the supported document
+ * formats of a printer. Printer are supplying a set of this attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class DocumentFormatSupported extends TextSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>DocumentFormatSupported</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @exception NullPointerException if value is null
+ */
+ public DocumentFormatSupported(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>DocumentFormatSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return DocumentFormatSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "document-format-supported".
+ */
+ public String getName()
+ {
+ return "document-format-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java
new file mode 100644
index 00000000000..9f9c635d3fe
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java
@@ -0,0 +1,303 @@
+/* FinishingsSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.Finishings;
+
+
+/**
+ * The <code>FinishingsSupported</code> attribute provides the supported
+ * values for finishings of a job.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class FinishingsSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ /** No finishing. */
+ public static final FinishingsSupported NONE = new FinishingsSupported(3);
+
+ /** Staple the document(s) */
+ public static final FinishingsSupported STAPLE = new FinishingsSupported(4);
+
+ /** Cover a document */
+ public static final FinishingsSupported COVER = new FinishingsSupported(6);
+
+ /**
+ * This value indicates that a binding is to be applied to the document.
+ * The type and placement of the binding is site-defined.
+ */
+ public static final FinishingsSupported BIND = new FinishingsSupported(7);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along the middle fold.
+ */
+ public static final FinishingsSupported SADDLE_STITCH =
+ new FinishingsSupported(8);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along one edge.
+ */
+ public static final FinishingsSupported EDGE_STITCH =
+ new FinishingsSupported(9);
+
+ /**
+ * Bind the document(s) with one or more staples in the top left
+ * corner.
+ */
+ public static final FinishingsSupported STAPLE_TOP_LEFT =
+ new FinishingsSupported(20);
+
+ /**
+ * Bind the document(s) with one or more staples in the bottom
+ * left corner.
+ */
+ public static final FinishingsSupported STAPLE_BOTTOM_LEFT =
+ new FinishingsSupported(21);
+
+ /**
+ * Bind the document(s) with one or more staples in the top right corner.
+ */
+ public static final FinishingsSupported STAPLE_TOP_RIGHT =
+ new FinishingsSupported(22);
+
+ /**
+ * Bind the document(s) with one or more staples in the bottom right corner.
+ */
+ public static final FinishingsSupported STAPLE_BOTTOM_RIGHT =
+ new FinishingsSupported(23);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches)
+ * along the left edge.
+ */
+ public static final FinishingsSupported EDGE_STITCH_LEFT =
+ new FinishingsSupported(24);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the top edge.
+ */
+ public static final FinishingsSupported EDGE_STITCH_TOP =
+ new FinishingsSupported(25);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the right edge.
+ */
+ public static final FinishingsSupported EDGE_STITCH_RIGHT =
+ new FinishingsSupported(26);
+
+ /**
+ * Bind the document(s) with one or more staples (wire stitches) along
+ * the bottom edge.
+ */
+ public static final FinishingsSupported EDGE_STITCH_BOTTOM =
+ new FinishingsSupported(27);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * left edge assuming a portrait document.
+ */
+ public static final FinishingsSupported STAPLE_DUAL_LEFT =
+ new FinishingsSupported(28);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * top edge assuming a portrait document.
+ */
+ public static final FinishingsSupported STAPLE_DUAL_TOP =
+ new FinishingsSupported(29);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * right edge assuming a portrait document.
+ */
+ public static final FinishingsSupported STAPLE_DUAL_RIGHT =
+ new FinishingsSupported(30);
+
+ /**
+ * Bind the document(s) with two staples (wire stitches) along the
+ * bottom edge assuming a portrait document.
+ */
+ public static final FinishingsSupported STAPLE_DUAL_BOTTOM =
+ new FinishingsSupported(31);
+
+ private static final String[] stringTable = { "none", "staple", null,
+ "cover", "bind", "saddle-stitch",
+ "edge-stitch", null, null, null,
+ null, null, null, null, null,
+ null, null, "staple-top-left",
+ "staple-bottom-left",
+ "staple-top-right",
+ "staple-bottom-right",
+ "edge-stitch-left",
+ "edge-stitch-top",
+ "edge-stitch-right",
+ "edge-stitch-bottom",
+ "staple-dual-left",
+ "staple-dual-top",
+ "staple-dual-right",
+ "staple-dual-bottom" };
+
+ private static final FinishingsSupported[] enumValueTable = { NONE, STAPLE,
+ null, COVER, BIND,
+ SADDLE_STITCH,
+ EDGE_STITCH, null,
+ null, null, null,
+ null, null, null,
+ null, null, null,
+ STAPLE_TOP_LEFT,
+ STAPLE_BOTTOM_LEFT,
+ STAPLE_TOP_RIGHT,
+ STAPLE_BOTTOM_RIGHT,
+ EDGE_STITCH_LEFT,
+ EDGE_STITCH_TOP,
+ EDGE_STITCH_RIGHT,
+ EDGE_STITCH_BOTTOM,
+ STAPLE_DUAL_LEFT,
+ STAPLE_DUAL_TOP,
+ STAPLE_DUAL_RIGHT,
+ STAPLE_DUAL_BOTTOM };
+
+ /**
+ * Constructs a <code>FinishingsSupported</code> object.
+ *
+ * @param value the value
+ */
+ protected FinishingsSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return the class <code>FinishingsSupported</code> itself
+ */
+ public Class getCategory()
+ {
+ return FinishingsSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "finishings-supported".
+ */
+ public String getName()
+ {
+ return "finishings-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public Finishings getAssociatedAttribute()
+ {
+ return (Finishings) IppUtilities.getEnumAttribute(
+ "finishings", new Integer(getValue()));
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static Finishings[] getAssociatedAttributeArray(Set set)
+ {
+ FinishingsSupported tmp;
+ Finishings[] result = new Finishings[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (FinishingsSupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java
new file mode 100644
index 00000000000..1dbb2939fc5
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java
@@ -0,0 +1,88 @@
+/* GeneratedNaturalLanguageSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.NaturalLanguageSyntax;
+
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * GeneratedNaturalLanguageSupported attribute as described
+ * in RFC 2911 section 4.4.20 provides the natural languages
+ * which are supported by the IPP implementation to be used
+ * in the name and text syntax attribute types.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class GeneratedNaturalLanguageSupported
+ extends NaturalLanguageSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>GeneratedNaturalLanguageSupported</code> object.
+ *
+ * @param value the charset string value.
+ */
+ public GeneratedNaturalLanguageSupported(String value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>GeneratedNaturalLanguageSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return GeneratedNaturalLanguageSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "generated-natural-language-supported".
+ */
+ public String getName()
+ {
+ return "generated-natural-language-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java
new file mode 100644
index 00000000000..06365e6d11c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java
@@ -0,0 +1,121 @@
+/* IppVersionsSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * IppVersionsSupported attribute as described in RFC 2911 section
+ * 4.4.14 provides the value(s) (implemented as EnumSyntax)
+ * of the supported IPP versions.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class IppVersionsSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ // a keyword based attribute in IPP - int values just starting at 0
+
+ /** IPP version 1.0 */
+ public static final IppVersionsSupported V_1_0 =
+ new IppVersionsSupported(0);
+
+ /** IPP version 1.1 */
+ public static final IppVersionsSupported V_1_1 =
+ new IppVersionsSupported(1);
+
+ private static final String[] stringTable = { "1.0", "1.1" };
+
+ private static final IppVersionsSupported[] enumValueTable = { V_1_0,
+ V_1_1 };
+
+ /**
+ * Constructs a <code>IppVersionsSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ public IppVersionsSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>IppVersionsSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return IppVersionsSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "ipp-versions-supported".
+ */
+ public String getName()
+ {
+ return "ipp-versions-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java
new file mode 100644
index 00000000000..a15d0095f73
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java
@@ -0,0 +1,133 @@
+/* JobHoldUntilSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Locale;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+
+/**
+ * JobHoldUntilSupported attribute provides the supported
+ * values for the attribute type job-hold-until.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobHoldUntilSupported extends TextSyntax
+ implements SupportedValuesAttribute
+{
+
+ // a keyword/name based attribute in IPP
+ // can be extended by administrators
+ // standard values are predefined
+
+ /** Job should be printed immediately. */
+ public static final JobHoldUntilSupported NO_HOLD =
+ new JobHoldUntilSupported("no-hold", null);
+
+ /** Job should be hold indefinitely. */
+ public static final JobHoldUntilSupported INDEFINITE =
+ new JobHoldUntilSupported("indefinite", null);
+
+ /** Job should be processed during the day. */
+ public static final JobHoldUntilSupported DAY_TIME =
+ new JobHoldUntilSupported("day-time", null);
+
+ /** Job should be processed in the evening. */
+ public static final JobHoldUntilSupported EVENING =
+ new JobHoldUntilSupported("evening", null);
+
+ /** Job should be processed during night. */
+ public static final JobHoldUntilSupported NIGHT =
+ new JobHoldUntilSupported("night", null);
+
+ /** Job should be processed during the weekend. */
+ public static final JobHoldUntilSupported WEEKEND =
+ new JobHoldUntilSupported("weekend", null);
+
+ /**
+ * Job should be processed as second-shift
+ * (after close of business).
+ */
+ public static final JobHoldUntilSupported SECOND_SHIFT =
+ new JobHoldUntilSupported("second-shift", null);
+
+ /**
+ * Job should be processed as third-shift
+ * (after midnight).
+ */
+ public static final JobHoldUntilSupported THIRD_SHIFT =
+ new JobHoldUntilSupported("third-shift", null);
+
+ /**
+ * Creates a <code>JobHoldUntilSupported</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public JobHoldUntilSupported(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobHoldUntilSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobHoldUntilSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-hold-until-supported".
+ */
+ public String getName()
+ {
+ return "job-hold-until-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java
new file mode 100644
index 00000000000..4051e24200c
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java
@@ -0,0 +1,150 @@
+/* JobSheetsSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.attribute.defaults.JobSheetsDefault;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.JobSheets;
+
+/**
+ * JobSheetsSupported attribute provides the supported values
+ * of the job-sheets attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class JobSheetsSupported extends TextSyntax
+ implements SupportedValuesAttribute
+{
+ //a keyword/name based attribute in IPP
+ // can be extended by administrators
+ // standard values are predefined
+
+ /** No job sheet is the default */
+ public static final JobSheetsDefault NONE =
+ new JobSheetsDefault("none", Locale.getDefault());
+
+ /** A job sheet is the default */
+ public static final JobSheetsDefault STANDARD =
+ new JobSheetsDefault("standard", Locale.getDefault());
+
+ /**
+ * Creates a <code>JobSheetsSupported</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public JobSheetsSupported(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>JobSheetsSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return JobSheetsSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "job-sheets-supported".
+ */
+ public String getName()
+ {
+ return "job-sheets-supported";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ * <p>May return null if no value exists in JPS API.</p>
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public JobSheets getAssociatedAttribute()
+ {
+ if (this.equals(JobSheetsDefault.NONE))
+ return JobSheets.NONE;
+ if (this.equals(JobSheetsDefault.STANDARD))
+ return JobSheets.STANDARD;
+
+ return null;
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static JobSheets[] getAssociatedAttributeArray(Set set)
+ {
+ JobSheetsSupported tmp;
+ ArrayList result = new ArrayList();
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (JobSheetsSupported) it.next();
+ Attribute att = tmp.getAssociatedAttribute();
+ if (att != null)
+ result.add(att);
+ j++;
+ }
+ return (JobSheets[]) result.toArray(new JobSheets[result.size()]);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java
new file mode 100644
index 00000000000..3f10c06b5f7
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MediaSupported.java
@@ -0,0 +1,118 @@
+/* MediaSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.Media;
+
+/**
+ * MediaSupported attribute provides the keyword values
+ * of the media types supported by the printer object.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class MediaSupported extends TextSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>MediaSupported</code> object with the
+ * given value and locale.
+ *
+ * @param value the value for this syntax
+ * @param locale the locale to use, if <code>null</code> the default
+ * locale is used.
+ *
+ * @throws NullPointerException if value is null
+ */
+ public MediaSupported(String value, Locale locale)
+ {
+ super(value, locale);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MediaSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MediaSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "media-supported".
+ */
+ public String getName()
+ {
+ return "media-supported";
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ */
+ public static Media[] getAssociatedAttributeArray(Set set)
+ {
+ MediaSupported tmp;
+ Media tmp2;
+ ArrayList result = new ArrayList();
+ Iterator it = set.iterator();
+ while (it.hasNext())
+ {
+ tmp = (MediaSupported) it.next();
+ tmp2 = (Media) IppUtilities.getEnumAttribute("media", tmp.toString());
+ if (tmp2 != null)
+ result.add(tmp2);
+ }
+ return (Media[]) result.toArray(new Media[result.size()]);
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java
new file mode 100644
index 00000000000..891a99faedb
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java
@@ -0,0 +1,177 @@
+/* MultipleDocumentHandlingSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.MultipleDocumentHandling;
+
+
+/**
+ * <code>MultipleDocumentHandlingSupported</code> provides the
+ * supported values for the MultipleDocumentHandling attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class MultipleDocumentHandlingSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ //a keyword based attribute in IPP - int values just starting at 0
+
+ /**
+ * Supports only multiple documents treated as a single document. This
+ * applies to attributes which specify treatment of multiple document jobs.
+ */
+ public static final MultipleDocumentHandlingSupported SINGLE_DOCUMENT =
+ new MultipleDocumentHandlingSupported(0);
+
+ /** Supports multiple documents as uncollated copies */
+ public static final MultipleDocumentHandlingSupported SEPARATE_DOCUMENTS_UNCOLLATED_COPIES =
+ new MultipleDocumentHandlingSupported(1);
+
+ /** Supports multiple documents as collated copies */
+ public static final MultipleDocumentHandlingSupported SEPARATE_DOCUMENTS_COLLATED_COPIES =
+ new MultipleDocumentHandlingSupported(2);
+
+ /**
+ * Supports multiple documents where every single document starts
+ * with a new sheet.
+ */
+ public static final MultipleDocumentHandlingSupported SINGLE_DOCUMENT_NEW_SHEET =
+ new MultipleDocumentHandlingSupported(3);
+
+ private static final String[] stringTable = { "single-document",
+ "separate-documents-uncollated-copies",
+ "separate-documents-collated-copies",
+ "single-document-new-sheet" };
+
+ private static final MultipleDocumentHandlingSupported[] enumValueTable =
+ { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
+ SEPARATE_DOCUMENTS_COLLATED_COPIES, SINGLE_DOCUMENT_NEW_SHEET};
+
+ /**
+ * Constructs a <code>MultipleDocumentHandlingSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ protected MultipleDocumentHandlingSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MultipleDocumentHandlingSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MultipleDocumentHandlingSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "multiple-document-handling-supported".
+ */
+ public String getName()
+ {
+ return "multiple-document-handling-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public MultipleDocumentHandling getAssociatedAttribute()
+ {
+ return (MultipleDocumentHandling) IppUtilities.getEnumAttribute(
+ "multiple-document-handling", new Integer(getValue()));
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static MultipleDocumentHandling[] getAssociatedAttributeArray(Set set)
+ {
+ MultipleDocumentHandlingSupported tmp;
+ MultipleDocumentHandling[] result = new MultipleDocumentHandling[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (MultipleDocumentHandlingSupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java
new file mode 100644
index 00000000000..387e6b5131d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java
@@ -0,0 +1,118 @@
+/* MultipleDocumentJobsSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * <code>MultipleDocumentJobsSupported</code> specifies if a printer
+ * supported multiple documents in one job.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public class MultipleDocumentJobsSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ /** Multiple documents per job are not supported. */
+ public static final MultipleDocumentJobsSupported NOT_SUPPORTED =
+ new MultipleDocumentJobsSupported(0);
+
+ /** Multiple documents per job are supported. */
+ public static final MultipleDocumentJobsSupported SUPPORTED =
+ new MultipleDocumentJobsSupported(1);
+
+ private static final String[] stringTable = { "not-supported", "supported" };
+
+ private static final MultipleDocumentJobsSupported[] enumValueTable =
+ { NOT_SUPPORTED, SUPPORTED };
+
+ /**
+ * Constructs a <code>MultipleDocumentJobsSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ protected MultipleDocumentJobsSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>MultipleDocumentJobsSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return MultipleDocumentJobsSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "multiple-document-jobs-supported".
+ */
+ public String getName()
+ {
+ return "multiple-document-jobs-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java
new file mode 100644
index 00000000000..81e2e34cd05
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OperationsSupported.java
@@ -0,0 +1,230 @@
+/* OperationsSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * <code>OperationsSupported</code> specifies the enums of the operations
+ * supported by a given printer or job object. The attribute is further
+ * specified in RFC 2911 section 4.4.15.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class OperationsSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+ /*
+ * Value Operation Name
+ ----------------- -------------------------------------
+ 0x0000 reserved, not used
+ 0x0001 reserved, not used
+ 0x0002 Print-Job
+ 0x0003 Print-URI
+ 0x0004 Validate-Job
+ 0x0005 Create-Job
+ 0x0006 Send-Document
+ 0x0007 Send-URI
+ 0x0008 Cancel-Job
+ 0x0009 Get-Job-Attributes
+ 0x000A Get-Jobs
+ 0x000B Get-Printer-Attributes
+ 0x000C Hold-Job
+ 0x000D Release-Job
+ 0x000E Restart-Job
+ 0x000F reserved for a future operation
+ 0x0010 Pause-Printer
+ 0x0011 Resume-Printer
+ 0x0012 Purge-Jobs
+ 0x0013-0x3FFF reserved for future IETF standards track operations
+ 0x4000-0x8FFF reserved for vendor extensions
+ */
+
+ // standard ipp 1.1 operations
+
+ /**
+ * Operation to print a job in one request/response. */
+ public static final OperationsSupported PRINT_JOB =
+ new OperationsSupported(0x02);
+
+ /** Operation to print a document from an URI */
+ public static final OperationsSupported PRINT_URI =
+ new OperationsSupported(0x03);
+
+ /** Operation to validate a job before submission. */
+ public static final OperationsSupported VALIDATE_JOB =
+ new OperationsSupported(0x04);
+
+ /**
+ * Operation to create an initial job for use with multiple document per job.
+ */
+ public static final OperationsSupported CREATE_JOB =
+ new OperationsSupported(0x05);
+
+ /**
+ * Operation to send a document to a multidoc job created via CREATE_JOB
+ */
+ public static final OperationsSupported SEND_DOCUMENT =
+ new OperationsSupported(0x06);
+
+ /**
+ * Operation to send a document uri to a multidoc job created
+ * via CREATE_JOB. The document accessible from this URI will be printed.
+ */
+ public static final OperationsSupported SEND_URI =
+ new OperationsSupported(0x07);
+
+ /** Operation to cancel a job by its ID or name. */
+ public static final OperationsSupported CANCEL_JOB =
+ new OperationsSupported(0x08);
+
+ /** Operation to get job attributes of a current job. */
+ public static final OperationsSupported GET_JOB_ATTRIBUTES =
+ new OperationsSupported(0x09);
+
+ /** Operation to pause a printer. */
+ public static final OperationsSupported PAUSE_PRINTER =
+ new OperationsSupported(0x10);
+
+ /** Operation to get all currently queued or processed jobs. */
+ public static final OperationsSupported GET_JOBS =
+ new OperationsSupported(0x0A);
+
+ /** Operation to get the attributes of a printer. */
+ public static final OperationsSupported GET_PRINTER_ATTRIBUTES =
+ new OperationsSupported(0x0B);
+
+ /** Operation to put a job on hold by its ID or name. */
+ public static final OperationsSupported HOLD_JOB =
+ new OperationsSupported(0x0C);
+
+ /** Operation to release a job by its ID or name. */
+ public static final OperationsSupported RELEASE_JOB =
+ new OperationsSupported(0x0D);
+
+ /** Operation to restart a job by its ID or name. */
+ public static final OperationsSupported RESTART_JOB =
+ new OperationsSupported(0x0E);
+
+ /** Not yet an operation - reserved for futher use. */
+ public static final OperationsSupported RESERVED =
+ new OperationsSupported(0x0F);
+
+ /** Operation to resume a printer. */
+ public static final OperationsSupported RESUME_PRINTER =
+ new OperationsSupported(0x11);
+
+ /** Operation to remove all jobs from a printer regardless of state. */
+ public static final OperationsSupported PURGE_JOBS =
+ new OperationsSupported(0x12);
+
+
+ private static final String[] stringTable = { "print-job", "print-uri",
+ "validate-job", "create-job",
+ "send-document", "send-uri",
+ "cancel-job", "get-job-attributes",
+ "pause-printer", "get-jobs",
+ "get-printer-attributes", "hold-job",
+ "release-job", "restart-job", "reserved",
+ "resume-printer", "purge-job"};
+
+ private static final OperationsSupported[] enumValueTable =
+ { PRINT_JOB, PRINT_URI, VALIDATE_JOB, CREATE_JOB, SEND_DOCUMENT, SEND_URI,
+ CANCEL_JOB, GET_JOB_ATTRIBUTES, PAUSE_PRINTER, GET_JOBS, GET_PRINTER_ATTRIBUTES,
+ HOLD_JOB, RELEASE_JOB, RESTART_JOB, RESERVED, RESUME_PRINTER, PURGE_JOBS};
+
+
+ /**
+ * Constructs a <code>OperationsSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ protected OperationsSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>OperationsSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return OperationsSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "operations-supported".
+ */
+ public String getName()
+ {
+ return "operations-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ // we start with 2
+ protected int getOffset()
+ {
+ return 2;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java
new file mode 100644
index 00000000000..528c758ac70
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java
@@ -0,0 +1,179 @@
+/* OrientationRequestedSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.OrientationRequested;
+
+
+/**
+ * The <code>OrientationRequestedSupported</code> attribute provides
+ * the supported values for the job attribute orientation-requested.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class OrientationRequestedSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ /** Orientation as portrait. */
+ public static final OrientationRequestedSupported PORTRAIT =
+ new OrientationRequestedSupported(3);
+
+ /** Orientation as landscape. */
+ public static final OrientationRequestedSupported LANDSCAPE =
+ new OrientationRequestedSupported(4);
+
+ /** Orientation as reversed landscape. */
+ public static final OrientationRequestedSupported REVERSE_LANDSCAPE =
+ new OrientationRequestedSupported(5);
+
+ /** Orientation as reversed portrait. */
+ public static final OrientationRequestedSupported REVERSE_PORTRAIT =
+ new OrientationRequestedSupported(6);
+
+
+ private static final String[] stringTable = { "portrait", "landscape",
+ "reverse-landscape",
+ "reverse-portrait" };
+
+ private static final OrientationRequestedSupported[]
+ enumValueTable = { PORTRAIT, LANDSCAPE,
+ REVERSE_LANDSCAPE, REVERSE_PORTRAIT };
+
+ /**
+ * Constructs a <code>OrientationRequestedSupported</code> object.
+ *
+ * @param value the value
+ */
+ protected OrientationRequestedSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>OrientationRequestedSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return OrientationRequestedSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "orientation-requested-supported".
+ */
+ public String getName()
+ {
+ return "orientation-requested-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public OrientationRequested getAssociatedAttribute()
+ {
+ return (OrientationRequested) IppUtilities.getEnumAttribute(
+ "orientation-requested", new Integer(getValue()));
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static OrientationRequested[] getAssociatedAttributeArray(Set set)
+ {
+ OrientationRequestedSupported tmp;
+ OrientationRequested[] result = new OrientationRequested[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (OrientationRequestedSupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java
new file mode 100644
index 00000000000..d39a37fd708
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java
@@ -0,0 +1,117 @@
+/* PageRangesSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+
+/**
+ * <code>PageRangesSupported</code> is a boolean typed
+ * attribute indicating (as EnumSyntax) if page ranges
+ * are supported.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PageRangesSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+ /** Page ranges are not supported. */
+ public static final PageRangesSupported NOT_SUPPORTED =
+ new PageRangesSupported(0);
+
+ /** Page ranges are supported. */
+ public static final PageRangesSupported SUPPORTED =
+ new PageRangesSupported(1);
+
+ private static final String[] stringTable = { "not-supported", "supported" };
+
+ private static final PageRangesSupported[] enumValueTable = { NOT_SUPPORTED,
+ SUPPORTED };
+
+ /**
+ * Constructs a <code>PageRangesSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ protected PageRangesSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PageRangesSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PageRangesSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "page-ranges-supported".
+ */
+ public String getName()
+ {
+ return "page-ranges-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java
new file mode 100644
index 00000000000..b0f7e86735b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java
@@ -0,0 +1,171 @@
+/* PrintQualitySupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import gnu.javax.print.ipp.IppUtilities;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.PrintQuality;
+
+
+/**
+ * <code>PrintQualitySupported</code> provides the
+ * supported values for the print-quality attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrintQualitySupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+ /** Draft quality of the printer. */
+ public static final PrintQualitySupported DRAFT =
+ new PrintQualitySupported(3);
+
+ /** Normal quality of the printer. */
+ public static final PrintQualitySupported NORMAL =
+ new PrintQualitySupported(4);
+
+ /** High quality of the printer. */
+ public static final PrintQualitySupported HIGH =
+ new PrintQualitySupported(5);
+
+ private static final String[] stringTable = { "draft", "normal", "high" };
+
+ private static final PrintQualitySupported[] enumValueTable = { DRAFT,
+ NORMAL,
+ HIGH };
+
+ /**
+ * Constructs a <code>PrintQualitySupported</code> object.
+ *
+ * @param value the value of the enum
+ */
+ protected PrintQualitySupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrintQualitySupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrintQualitySupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "print-quality-supported".
+ */
+ public String getName()
+ {
+ return "print-quality-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+ /**
+ * Returns the lowest used value by the enumerations of this class.
+ * .
+ * @return The lowest value used.
+ */
+ protected int getOffset()
+ {
+ return 3;
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public PrintQuality getAssociatedAttribute()
+ {
+ return (PrintQuality) IppUtilities.getEnumAttribute(
+ "print-quality", new Integer(getValue()));
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static PrintQuality[] getAssociatedAttributeArray(Set set)
+ {
+ PrintQualitySupported tmp;
+ PrintQuality[] result = new PrintQuality[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (PrintQualitySupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java
new file mode 100644
index 00000000000..e3266c4221e
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java
@@ -0,0 +1,143 @@
+/* PrinterResolutionSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.print.attribute.ResolutionSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.standard.PrinterResolution;
+
+
+/**
+ * The <code>PrinterResolutionSupported</code> attribute provides
+ * the supported values for the job attribute printer-resolution.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterResolutionSupported extends ResolutionSyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>PrinterResolutionSupported</code> object with the
+ * given arguments.
+ *
+ * @param crossFeedResolution the cross feed resolution
+ * @param feedResolution the feed resolution
+ * @param units the unit to use (e.g. {@link #DPCM} or {@link #DPI})
+ *
+ * @exception IllegalArgumentException if preconditions fail
+ */
+ public PrinterResolutionSupported(int crossFeedResolution,
+ int feedResolution, int units)
+ {
+ super(crossFeedResolution, feedResolution, units);
+ }
+
+ /**
+ * Tests if the given object is equal to this object.
+ *
+ * @param obj the object to test
+ *
+ * @return <code>true</code> if both objects are equal,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if(! (obj instanceof PrinterResolutionSupported))
+ return false;
+
+ return super.equals(obj);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterResolutionSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterResolutionSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-resolution-supported".
+ */
+ public String getName()
+ {
+ return "printer-resolution-supported";
+ }
+
+ /**
+ * Returns the equally enum of the standard attribute class
+ * of this SupportedValuesAttribute enum.
+ *
+ * @return The enum of the standard attribute class.
+ */
+ public PrinterResolution getAssociatedAttribute()
+ {
+ return new PrinterResolution(getCrossFeedResolutionDphi(),
+ getFeedResolutionDphi(), 1);
+ }
+
+ /**
+ * Constructs an array from a set of -supported attributes.
+ * @param set set to process
+ * @return The constructed array.
+ *
+ * @see #getAssociatedAttribute()
+ */
+ public static PrinterResolution[] getAssociatedAttributeArray(Set set)
+ {
+ PrinterResolutionSupported tmp;
+ PrinterResolution[] result = new PrinterResolution[set.size()];
+ Iterator it = set.iterator();
+ int j = 0;
+ while (it.hasNext())
+ {
+ tmp = (PrinterResolutionSupported) it.next();
+ result[j] = tmp.getAssociatedAttribute();
+ j++;
+ }
+ return result;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java
new file mode 100644
index 00000000000..ce3e2a7d6c4
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java
@@ -0,0 +1,88 @@
+/* PrinterUriSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import java.net.URI;
+
+import javax.print.attribute.SupportedValuesAttribute;
+import javax.print.attribute.URISyntax;
+
+/**
+ * PrinterUriSupported attribute as described in RFC 2911 section
+ * 4.4.1 contains one of the URIs the printer supported for
+ * job processing (e.g. one with authentication).
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class PrinterUriSupported extends URISyntax
+ implements SupportedValuesAttribute
+{
+
+ /**
+ * Creates a <code>PrinterUriSupported</code> object.
+ *
+ * @param uri the URI value for the syntax
+ * @throws NullPointerException if uri is null
+ */
+ public PrinterUriSupported(URI uri)
+ {
+ super(uri);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>PrinterUriSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return PrinterUriSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "printer-uri-supported".
+ */
+ public String getName()
+ {
+ return "printer-uri-supported";
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java
new file mode 100644
index 00000000000..5110e95934b
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/SidesSupported.java
@@ -0,0 +1,136 @@
+/* SidesSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+
+/**
+ * <code>SidesSupported</code> provides the
+ * supported values for the sides attribute.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class SidesSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ /** Specifies that each page should be printed on one sheet. */
+ public static final SidesSupported ONE_SIDED = new SidesSupported(0);
+
+ /**
+ * Specifies that two following pages should be printed on the
+ * front and back of one sheet for binding on the long edge.
+ */
+ public static final SidesSupported TWO_SIDED_LONG_EDGE =
+ new SidesSupported(1);
+
+ /**
+ * Specifies that two following pages should be printed on the
+ * front and back of one sheet for binding on the short edge.
+ */
+ public static final SidesSupported TWO_SIDED_SHORT_EDGE =
+ new SidesSupported(2);
+
+ /** An alias constant for "two sided long edge". */
+ public static final SidesSupported DUPLEX = new SidesSupported(1);
+
+ /** An alias constant for "two sided short edge". */
+ public static final SidesSupported TUMBLE = new SidesSupported(2);
+
+ private static final String[] stringTable = { "one-sided",
+ "two-sided-long-edge",
+ "two-sided-short-edge" };
+
+ private static final SidesSupported[]
+ enumValueTable = { ONE_SIDED, TWO_SIDED_LONG_EDGE,
+ TWO_SIDED_SHORT_EDGE };
+
+
+ /**
+ * Creates a <code>SidesSupported</code> object.
+ *
+ * @param value the value of the enum
+ */
+ protected SidesSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>SidesSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return SidesSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "sides-supported".
+ */
+ public String getName()
+ {
+ return "sides-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java
new file mode 100644
index 00000000000..8deac7a2f63
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java
@@ -0,0 +1,141 @@
+/* UriAuthenticationSupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * UriAuthenticationSupported attribute as described in RFC 2911 section
+ * 4.4.2 provides the keywords (implemented as EnumSyntax) which
+ * authentication methods are supported by the printer object. This
+ * includes a value of none.
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class UriAuthenticationSupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ // a keyword based attribute in IPP - int values just starting at 0
+
+ /** Supports no authentication - assumes anonymous process */
+ public static final UriAuthenticationSupported NONE =
+ new UriAuthenticationSupported(0);
+
+ /**
+ * The authenticated user assumed is the value of the
+ * "requesting-user-name" operation attribute supplied
+ * with the operation.
+ */
+ public static final UriAuthenticationSupported REQUESTING_USER_NAME =
+ new UriAuthenticationSupported(1);
+
+ /** Supports HTTP basic authentication (RFC 2617) */
+ public static final UriAuthenticationSupported BASIC =
+ new UriAuthenticationSupported(2);
+
+ /** Supports HTTP digest authentication (RFC 2617) */
+ public static final UriAuthenticationSupported DIGEST =
+ new UriAuthenticationSupported(3);
+
+ /** Supports authentication through a client provided certificate */
+ public static final UriAuthenticationSupported CERTIFICATE =
+ new UriAuthenticationSupported(4);
+
+ private static final String[] stringTable = { "none",
+ "requesting-user-name",
+ "basic", "digest",
+ "certificate" };
+
+ private static final UriAuthenticationSupported[] enumValueTable =
+ { NONE, REQUESTING_USER_NAME, BASIC, DIGEST, CERTIFICATE };
+
+ /**
+ * Constructs a <code>UriAuthenticationSupported</code> object.
+ *
+ * @param value the enum value
+ */
+ public UriAuthenticationSupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>UriAuthenticationSupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return UriAuthenticationSupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "uri-authentication-supported".
+ */
+ public String getName()
+ {
+ return "uri-authentication-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java
new file mode 100644
index 00000000000..1d995184d2d
--- /dev/null
+++ b/libjava/classpath/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java
@@ -0,0 +1,126 @@
+/* UriSecuritySupported.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.print.ipp.attribute.supported;
+
+import javax.print.attribute.EnumSyntax;
+import javax.print.attribute.SupportedValuesAttribute;
+
+/**
+ * UriSecuritySupported attribute as described in RFC 2911 section
+ * 4.4.3 provides the keywords (implemented as EnumSyntax) for
+ * the security mechanisms supported by the corresponding uri's
+ * supported (same place in setOf).
+ *
+ * @author Wolfgang Baer (WBaer@gmx.de)
+ */
+public final class UriSecuritySupported extends EnumSyntax
+ implements SupportedValuesAttribute
+{
+
+ // a keyword based attribute in IPP - int values just starting at 0
+
+ /** The URI has no secure communication */
+ public static final UriSecuritySupported NONE =
+ new UriSecuritySupported(0);
+
+ /** The URI has SSL3 communication */
+ public static final UriSecuritySupported SSL3 =
+ new UriSecuritySupported(1);
+
+ /** The URI has TLS (RFC 2246) communication */
+ public static final UriSecuritySupported TLS =
+ new UriSecuritySupported(2);
+
+ private static final String[] stringTable = { "none", "ssl3", "tls" };
+
+ private static final UriSecuritySupported[] enumValueTable = { NONE,
+ SSL3, TLS };
+
+ /**
+ * Constructs a <code>UriSecuritySupported</code> object.
+ *
+ * @param value the enum value
+ */
+ public UriSecuritySupported(int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Returns category of this class.
+ *
+ * @return The class <code>UriSecuritySupported</code> itself.
+ */
+ public Class getCategory()
+ {
+ return UriSecuritySupported.class;
+ }
+
+ /**
+ * Returns the name of this attribute.
+ *
+ * @return The name "uri-security-supported".
+ */
+ public String getName()
+ {
+ return "uri-security-supported";
+ }
+
+ /**
+ * Returns a table with the enumeration values represented as strings
+ * for this object.
+ *
+ * @return The enumeration values as strings.
+ */
+ protected String[] getStringTable()
+ {
+ return stringTable;
+ }
+
+ /**
+ * Returns a table with the enumeration values for this object.
+ *
+ * @return The enumeration values.
+ */
+ protected EnumSyntax[] getEnumValueTable()
+ {
+ return enumValueTable;
+ }
+
+}
diff --git a/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java b/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
index 4ce22cb3033..052b6c43d73 100644
--- a/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
+++ b/libjava/classpath/gnu/javax/security/auth/callback/ConsoleCallbackHandler.java
@@ -157,7 +157,8 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
if (c.getPrompt() != null)
- out.println(c.getPrompt());
+ out.print(c.getPrompt());
+
String[] choices = null;
int[] values = null;
switch (c.getOptionType())
@@ -175,6 +176,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
ConfirmationCallback.OK, ConfirmationCallback.CANCEL
};
break;
+
case ConfirmationCallback.YES_NO_CANCEL_OPTION:
out.print(messages.getString("callback.yesNoCancel"));
choices = new String[] {
@@ -191,19 +193,26 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
ConfirmationCallback.NO, ConfirmationCallback.CANCEL
};
break;
+
case ConfirmationCallback.YES_NO_OPTION:
out.print(messages.getString("callback.yesNo"));
- choices = new String[] {
- messages.getString("callback.yes"),
- messages.getString("callback.no"),
- messages.getString("callback.shortYes"),
- messages.getString("callback.shortNo")
- };
- values = new int[] {
- ConfirmationCallback.YES, ConfirmationCallback.NO,
- ConfirmationCallback.YES, ConfirmationCallback.NO
- };
+ choices = new String[] { messages.getString("callback.yes"),
+ messages.getString("callback.no"),
+ messages.getString("callback.shortYes"),
+ messages.getString("callback.shortNo") };
+ values = new int[] { ConfirmationCallback.YES,
+ ConfirmationCallback.NO,
+ ConfirmationCallback.YES,
+ ConfirmationCallback.NO };
+ int defaultOption = c.getDefaultOption();
+ if (defaultOption > -1 && defaultOption < choices.length)
+ {
+ out.print("[");
+ out.print(choices[defaultOption]);
+ out.print("] ");
+ }
break;
+
case ConfirmationCallback.UNSPECIFIED_OPTION:
choices = c.getOptions();
values = new int[choices.length];
@@ -220,6 +229,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
out.print(choices[c.getDefaultOption()]);
out.print("] ");
break;
+
default:
throw new IllegalArgumentException();
}
@@ -242,7 +252,7 @@ public class ConsoleCallbackHandler extends AbstractCallbackHandler
protected void handleLanguage(LanguageCallback c) throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- out.println(messages.getString("callback.language"));
+ out.print(messages.getString("callback.language"));
String reply = null;
reply = in.readLine();
if (reply == null)
diff --git a/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
new file mode 100644
index 00000000000..67d6332df58
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java
@@ -0,0 +1,265 @@
+/* GNULookAndFeel.java -- An example of using the javax.swing UI.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.javax.swing.plaf.gnu;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JCheckBox;
+import javax.swing.JRadioButton;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.IconUIResource;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+public class GNULookAndFeel extends BasicLookAndFeel
+{
+
+ static Color blueGray = new Color(0xdc, 0xda, 0xd5);
+
+ public boolean isNativeLookAndFeel() { return true; }
+ public boolean isSupportedLookAndFeel() { return true; }
+ public String getDescription() { return "GNU Look and Feel"; }
+ public String getID() { return "GNULookAndFeel"; }
+ public String getName() { return "GNU"; }
+
+ static UIDefaults LAF_defaults;
+
+ private final static String iconspath = "/gnu/javax/swing/plaf/gtk/icons/";
+
+ public UIDefaults getDefaults()
+ {
+ if (LAF_defaults == null)
+ {
+ LAF_defaults = super.getDefaults();
+ Object[] myDefaults = new Object[] {
+ "Button.background", new ColorUIResource(blueGray),
+ "CheckBox.background", new ColorUIResource(blueGray),
+ "CheckBoxMenuItem.background", new ColorUIResource(blueGray),
+ "ToolBar.background", new ColorUIResource(blueGray),
+ "Panel.background", new ColorUIResource(blueGray),
+ "Slider.background", new ColorUIResource(blueGray),
+ "OptionPane.background", new ColorUIResource(blueGray),
+ "ProgressBar.background", new ColorUIResource(blueGray),
+ "TabbedPane.background", new ColorUIResource(blueGray),
+ "Label.background", new ColorUIResource(blueGray),
+ "Menu.background", new ColorUIResource(blueGray),
+ "MenuBar.background", new ColorUIResource(blueGray),
+ "MenuItem.background", new ColorUIResource(blueGray),
+ "ScrollBar.background", new ColorUIResource(blueGray),
+ "CheckBox.icon", new CheckBoxIcon(),
+ "RadioButton.icon", new RadioButtonIcon(),
+
+ "Tree.closedIcon",
+ new IconUIResource(new ImageIcon
+ (getClass().getResource
+ (iconspath + "TreeClosed.png"))),
+ "Tree.leafIcon",
+ new IconUIResource(new ImageIcon
+ (getClass().getResource
+ (iconspath + "TreeLeaf.png"))),
+ "Tree.openIcon",
+ new IconUIResource(new ImageIcon
+ (getClass().getResource
+ (iconspath + "TreeOpen.png"))),
+ };
+ LAF_defaults.putDefaults(myDefaults);
+ }
+ return LAF_defaults;
+ }
+
+ /**
+ * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class CheckBoxIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel CheckBox icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel CheckBox icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color save = g.getColor();
+ g.setColor(c.getForeground());
+ g.drawRect(x, y, getIconWidth(), getIconHeight());
+
+ JCheckBox item = (JCheckBox) c;
+ if (item.isSelected())
+ {
+ g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+ g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+ g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+ g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+ }
+
+ g.setColor(save);
+ }
+ }
+
+ /**
+ * The icon used for RadioButtons in the GNULookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class RadioButtonIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The GNULookAndFeel RadioButton icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The GNULookAndFeel RadioButton icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The GNULookAndFeel RadioButton icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ JRadioButton b = (JRadioButton) c;
+
+ // draw outer circle
+ if (b.isEnabled())
+ g.setColor(Color.GRAY);
+ else
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 2, y + 1, x + 3, y + 1);
+ g.drawLine(x + 4, y, x + 7, y);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+ g.drawLine(x + 10, y + 2, x + 10, y + 3);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+ g.drawLine(x + 10, y + 8, x + 10, y + 9);
+ g.drawLine(x + 8, y + 10, x + 9, y + 10);
+ g.drawLine(x + 4, y + 11, x + 7, y + 11);
+ g.drawLine(x + 2, y + 10, x + 3, y + 10);
+ g.drawLine(x + 1, y + 9, x + 1, y + 8);
+ g.drawLine(x, y + 7, x, y + 4);
+ g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+ if (b.getModel().isArmed())
+ {
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 4, y + 10, x + 7, y + 10);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 10, y + 4, x + 10, y + 7);
+ g.fillRect(x + 2, y + 2, 8, 8);
+ }
+ else
+ {
+ // only draw inner highlight if not filled
+ if (b.isEnabled())
+ {
+ g.setColor(Color.WHITE);
+
+ g.drawLine(x + 2, y + 8, x + 2, y + 9);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 3);
+ g.drawLine(x + 3, y + 2, x + 3, y + 2);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 9, y + 2);
+ }
+ }
+
+ // draw outer highlight
+ if (b.isEnabled())
+ {
+ g.setColor(Color.WHITE);
+
+ // outer
+ g.drawLine(x + 10, y + 1, x + 10, y + 1);
+ g.drawLine(x + 11, y + 2, x + 11, y + 3);
+ g.drawLine(x + 12, y + 4, x + 12, y + 7);
+ g.drawLine(x + 11, y + 8, x + 11, y + 9);
+ g.drawLine(x + 10, y + 10, x + 10, y + 10);
+ g.drawLine(x + 8, y + 11, x + 9, y + 11);
+ g.drawLine(x + 4, y + 12, x + 7, y + 12);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ }
+
+ if (b.isSelected())
+ {
+ if (b.isEnabled())
+ g.setColor(Color.BLACK);
+ else
+ g.setColor(Color.GRAY);
+ g.drawLine(x + 4, y + 3, x + 7, y + 3);
+ g.fillRect(x + 3, y + 4, 6, 4);
+ g.drawLine(x + 4, y + 8, x + 7, y + 8);
+ }
+ g.setColor(savedColor);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java b/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java
new file mode 100644
index 00000000000..7dbf6e12a50
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java
@@ -0,0 +1,218 @@
+/* CustomizableTheme.java -- A customizable metal theme
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.plaf.metal;
+
+import java.awt.Color;
+
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+
+/**
+ * A Metal theme that can be customized by setting the primary and secondary
+ * colors.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class CustomizableTheme
+ extends DefaultMetalTheme
+ implements Cloneable
+{
+
+ /**
+ * The primary1 color.
+ */
+ private ColorUIResource primary1;
+
+ /**
+ * The primary2 color.
+ */
+ private ColorUIResource primary2;
+
+ /**
+ * The primary3 color.
+ */
+ private ColorUIResource primary3;
+
+ /**
+ * The secondary1 color.
+ */
+ private ColorUIResource secondary1;
+
+ /**
+ * The secondary2 color.
+ */
+ private ColorUIResource secondary2;
+
+ /**
+ * The secondary3 color.
+ */
+ private ColorUIResource secondary3;
+
+ /**
+ * Sets the primary1 color of the theme.
+ *
+ * @param c the primary1 color to set
+ */
+ public void setPrimary1(Color c)
+ {
+ primary1 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the primary1 color of this theme.
+ *
+ * @return the primary1 color of this theme
+ */
+ public ColorUIResource getPrimary1()
+ {
+ return primary1 == null ? super.getPrimary1() : primary1;
+ }
+
+
+ /**
+ * Sets the primary2 color of the theme.
+ *
+ * @param c the primary2 color to set
+ */
+ public void setPrimary2(Color c)
+ {
+ primary2 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the primary2 color of this theme.
+ *
+ * @return the primary2 color of this theme
+ */
+ public ColorUIResource getPrimary2()
+ {
+ return primary2 == null ? super.getPrimary2() : primary2;
+ }
+
+ /**
+ * Sets the primary3 color of the theme.
+ *
+ * @param c the primary3 color to set
+ */
+ public void setPrimary3(Color c)
+ {
+ primary3 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the primary3 color of this theme.
+ *
+ * @return the primary3 color of this theme
+ */
+ public ColorUIResource getPrimary3()
+ {
+ return primary3 == null ? super.getPrimary3() : primary3;
+ }
+
+ /**
+ * Sets the secondary1 color of the theme.
+ *
+ * @param c the secondary1 color to set
+ */
+ public void setSecondary1(Color c)
+ {
+ secondary1 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the secondary1 color of this theme.
+ *
+ * @return the secondary1 color of this theme
+ */
+ public ColorUIResource getSecondary1()
+ {
+ return secondary1 == null ? super.getSecondary1() : secondary1;
+ }
+
+ /**
+ * Sets the secondary2 color of the theme.
+ *
+ * @param c the secondary2 color to set
+ */
+ public void setSecondary2(Color c)
+ {
+ secondary2 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the secondary2 color of this theme.
+ *
+ * @return the secondary2 color of this theme
+ */
+ public ColorUIResource getSecondary2()
+ {
+ return secondary2 == null ? super.getSecondary2() : secondary2;
+ }
+
+ /**
+ * Sets the secondary3 color of the theme.
+ *
+ * @param c the secondary3 color to set
+ */
+ public void setSecondary3(Color c)
+ {
+ secondary3 = new ColorUIResource(c);
+ }
+
+ /**
+ * Returns the secondary3 color of this theme.
+ *
+ * @return the secondary3 color of this theme
+ */
+ public ColorUIResource getSecondary3()
+ {
+ return secondary3 == null ? super.getSecondary3() : secondary3;
+ }
+
+ /**
+ * Returns a clone of this theme.
+ *
+ * @return a clone of this theme
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ return super.clone();
+ }
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java b/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java
index cef94942e16..92f9b27c5d9 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java
+++ b/libjava/classpath/gnu/javax/swing/text/html/parser/support/Parser.java
@@ -934,7 +934,7 @@ public class Parser
optional(WS);
attributeReading:
- while (getTokenAhead().kind == NUMTOKEN)
+ while (getTokenAhead().kind == NUMTOKEN)
{
name = getNextToken();
optional(WS);
@@ -949,46 +949,90 @@ public class Parser
switch (next.kind)
{
- case QUOT :
-
- // read "quoted" attribute.
- buffer.setLength(0);
- readTillTokenE(QUOT);
- attrValue = buffer.toString();
- break;
-
- case AP :
-
- // read 'quoted' attribute.
- buffer.setLength(0);
- readTillTokenE(AP);
- attrValue = buffer.toString();
- break;
-
- // read unquoted attribute.
- case NUMTOKEN :
- value = next;
- optional(WS);
-
- // Check maybe the opening quote is missing.
- next = getTokenAhead();
- if (bQUOTING.get(next.kind))
- {
- hTag = next;
- error("The value without opening quote is closed with '" +
- next.getImage() + "'"
- );
- }
+ case QUOT:
+
+ // read "quoted" attribute.
+ buffer.setLength(0);
+ readTillTokenE(QUOT);
+ attrValue = buffer.toString();
+ break;
+
+ case AP:
+
+ // read 'quoted' attribute.
+ buffer.setLength(0);
+ readTillTokenE(AP);
+ attrValue = buffer.toString();
+ break;
+
+ // read unquoted attribute.
+ case NUMTOKEN:
+ value = next;
+ optional(WS);
+
+ // Check maybe the opening quote is missing.
+ next = getTokenAhead();
+ if (bQUOTING.get(next.kind))
+ {
+ hTag = next;
+ error("The value without opening quote is closed with '"
+ + next.getImage() + "'");
+ attrValue = value.getImage();
+ }
+ else if (next.kind == SLASH)
+ // The slash in this context is treated as the ordinary
+ // character, not as a token. The slash may be part of
+ // the unquoted URL.
+ {
+ StringBuffer image = new StringBuffer(value.getImage());
+ while (next.kind == NUMTOKEN || next.kind == SLASH)
+ {
+ image.append(getNextToken().getImage());
+ next = getTokenAhead();
+ }
+ attrValue = image.toString();
+ }
+ else
attrValue = value.getImage();
- break;
-
- default :
- break attributeReading;
+ break;
+
+ case SLASH:
+ value = next;
+ optional(WS);
+
+ // Check maybe the opening quote is missing.
+ next = getTokenAhead();
+ if (bQUOTING.get(next.kind))
+ {
+ hTag = next;
+ error("The value without opening quote is closed with '"
+ + next.getImage() + "'");
+ attrValue = value.getImage();
+ }
+ else if (next.kind == NUMTOKEN || next.kind == SLASH)
+ // The slash in this context is treated as the ordinary
+ // character, not as a token. The slash may be part of
+ // the unquoted URL.
+ {
+ StringBuffer image = new StringBuffer(value.getImage());
+ while (next.kind == NUMTOKEN || next.kind == SLASH)
+ {
+ image.append(getNextToken().getImage());
+ next = getTokenAhead();
+ }
+ attrValue = image.toString();
+ }
+ else
+ attrValue = value.getImage();
+ break;
+ default:
+ break attributeReading;
}
attributes.addAttribute(name.getImage(), attrValue);
optional(WS);
}
- else // The '=' is missing: attribute without value.
+ else
+ // The '=' is missing: attribute without value.
{
noValueAttribute(element, name.getImage());
}
@@ -996,9 +1040,8 @@ public class Parser
}
/**
- * Return string, corresponding the given named entity.
- * The name is passed with the preceeding &, but without
- * the ending semicolon.
+ * Return string, corresponding the given named entity. The name is passed
+ * with the preceeding &, but without the ending semicolon.
*/
protected String resolveNamedEntity(final String a_tag)
{
diff --git a/libjava/classpath/gnu/javax/swing/tree/GnuPath.java b/libjava/classpath/gnu/javax/swing/tree/GnuPath.java
new file mode 100644
index 00000000000..dd576e8d3e9
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/tree/GnuPath.java
@@ -0,0 +1,65 @@
+/* GnuPath.java -- The extended version of TreePath
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.swing.tree;
+
+import javax.swing.tree.TreePath;
+
+/**
+ * The tree path with additional data. Needed for the optimized tree drawing.
+ * Returned by layout caches.
+ *
+ * @author Audrius Meskauskas
+ */
+public class GnuPath extends TreePath
+{
+ /**
+ * The flag, marking the last visible child.
+ */
+ public boolean isLastChild;
+
+ /**
+ * Create a new path, specifying flag if this path is the path to the
+ * last visible child (needed for optimized tree drawing).
+ */
+ public GnuPath(Object[] path, boolean lastChild)
+ {
+ super(path);
+ isLastChild = lastChild;
+ }
+}
OpenPOWER on IntegriCloud