harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r454289 [5/22] - in /incubator/harmony/enhanced/classlib/trunk/modules/H-1609: ./ modules/ modules/applet/ modules/applet/src/ modules/applet/src/main/ modules/applet/src/main/java/ modules/applet/src/main/java/java/ modules/applet/src/main...
Date Mon, 09 Oct 2006 05:33:21 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/JpegEncoder.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/JpegEncoder.c?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/JpegEncoder.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/JpegEncoder.c Sun Oct  8 22:33:09 2006
@@ -0,0 +1,461 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ * @author Rustem Rafikov
+ * @version $Revision: 1.2 $
+ */
+
+#include <string.h>
+#include <malloc.h>
+#include <assert.h>
+
+#include "org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h"
+#include "jpeglib.h"
+#include "jpegint.h"
+#include "setjmp.h"
+
+#include "Exceptions.h"
+
+#define MAX_BUFFER 32768
+
+
+typedef struct {
+    struct jpeg_error_mgr base;
+    jmp_buf jmp_buffer;
+} enc_error_mgr, * enc_error_mgr_ptr;
+
+typedef struct {
+  JOCTET *jpeg_buffer;
+  jobject ios;
+} enc_client_data, * enc_client_data_ptr;
+
+
+static jmethodID IOSwriteID;
+static jmethodID getScanlineID;
+static jmethodID QTableGetTableID;
+
+JavaVM *jvm;
+
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
+    jvm = vm;
+    return JNI_VERSION_1_2;
+}
+
+static JNIEnv* get_env() {
+    JNIEnv *e;
+    int rt = (*jvm)->GetEnv(jvm, (void **)&e, JNI_VERSION_1_2);
+    return e;
+}
+
+/**
+ * Sets DQT tables
+ */
+static void setupDQTs(JNIEnv *env, j_compress_ptr cinfo, jobjectArray dqts) {
+
+    JQUANT_TBL *quant_ptr;
+    jint len;
+    int i, j;
+    jobject slot;
+    jint *arrPtr;
+
+    if (!dqts)  {
+        //-- TODO: write warning
+        return;
+    }
+
+    len = (*env)->GetArrayLength(env, dqts);
+
+    for (i = 0; i < len; i++) {
+        slot = (*env)->GetObjectArrayElement(env, dqts, i);
+        arrPtr = (*env)->GetPrimitiveArrayCritical(env, slot, NULL);
+
+        if (cinfo->quant_tbl_ptrs[i] == NULL) {
+            cinfo->quant_tbl_ptrs[i] = jpeg_alloc_quant_table((j_common_ptr)cinfo);
+        }
+        quant_ptr = cinfo->quant_tbl_ptrs[i];
+
+        for (j = 0; j < 64; j++) {
+            quant_ptr->quantval[j] = arrPtr[j];
+        }
+        quant_ptr->sent_table = FALSE;
+        (*env)->ReleasePrimitiveArrayCritical(env, slot, arrPtr, 0);
+    }
+}
+
+/*
+ * Initialize destination --- called by jpeg_start_compress
+ * before any data is actually written.
+ */
+METHODDEF(void) ios_init_destination(j_compress_ptr cinfo) {
+}
+
+/**
+ * Called when output buffer becomes filled
+ */
+METHODDEF(boolean) ios_empty_output_buffer(j_compress_ptr cinfo) {
+
+    struct jpeg_compress_struct * cs;
+    enc_client_data_ptr cdata;
+    enc_error_mgr_ptr err_mgr;
+
+    jbyteArray java_buffer;
+    JOCTET *native_buffer;
+    JNIEnv *env;
+
+    cs = (struct jpeg_compress_struct *) cinfo;
+    cdata = (enc_client_data_ptr) cs->client_data;
+    err_mgr = (enc_error_mgr_ptr) cs->err;
+
+    env = get_env();
+    java_buffer = (*env)->NewByteArray(env, MAX_BUFFER);
+    native_buffer = (JOCTET *)(*env)->GetPrimitiveArrayCritical(env, java_buffer, NULL);
+    memcpy(native_buffer, cdata->jpeg_buffer, MAX_BUFFER);
+    (*env)->ReleasePrimitiveArrayCritical(env, java_buffer, native_buffer, 0);
+    (*env)->CallVoidMethod(env, cdata->ios, IOSwriteID, java_buffer, 0, MAX_BUFFER);
+
+    // checking for an exception in the java method
+    if ((*env)->ExceptionOccurred(env)) {
+        err_mgr->base.error_exit((j_common_ptr) cinfo);
+    }
+    
+    cs->dest->next_output_byte = cdata->jpeg_buffer;
+    cs->dest->free_in_buffer = MAX_BUFFER;
+    
+    return TRUE;
+}
+
+/*
+ * Terminate destination --- called by jpeg_finish_compress
+ */
+METHODDEF(void) ios_term_destination(j_compress_ptr cinfo) {
+
+
+    struct jpeg_compress_struct * cs;
+    enc_client_data_ptr cdata;
+    enc_error_mgr_ptr err_mgr;
+
+    jbyteArray java_buffer;
+    JOCTET *native_buffer;
+    JNIEnv *env;
+
+    cs = (struct jpeg_compress_struct *) cinfo;
+    cdata = (enc_client_data_ptr) cs->client_data;
+    err_mgr = (enc_error_mgr_ptr) cs->err;
+
+    env = get_env();
+    java_buffer = (*env)->NewByteArray(env, MAX_BUFFER);
+    native_buffer = (JOCTET *)(*env)->GetPrimitiveArrayCritical(env, java_buffer, NULL);
+    memcpy(native_buffer, cdata->jpeg_buffer, MAX_BUFFER);
+    (*env)->ReleasePrimitiveArrayCritical(env, java_buffer, native_buffer, 0);
+    (*env)->CallVoidMethod(env, cdata->ios, IOSwriteID, java_buffer, 0, MAX_BUFFER - cs->dest->free_in_buffer);
+
+    // checking for an exception in the java method
+    if ((*env)->ExceptionOccurred(env)) {
+        err_mgr->base.error_exit((j_common_ptr) cinfo);
+    }
+
+    cs->dest->next_output_byte = NULL;
+    cs->dest->free_in_buffer = 0;
+}
+
+/** 
+ * The error handler
+ */
+METHODDEF(void) ios_jpeg_error_exit(j_common_ptr cinfo) {
+    enc_error_mgr_ptr err_mgr = (enc_error_mgr_ptr) cinfo->err;
+#ifdef DEBUG
+    printf("in jpeg_error_exit()\n");
+#endif //-- DEBUG
+    longjmp(err_mgr->jmp_buffer, 1);
+}
+
+/**
+ * It is called from initCompressionObjects
+ */
+//GLOBAL(CompressStruct*) ios_create_compress(JNIEnv *env) {
+GLOBAL(struct jpeg_compress_struct *) ios_create_compress(JNIEnv *env) {
+
+    struct jpeg_compress_struct * cinfo;
+    struct jpeg_destination_mgr * dest_mgr;
+
+    enc_error_mgr_ptr err_mgr;
+    enc_client_data_ptr client_data;
+
+    //-- create compress struct
+    cinfo = malloc(sizeof(struct jpeg_compress_struct));
+    if (!cinfo) {
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return 0;
+    }
+
+    //-- create error manager
+    err_mgr = malloc(sizeof(enc_error_mgr));
+    if (!err_mgr) {
+        free(cinfo);
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return 0;
+    }
+    
+
+    cinfo->err = jpeg_std_error(&(err_mgr->base));
+    err_mgr->base.error_exit = ios_jpeg_error_exit;
+
+
+    //-- TODO setjmp before every call to libjpeg
+    jpeg_create_compress(cinfo);
+
+    dest_mgr = malloc(sizeof(struct jpeg_destination_mgr));
+    if (!dest_mgr) {
+        free(cinfo);
+        free(err_mgr);
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return 0;
+    }
+    cinfo->dest = dest_mgr;
+
+    client_data = malloc(sizeof(enc_client_data));
+
+    if (!client_data) {
+        free(cinfo);
+        free(err_mgr);
+        free(dest_mgr);
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return 0;
+    }
+    cinfo->client_data = client_data;
+    client_data->ios = NULL;
+    client_data->jpeg_buffer = malloc(MAX_BUFFER);
+    if (!client_data->jpeg_buffer) {
+        free(cinfo);
+        free(err_mgr);
+        free(dest_mgr);
+        free(client_data);
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return 0;
+    }
+    dest_mgr->next_output_byte = client_data->jpeg_buffer;
+    dest_mgr->free_in_buffer = MAX_BUFFER;
+
+    dest_mgr->init_destination = ios_init_destination;
+    dest_mgr->empty_output_buffer = ios_empty_output_buffer;
+    dest_mgr->term_destination = ios_term_destination;
+    
+    return cinfo;
+}
+
+/*
+ * Class:     org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter
+ * Method:    dispose
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_dispose(JNIEnv *env, jobject obj, jlong handle) {
+
+    struct jpeg_compress_struct * cinfo = (struct jpeg_compress_struct *) handle;
+    enc_client_data_ptr cdata = (enc_client_data_ptr) cinfo->client_data;
+
+    if (cdata->ios != NULL) {
+        (*env)->DeleteGlobalRef(env, cdata->ios);
+        cdata->ios = NULL;
+    }
+    if (cdata->jpeg_buffer != NULL) {
+        free(cdata->jpeg_buffer);
+    }
+    
+    free(cinfo->dest);
+    free(cinfo->client_data);
+    free(cinfo->err);
+
+    jpeg_destroy_compress(cinfo);
+    free(cinfo);
+}
+
+/*
+ * Class:     org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter
+ * Method:    initWriterIds
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_initWriterIds(JNIEnv *env, jclass encoderClass, jclass iosClass) {
+
+    //-- ImageOutputStream.write(byte[], int, int)
+    IOSwriteID = (*env)->GetMethodID(env, iosClass, "write", "([BII)V");
+    //-- call back to getScanLine(int);
+    getScanlineID = (*env)->GetMethodID(env, encoderClass, "getScanLine", "(I)V");
+
+    //-- init jvm var
+    (*env)->GetJavaVM(env, &jvm);
+}
+
+/*
+ * Class:     org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter
+ * Method:    initCompressionObj
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL 
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_initCompressionObj(JNIEnv *env, jobject encoder) {
+    return (jlong) ios_create_compress(env);
+}
+
+/*
+ * Class:     org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter
+ * Method:    setIOS
+ * Signature: (Ljavax/imageio/stream/ImageOutputStream;J)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_setIOS(JNIEnv *env, jobject encoder, jobject iosObj, jlong handle) {
+
+    struct jpeg_compress_struct * cinfo = (struct jpeg_compress_struct *) handle;
+    enc_client_data_ptr cdata = (enc_client_data_ptr) cinfo->client_data;
+
+    if (cdata->ios != NULL) {
+        (*env)->DeleteGlobalRef(env, cdata->ios);
+        cdata->ios = NULL;
+    }
+    cdata->ios = (*env)->NewGlobalRef(env, iosObj);
+    if (cdata->ios == NULL) {
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return;
+    }
+    cinfo->dest->next_output_byte = cdata->jpeg_buffer;
+    cinfo->dest->free_in_buffer = MAX_BUFFER;
+}
+
+
+/*
+ * Class:     org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter
+ * Method:    encode
+ * Signature: ([BIIIIIIIZ[[IJ)Z
+ */
+JNIEXPORT jboolean JNICALL 
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_encode(JNIEnv *env, 
+    jobject callerObj, jbyteArray arr, jint srcWidth, jint width, jint height, jint deltaX, 
+    jint in_cs, jint out_cs, jint numBands, jboolean progressive, jobjectArray dqts, jlong handle) 
+{
+
+    JSAMPROW row_pointer;
+    struct jpeg_compress_struct * cinfo;
+    enc_error_mgr_ptr err_mgr;
+    
+    int i, j;
+    int cur_scanline;
+    unsigned char * native_buffer;
+    unsigned char * rowPtr;
+
+    jboolean optimizeHuffman = FALSE;
+
+    row_pointer = (JSAMPROW) malloc(width * numBands);
+
+    if (!row_pointer) {
+        newExceptionByName(env, "java/lang/OutOfMemoryError", "Unable to allocate memory for IJG structures");
+        return FALSE;
+    }
+
+    
+    cinfo = (struct jpeg_compress_struct *) handle;
+    err_mgr = (enc_error_mgr_ptr) cinfo->err;
+
+    if (setjmp(err_mgr->jmp_buffer)) {
+        if (!(*env)->ExceptionOccurred(env)) {
+            char msg_buffer[JMSG_LENGTH_MAX];
+            cinfo->err->format_message(cinfo, msg_buffer);
+            newExceptionByName(env, "javax/imageio/IIOException", msg_buffer);
+        }
+        if (row_pointer) {
+            free(row_pointer);
+        }
+        return FALSE;
+    }
+
+    cinfo->image_width = width;
+    cinfo->image_height = height;
+    cinfo->input_components = numBands;
+    cinfo->in_color_space = in_cs;
+    
+    jpeg_set_defaults(cinfo);
+    jpeg_set_colorspace(cinfo, out_cs);
+    cinfo->optimize_coding = optimizeHuffman;
+
+    //-- TRUE - for pure abbrivated images (wo tables) creation 
+    //-- if you want to write some tables set "sent_table = FALSE" after 
+    //-- this call for the table to be emitted. 
+    //jpeg_suppress_tables(&cinfo, TRUE);
+    jpeg_suppress_tables(cinfo, FALSE);
+
+    setupDQTs(env, cinfo, dqts);
+
+    //-- only simple progression sequence
+    if (progressive) {
+        jpeg_simple_progression(cinfo);
+    }
+
+    //-- TRUE forces all "sent_table = FALSE" so all tables will be written
+    jpeg_start_compress(cinfo, TRUE);
+
+    //-- use this for tables-only files and abbrivated images.
+    //-- If using jpeg_suppress_tables(&cinfo, TRUE):
+    //-- Only DQT sent_table = FALSE right now -> so DQT will be written but not DHT.
+    //-- uncomment when custom huffman tables be used.
+    //jpeg_start_compress(&cinfo, FALSE);
+
+    cur_scanline = 0;
+
+    while (cinfo->next_scanline < cinfo->image_height) {
+       (*env)->CallVoidMethod(env, callerObj, getScanlineID, cur_scanline);
+
+       // checking for an exception in the java method
+       if ((*env)->ExceptionOccurred(env)) {
+           //c_struct->exception_in_callback = TRUE;
+           cinfo->err->error_exit((j_common_ptr) cinfo);
+       }
+
+       native_buffer = (JOCTET*) (*env)->GetPrimitiveArrayCritical(env, arr, NULL);
+
+       // subsampling and copying to internal array
+       rowPtr = row_pointer;
+       for (i = 0; i < srcWidth * numBands; i += numBands * deltaX) {
+           for (j = 0; j < numBands; j++) {
+               *rowPtr++ = native_buffer[i + j];
+           }
+       }
+       (*env)->ReleasePrimitiveArrayCritical(env, arr, native_buffer, 0);
+
+       jpeg_write_scanlines(cinfo, &row_pointer, 1);
+
+       cur_scanline++;
+    }
+
+    jpeg_finish_compress(cinfo);
+    free(row_pointer);
+
+    return TRUE;
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/JpegEncoder.c
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/Exceptions.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/Exceptions.h?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/Exceptions.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/Exceptions.h Sun Oct  8 22:33:09 2006
@@ -0,0 +1,31 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Oleg V. Khaschansky
+ * @version $Revision: 1.2 $
+ * 
+ */
+
+#ifndef _Included_Exceptions
+#define _Included_Exceptions
+
+#include <jni.h>
+
+// Java exceptions
+void newExceptionByName(JNIEnv *env, const char* name, const char* msg);
+void newNullPointerException(JNIEnv *env, const char* msg);
+
+#endif // _Included_Exceptions
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/Exceptions.h
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h Sun Oct  8 22:33:09 2006
@@ -0,0 +1,82 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY IJH TOOL.
+ * Please be aware that all changes made to this file manually
+ * will be overwritten by the tool if it runs again.
+ */
+/**
+ * @author Alexey A. Petrenko
+ * @version $Revision: 1.4 $
+ * 
+ */
+
+#include <jni.h>
+
+
+/* Header for class org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter */
+
+#ifndef _ORG_APACHE_HARMONY_X_IMAGEIO_PLUGINS_JPEG_JPEGIMAGEWRITER_H
+#define _ORG_APACHE_HARMONY_X_IMAGEIO_PLUGINS_JPEG_JPEGIMAGEWRITER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Native methods */
+
+/*
+ * Method: org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter.dispose(J)V
+ */
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_dispose(JNIEnv *, jobject, 
+    jlong);
+
+/*
+ * Method: org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter.initWriterIds(Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_initWriterIds(JNIEnv *, jclass, 
+    jclass);
+
+/*
+ * Method: org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter.initCompressionObj()J
+ */
+JNIEXPORT jlong JNICALL
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_initCompressionObj(JNIEnv *, jobject);
+
+/*
+ * Method: org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter.setIOS(Ljavax/imageio/stream/ImageOutputStream;J)V
+ */
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_setIOS(JNIEnv *, jobject, 
+    jobject, jlong);
+
+/*
+ * Method: org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter.encode([BIIIIIIIZ[[IJ)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter_encode(JNIEnv *, jobject, 
+    jbyteArray, jint, jint, jint, jint, jint, jint, jint, jboolean, jobjectArray, jlong);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ORG_APACHE_HARMONY_X_IMAGEIO_PLUGINS_JPEG_JPEGIMAGEWRITER_H */
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/imageio/src/main/native/jpegencoder/shared/include/org_apache_harmony_x_imageio_plugins_jpeg_JPEGImageWriter.h
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/AttributeException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/AttributeException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/AttributeException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/AttributeException.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,31 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.4 $ 
+ */ 
+
+package javax.print;
+
+import javax.print.attribute.Attribute;
+
+public interface AttributeException {
+
+    Class[] getUnsupportedAttributes();
+
+    Attribute[] getUnsupportedValues();
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/AttributeException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/CancelablePrintJob.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/CancelablePrintJob.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/CancelablePrintJob.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/CancelablePrintJob.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,27 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+public interface CancelablePrintJob extends DocPrintJob {
+    
+    void cancel() throws PrintException;
+    
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/CancelablePrintJob.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/Doc.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/Doc.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/Doc.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/Doc.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,41 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.print.attribute.DocAttributeSet;
+
+public interface Doc {
+    
+    DocAttributeSet getAttributes();
+
+    DocFlavor getDocFlavor();
+
+    Object getPrintData() throws IOException;
+
+    Reader getReaderForText() throws IOException;
+
+    InputStream getStreamForBytes() throws IOException;
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/Doc.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocFlavor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocFlavor.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocFlavor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocFlavor.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,350 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Irina A. Arkhipets 
+ * @version $Revision: 1.5 $ 
+ */ 
+
+/*
+ * DocFlavor.java 
+ *  
+ * Encapsulates an object that specifies the format to a DocPrintJob print 
+ * data.
+ * 
+ */
+
+package javax.print;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.harmony.x.print.MimeType;
+
+
+public class DocFlavor implements Serializable, Cloneable {
+
+public static final String hostEncoding;
+
+static {
+    /* Host encoding. Need to change it to 
+       "hostEncoding = Charset.defaultCharset().toString" */ 
+    hostEncoding = (String) 
+            (AccessController.doPrivileged(new PrivilegedAction() {
+        public Object run() {
+            return (System.getProperty("file.encoding"));
+        }
+    }));
+}
+
+//Document media type (as defined in RFC 2045,2046, 822)
+private transient org.apache.harmony.x.print.MimeType aType;
+
+private String aClass;      // Representation class name
+
+public DocFlavor(String mimeType, String className) {
+    if ((mimeType == null) || (className == null)) {
+        throw new NullPointerException();
+    }
+    aType = new MimeType(mimeType);
+    aClass = className;
+}
+
+public boolean equals(Object obj) {
+    return (obj != null) && (obj instanceof DocFlavor) &&
+           (getCanonicalForm().equals(((DocFlavor) obj).getCanonicalForm()));
+}
+
+public String getMediaSubtype() {
+    return aType.getSubtype();
+}
+
+public String getMediaType() {
+    return aType.getType();
+}
+
+public String getMimeType() {
+    return aType.toString();
+}
+
+public String getParameter(String paramName) {
+    if (paramName == null) {
+        throw new NullPointerException();
+    }
+    return aType.getParameter(paramName);
+}
+
+public String getRepresentationClassName() {
+    return aClass;
+}
+
+public int hashCode() {
+    return getCanonicalForm().hashCode();
+}
+
+public String toString() {
+    return getCanonicalForm();
+}
+
+//--------------------------------------------------------------
+
+private void readObject(ObjectInputStream s) 
+        throws ClassNotFoundException, IOException {
+    s.defaultReadObject();
+    aType = new MimeType((String)(s.readObject()));
+}
+
+private void writeObject(ObjectOutputStream s) 
+        throws IOException {
+    s.defaultWriteObject();
+    s.writeObject(aType.getCanonicalForm());
+}
+
+private String getCanonicalForm() {
+    return aType.toString()+"; class=\""+aClass+"\"";
+}
+
+//--------------------------------------------------------------
+
+public static class BYTE_ARRAY extends DocFlavor {
+
+public BYTE_ARRAY(String mimeType) {
+    super(mimeType, "[B");
+}
+
+public static final BYTE_ARRAY AUTOSENSE =
+        new BYTE_ARRAY("application/octet-stream");
+
+public static final BYTE_ARRAY GIF = new BYTE_ARRAY("image/gif");
+
+public static final BYTE_ARRAY JPEG = new BYTE_ARRAY("image/jpeg");
+
+public static final BYTE_ARRAY PCL = new BYTE_ARRAY("application/vnd.hp-pcl");
+
+public static final BYTE_ARRAY PDF = new BYTE_ARRAY("application/pdf");
+
+
+public static final BYTE_ARRAY PNG = new BYTE_ARRAY("image/png");
+
+public static final BYTE_ARRAY POSTSCRIPT = 
+        new BYTE_ARRAY("application/postscript");
+
+public static final BYTE_ARRAY TEXT_HTML_HOST = 
+        new BYTE_ARRAY("text/html;charset=" + hostEncoding);
+
+public static final BYTE_ARRAY TEXT_HTML_US_ASCII = 
+        new BYTE_ARRAY("text/html;charset=us-ascii");
+
+public static final BYTE_ARRAY TEXT_HTML_UTF_16 = 
+        new BYTE_ARRAY("text/html;charset=utf-16");
+
+public static final BYTE_ARRAY TEXT_HTML_UTF_16BE = 
+        new BYTE_ARRAY("text/html;charset=utf-16be");
+
+public static final BYTE_ARRAY TEXT_HTML_UTF_16LE = 
+        new BYTE_ARRAY("text/html;charset=utf-16le");
+
+public static final BYTE_ARRAY TEXT_HTML_UTF_8 = 
+        new BYTE_ARRAY("text/html;charset=utf-8");
+
+public static final BYTE_ARRAY TEXT_PLAIN_HOST = 
+        new BYTE_ARRAY("text/plain;charset=" + hostEncoding);
+
+public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII = 
+        new BYTE_ARRAY("text/plain;charset=us-ascii");
+
+public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 = 
+        new BYTE_ARRAY("text/plain;charset=utf-16");
+
+public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE = 
+        new BYTE_ARRAY("text/plain;charset=utf-16be");
+
+public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE = 
+        new BYTE_ARRAY("text/plain;charset=utf-16le");
+
+public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 = 
+        new BYTE_ARRAY("text/plain;charset=utf-8");
+}
+
+public static class CHAR_ARRAY extends DocFlavor {
+
+public CHAR_ARRAY(String mimeType) {
+    super(mimeType, "[C");
+}
+
+public static final CHAR_ARRAY TEXT_HTML = 
+        new CHAR_ARRAY("text/html;charset=utf-16");
+
+public static final CHAR_ARRAY TEXT_PLAIN = 
+        new CHAR_ARRAY("text/plain;charset=utf-16");
+}
+
+public static class INPUT_STREAM extends DocFlavor {
+
+public INPUT_STREAM(String mimeType) {
+    super(mimeType, "java.io.InputStream");
+}
+
+public static final INPUT_STREAM AUTOSENSE = 
+        new INPUT_STREAM("application/octet-stream");
+
+public static final INPUT_STREAM GIF = new INPUT_STREAM("image/gif");
+
+public static final INPUT_STREAM JPEG = new INPUT_STREAM("image/jpeg");
+
+public static final INPUT_STREAM PCL = 
+        new INPUT_STREAM("application/vnd.hp-pcl");
+
+public static final INPUT_STREAM PDF = new INPUT_STREAM("application/pdf");
+
+public static final INPUT_STREAM PNG = new INPUT_STREAM("image/png");
+
+public static final INPUT_STREAM POSTSCRIPT = 
+        new INPUT_STREAM("application/postscript");
+
+public static final INPUT_STREAM TEXT_HTML_HOST = 
+        new INPUT_STREAM("text/html;charset=" + hostEncoding);
+
+public static final INPUT_STREAM TEXT_HTML_US_ASCII = 
+        new INPUT_STREAM("text/html;charset=us-ascii");
+
+public static final INPUT_STREAM TEXT_HTML_UTF_16 = 
+        new INPUT_STREAM("text/html;charset=utf-16");
+
+public static final INPUT_STREAM TEXT_HTML_UTF_16BE = 
+        new INPUT_STREAM("text/html;charset=utf-16be");
+
+public static final INPUT_STREAM TEXT_HTML_UTF_16LE = 
+        new INPUT_STREAM("text/html;charset=utf-16le");
+
+public static final INPUT_STREAM TEXT_HTML_UTF_8 = 
+        new INPUT_STREAM("text/html;charset=utf-8");
+
+public static final INPUT_STREAM TEXT_PLAIN_HOST = 
+        new INPUT_STREAM("text/plain;charset=" + hostEncoding);
+
+public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = 
+        new INPUT_STREAM("text/plain;charset=us-ascii");
+
+public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = 
+        new INPUT_STREAM("text/plain;charset=utf-16");
+
+public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = 
+        new INPUT_STREAM("text/plain;charset=utf-16be");
+
+public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = 
+        new INPUT_STREAM("text/plain;charset=utf-16le");
+
+public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = 
+        new INPUT_STREAM("text/plain;charset=utf-8");
+}
+
+public static class READER extends DocFlavor {
+
+public READER(String mimeType) {
+    super(mimeType, "java.io.Reader");
+}
+
+public static final READER TEXT_HTML = new READER("text/html;charset=utf-16");
+
+public static final READER TEXT_PLAIN = new READER("text/plain;charset=utf-16");
+}
+
+public static class SERVICE_FORMATTED extends DocFlavor {
+
+public SERVICE_FORMATTED(String className) {
+    super("application/x-java-jvm-local-objectref", className);
+}
+
+public static final SERVICE_FORMATTED PAGEABLE = 
+        new SERVICE_FORMATTED("java.awt.print.Pageable");
+
+public static final SERVICE_FORMATTED PRINTABLE = 
+        new SERVICE_FORMATTED("java.awt.print.Printable");
+
+public static final SERVICE_FORMATTED RENDERABLE_IMAGE = 
+        new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
+}
+
+public static class STRING extends DocFlavor {
+public STRING(String mimeType) {
+    super(mimeType, "java.lang.String");
+}
+
+public static final STRING TEXT_HTML = new STRING("text/html;charset=utf-16");
+
+public static final STRING TEXT_PLAIN = new STRING("text/plain;charset=utf-16");
+}
+
+public static class URL extends DocFlavor {
+
+public URL(String mimeType) {
+    super(mimeType, "java.net.URL");
+}
+
+public static final URL AUTOSENSE = new URL("application/octet-stream");
+
+public static final URL GIF = new URL("image/gif");
+
+public static final URL JPEG = new URL("image/jpeg");
+
+public static final URL PCL = new URL("application/vnd.hp-pcl");
+
+public static final URL PDF = new URL("application/pdf");
+
+public static final URL PNG = new URL("image/png");
+
+public static final URL POSTSCRIPT = new URL("application/postscript");
+
+public static final URL TEXT_HTML_HOST = 
+        new URL("text/html;charset=" + hostEncoding);
+
+public static final URL TEXT_HTML_US_ASCII = 
+        new URL("text/html;charset=us-ascii");
+
+public static final URL TEXT_HTML_UTF_16 = new URL("text/html;charset=utf-16");
+
+public static final URL TEXT_HTML_UTF_16BE = 
+        new URL("text/html;charset=utf-16be");
+
+public static final URL TEXT_HTML_UTF_16LE =
+        new URL("text/html;charset=utf-16le");
+
+public static final URL TEXT_HTML_UTF_8 = new URL("text/html;charset=utf-8");
+
+public static final URL TEXT_PLAIN_HOST = 
+        new URL("text/plain;charset=" +hostEncoding);
+
+public static final URL TEXT_PLAIN_US_ASCII = 
+        new URL("text/plain;charset=us-ascii");
+
+public static final URL TEXT_PLAIN_UTF_16 = 
+        new URL("text/plain;charset=utf-16");
+
+public static final URL TEXT_PLAIN_UTF_16BE =
+        new URL("text/plain;charset=utf-16be");
+
+public static final URL TEXT_PLAIN_UTF_16LE =
+        new URL("text/plain;charset=utf-16le");
+
+public static final URL TEXT_PLAIN_UTF_8 =
+        new URL("text/plain;charset=utf-8");
+}
+
+} /* End of DocFlavor class */ 

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocFlavor.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocPrintJob.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocPrintJob.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocPrintJob.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocPrintJob.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,47 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.4 $ 
+ */ 
+
+package javax.print;
+
+import javax.print.attribute.PrintJobAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.event.PrintJobAttributeListener;
+import javax.print.event.PrintJobListener;
+import javax.print.PrintException;
+
+public interface DocPrintJob {
+
+    PrintService getPrintService();
+
+    PrintJobAttributeSet getAttributes();
+
+    void addPrintJobListener(PrintJobListener listener);
+
+    void removePrintJobListener(PrintJobListener listener);
+
+    void addPrintJobAttributeListener(PrintJobAttributeListener listener, 
+            PrintJobAttributeSet attributes);
+
+    void removePrintJobAttributeListener(PrintJobAttributeListener listener);
+
+    void print(Doc doc, PrintRequestAttributeSet attributes) 
+            throws PrintException;
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/DocPrintJob.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/FlavorException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/FlavorException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/FlavorException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/FlavorException.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,27 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.4 $ 
+ */ 
+
+package javax.print;
+
+public interface FlavorException {
+
+    DocFlavor[] getUnsupportedFlavors();
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/FlavorException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDoc.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDoc.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDoc.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDoc.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,31 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.io.IOException;
+
+public interface MultiDoc {
+    
+    Doc getDoc() throws IOException;
+
+    MultiDoc next() throws IOException;
+    
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDoc.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintJob.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintJob.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintJob.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintJob.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,30 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import javax.print.attribute.PrintRequestAttributeSet;
+
+public interface MultiDocPrintJob extends DocPrintJob {
+
+    void print(MultiDoc multiDoc, PrintRequestAttributeSet attributes)
+            throws PrintException;
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintJob.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintService.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintService.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintService.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintService.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,27 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+public interface MultiDocPrintService extends PrintService {
+
+    MultiDocPrintJob createMultiDocPrintJob();
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/MultiDocPrintService.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintException.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,41 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.4 $ 
+ */ 
+
+package javax.print;
+
+
+public class PrintException extends Exception {
+
+    public PrintException() {
+        super();
+    }
+
+    public PrintException(String string) {
+        super(string);
+    }
+
+    public PrintException(Exception exception) {
+        super(exception);
+    }
+
+    public PrintException(String string, Exception exception) {
+        super(string, exception);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintService.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintService.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintService.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintService.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,69 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.event.PrintServiceAttributeListener;
+
+public interface PrintService {
+    
+    void addPrintServiceAttributeListener(PrintServiceAttributeListener listener);
+
+    DocPrintJob createPrintJob();
+
+    boolean equals(Object object);
+
+    PrintServiceAttribute getAttribute(Class category);
+
+    PrintServiceAttributeSet getAttributes();
+
+    Object getDefaultAttributeValue(Class category);
+
+    String getName();
+
+    ServiceUIFactory getServiceUIFactory();
+
+    Class[] getSupportedAttributeCategories();
+
+    Object getSupportedAttributeValues(Class category, DocFlavor flavor,
+            AttributeSet attributes);
+
+    DocFlavor[] getSupportedDocFlavors();
+
+   AttributeSet getUnsupportedAttributes(DocFlavor flavor,
+            AttributeSet attributes);
+
+    int hashCode();
+
+    boolean isAttributeCategorySupported(Class category);
+
+    boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, 
+            AttributeSet attributes);
+
+    boolean isDocFlavorSupported(DocFlavor flavor);
+
+    void removePrintServiceAttributeListener(
+            PrintServiceAttributeListener listener);
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintService.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintServiceLookup.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintServiceLookup.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintServiceLookup.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintServiceLookup.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,200 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Aleksei V. Ivaschenko 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.print.attribute.AttributeSet;
+
+public abstract class PrintServiceLookup {
+
+    private static ArrayList services = null;
+    private static ArrayList providers = null;
+
+    static {
+        services = new ArrayList();
+        providers = new ArrayList();
+
+        Enumeration providersEnum = null;
+        ClassLoader classLoader = null;
+        InputStream is = null;
+
+        classLoader = (ClassLoader) AccessController
+                .doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        ClassLoader classLoader = Thread.currentThread()
+                                .getContextClassLoader();
+                        return (classLoader == null) ? ClassLoader
+                                .getSystemClassLoader() : classLoader;
+                    }
+                });
+
+        if (classLoader != null) {
+            try {
+                providersEnum = classLoader
+                        .getResources("META-INF/services/javax.print.PrintServiceLookup");
+            } catch (IOException ioe1) {
+                ioe1.printStackTrace();
+            }
+
+            while (providersEnum.hasMoreElements()) {
+                URL url = (URL) providersEnum.nextElement();
+                try {
+                    is = url.openStream();
+
+                    BufferedReader providerNameReader;
+                    String name = null;
+
+                    try {
+                        providerNameReader = new BufferedReader(
+                                new InputStreamReader(is, "UTF-8"));
+                    } catch (UnsupportedEncodingException uee) {
+                        providerNameReader = new BufferedReader(
+                                new InputStreamReader(is));
+                    }
+
+                    if (providerNameReader != null) {
+                        try {
+                            name = providerNameReader.readLine();
+                            while (name != null) {
+                                if (name.length() > 0 && name.charAt(0) != '#') {
+                                    final Class providerClass = Class
+                                            .forName(name);
+
+                                    Object provider = AccessController
+                                            .doPrivileged(new PrivilegedAction() {
+                                                public Object run() {
+                                                    try {
+                                                        Object inst = providerClass
+                                                                .newInstance();
+                                                        return inst;
+                                                    } catch (InstantiationException ie) {
+                                                        System.err
+                                                                .println("Can't instantiate class "
+                                                                        + providerClass
+                                                                                .getName()
+                                                                        + ": "
+                                                                        + ie);
+                                                    } catch (IllegalAccessException iae) {
+                                                        System.out
+                                                                .println("Illegal access for class "
+                                                                        + providerClass
+                                                                                .getName()
+                                                                        + ": "
+                                                                        + iae);
+                                                    }
+                                                    return null;
+                                                }
+                                            });
+
+                                    if (provider != null) {
+                                        registerServiceProvider((PrintServiceLookup) provider);
+                                    }
+                                }
+                                name = providerNameReader.readLine();
+                            }
+                        } catch (IOException ioe) {
+                            System.out
+                                    .println("IOException during reading file:"
+                                            + ioe);
+                        } catch (ClassNotFoundException cnfe) {
+                            System.out.println("Class" + name
+                                    + " is not found:" + cnfe);
+                        }
+                    }
+                } catch (IOException ioe2) {
+                    ioe2.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public PrintServiceLookup() {
+    }
+
+    public abstract PrintService getDefaultPrintService();
+
+    public abstract PrintService[] getPrintServices();
+
+    public abstract PrintService[] getPrintServices(DocFlavor flavor,
+            AttributeSet attributes);
+
+    public abstract MultiDocPrintService[] getMultiDocPrintServices(
+            DocFlavor[] flavors, AttributeSet attributes);
+
+    public static final PrintService lookupDefaultPrintService() {
+        if (providers.size() > 0) {
+            PrintServiceLookup provider = (PrintServiceLookup) providers.get(0);
+            return provider.getDefaultPrintService();
+        }
+        return null;
+    }
+
+    public static final PrintService[] lookupPrintServices(DocFlavor flavor,
+            AttributeSet attributes) {
+        ArrayList printServices = new ArrayList();
+        for (int i = 0; i < providers.size(); i++) {
+            PrintServiceLookup provider = (PrintServiceLookup) providers.get(i);
+            PrintService[] providerServices = provider.getPrintServices(flavor,
+                    attributes);
+            for (int j = 0; j < providerServices.length; j++) {
+                printServices.add(providerServices[j]);
+            }
+        }
+        return (printServices.size() == 0 ? new PrintService[0]
+                : (PrintService[]) printServices.toArray(new PrintService[0]));
+    }
+
+    public static final MultiDocPrintService[] lookupMultiDocPrintServices(
+            DocFlavor[] flavors, AttributeSet attributes) {
+        ArrayList printServices = new ArrayList();
+        for (int i = 0; i < providers.size(); i++) {
+            PrintServiceLookup provider = (PrintServiceLookup) providers.get(i);
+            MultiDocPrintService[] providerServices = provider
+                    .getMultiDocPrintServices(flavors, attributes);
+            if (providerServices != null) {
+                for (int j = 0; j < providerServices.length; j++) {
+                    printServices.add(providerServices[j]);
+                }
+            }
+        }
+        return (printServices.size() == 0 ? new MultiDocPrintService[0]
+                : (MultiDocPrintService[]) printServices
+                        .toArray(new MultiDocPrintService[0]));
+    }
+
+    public static boolean registerService(PrintService service) {
+        return services.add(service);
+    }
+
+    public static boolean registerServiceProvider(PrintServiceLookup provider) {
+        return providers.add(provider);
+    }
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/PrintServiceLookup.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUI.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUI.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUI.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,136 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Irina A. Arkhipets 
+ * @version $Revision: 1.4 $ 
+ */ 
+
+/*
+ * ServiceUI.java
+ */
+
+package javax.print;
+
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.KeyboardFocusManager;
+import java.awt.Window;
+
+import javax.print.attribute.PrintRequestAttributeSet;
+
+import org.apache.harmony.x.print.ServiceUIDialog;
+
+
+public class ServiceUI {
+    
+public static PrintService printDialog(GraphicsConfiguration gc, 
+                                       int x,
+                                       int y,
+                                       PrintService [] services,
+                                       PrintService defaultService,
+                                       DocFlavor flavor,
+                                       PrintRequestAttributeSet attributes)
+        throws HeadlessException
+{
+
+    if (GraphicsEnvironment.isHeadless()) { 
+        throw new HeadlessException();
+    }
+
+    int initialIndex = checkServices(services, defaultService, attributes);
+
+    Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager()
+            .getActiveWindow();
+    Window dialogOwner = getDialogOwner(activeWindow);
+
+    ServiceUIDialog dialog = new ServiceUIDialog(gc, x, y, services,
+            initialIndex, flavor, attributes, dialogOwner);
+
+    dialog.show();
+
+    if (dialogOwner != activeWindow) {
+        dialogOwner.dispose();
+    }
+
+    if (dialog.getResult() == ServiceUIDialog.APPROVE_PRINT) {
+        attributes.clear();
+        attributes.addAll(dialog.getAttributes());
+        return dialog.getPrintService();
+    } 
+
+    return null;
+}
+
+//------------------------------------------------------------------------
+
+/*
+ * This function checks services, defaultService and attributes input
+ * parameters for printDialog(...) method. 
+ * 
+ * Returns defaultService index in services array 
+ * or 0 if defaultService is null.
+ * 
+ * Throws IllegalArgumentException if services is null or empty, 
+ * or attributes is null, or the initial PrintService is not
+ * in the list of browsable services
+ */
+static int checkServices(PrintService [] services, 
+                         PrintService defaultService,
+                         PrintRequestAttributeSet attributes)
+{
+    if (services == null) {
+        throw new IllegalArgumentException("Services list is null!");
+    } else if (services.length == 0) {
+        throw new IllegalArgumentException("Services list is empty!");
+    } else if (attributes == null) {
+        throw new IllegalArgumentException("Attribute set is null!");
+    }
+
+    int serviceIndex = 0;
+    boolean defaultServiceFound = (defaultService == null);
+    
+    for (int i = 0; i < services.length; i++) {
+        if (services[i].equals(defaultService)) {
+            serviceIndex = i;
+            defaultServiceFound = true;
+            break;
+        }
+    }
+    
+    if (!defaultServiceFound) {
+        throw new IllegalArgumentException(
+                "Default service is absent in the services list!");
+    }
+
+    return serviceIndex;
+}
+
+/*
+ * This functions checks if current activeWindow can be parent for
+ * ServiceUIDialog window.
+ * 
+ * Returns window if the given window is Dialog or Frame, 
+ * overwise returns new Frame object.
+ */
+private static Window getDialogOwner(Window window) {
+    return ((window instanceof Dialog) || (window instanceof Frame)) ? 
+            window : new Frame();
+}
+
+} /* End of ServiceUI class */

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUI.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUIFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUIFactory.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUIFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUIFactory.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,50 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Irina A. Arkhipets 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+/*
+ * ServiceUIFactory.java
+ * 
+ */
+
+package javax.print;
+
+public abstract class ServiceUIFactory {
+
+public static final int ABOUT_UIROLE = 1;
+
+public static final int ADMIN_UIROLE = 2;
+
+public static final int MAIN_UIROLE = 3;
+
+public static final int RESERVED_UIROLE = 99;
+
+public static final String DIALOG_UI = "java.awt.Dialog";
+
+public static final String JCOMPONENT_UI = "javax.swing.JComponent";
+
+public static final String JDIALOG_UI = "javax.swing.JDialog";
+
+public static final String PANEL_UI = "java.awt.Panel";
+
+public abstract Object getUI(int role, String ui);
+
+public abstract String[] getUIClassNamesForRole(int role);
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/ServiceUIFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/SimpleDoc.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/SimpleDoc.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/SimpleDoc.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/SimpleDoc.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,110 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.print.attribute.DocAttributeSet;
+
+public final class SimpleDoc implements Doc {
+    
+    Object printdata;
+    DocFlavor flavor;
+    DocAttributeSet attributes;
+    Reader reader;
+    InputStream instream;
+
+    public SimpleDoc(Object printData, DocFlavor docflavor,
+            DocAttributeSet docattributes) {
+        // IllegalArgumentException - if flavor or printData is null, or the
+        // printData does not correspond to the specified doc flavor--for
+        // example, the data is not of the type specified as the representation
+        // in the DocFlavor.
+        if (docflavor == null || printData == null) {
+            throw new IllegalArgumentException("Argument is null");
+        }
+        try {
+            Class claz = null;
+            claz = Class.forName(docflavor.getRepresentationClassName());
+
+            if (!claz.isInstance(printData)) {
+                throw new IllegalArgumentException("");
+            }
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Wrong type of print data");
+        }
+
+        this.printdata = printData;
+        this.flavor = docflavor;
+        this.attributes = docattributes;
+        this.reader = null;
+        this.instream = null;
+    }
+
+    public DocAttributeSet getAttributes() {
+        return attributes;
+    }
+
+    public DocFlavor getDocFlavor() {
+        return flavor;
+    }
+
+    public Object getPrintData() throws IOException {
+        return printdata;
+    }
+
+    public Reader getReaderForText() throws IOException {
+        synchronized (this) {
+            if (reader != null) {
+                return reader;
+            }
+
+            if (printdata instanceof Reader) {
+                reader = (Reader) printdata;
+            } else if (printdata instanceof char[]) {
+                reader = new CharArrayReader((char[]) printdata);
+            } else if (printdata instanceof String) {
+                reader = new StringReader((String) printdata);
+            }
+        }
+        return reader;
+    }
+
+    public InputStream getStreamForBytes() throws IOException {
+        synchronized (this) {
+            if (instream != null) {
+                return instream;
+            }
+
+            if (printdata instanceof InputStream) {
+                instream = (InputStream) printdata;
+            } else if (printdata instanceof byte[]) {
+                instream = new ByteArrayInputStream((byte[]) printdata);
+            }
+        }
+        return instream;
+    }
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/SimpleDoc.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintService.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintService.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintService.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintService.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,55 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public abstract class StreamPrintService implements PrintService {  
+    private OutputStream outputStream;
+    private boolean disposed ;
+    
+    protected StreamPrintService(OutputStream out){
+        outputStream = out;
+        disposed = false;
+    }  
+    
+    public abstract String getOutputFormat();     
+    
+    public OutputStream getOutputStream(){
+        return outputStream;
+    }
+    
+    public void dispose() {     
+        try {
+            outputStream.flush();
+        } catch (IOException e) {
+            e.printStackTrace();            
+        }
+        disposed = true;
+    }
+    
+    public boolean isDisposed() {
+        return disposed;
+    }
+}
+
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintService.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintServiceFactory.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintServiceFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintServiceFactory.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,98 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Igor A. Pyankov 
+ * @version $Revision: 1.3 $ 
+ */ 
+package javax.print;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.io.IOException;
+import javax.print.DocFlavor;
+import javax.print.StreamPrintService;
+
+import org.apache.harmony.x.print.PSStreamPrintServiceFactory;
+import org.apache.harmony.x.print.util.FactoryLocator;
+
+
+public abstract class StreamPrintServiceFactory {
+
+    //  static part of the class
+    private static ArrayList listOfSPSFactories = new ArrayList();      
+       
+    
+    public static StreamPrintServiceFactory[] 
+             lookupStreamPrintServiceFactories(
+                    DocFlavor flavor, String outputMimeType) {
+        
+        int l;
+        ArrayList selectedSPSFactories = new ArrayList();
+        StreamPrintServiceFactory factory;        
+        StreamPrintServiceFactory[] a = {}; 
+        
+        FactoryLocator fl = new FactoryLocator();
+        try {
+            fl.lookupAllFactories();
+        } catch (IOException io) {            
+            return (StreamPrintServiceFactory[]) selectedSPSFactories.toArray(a);            
+        }
+        listOfSPSFactories = fl.getFactoryClasses();
+
+        // no selection      
+        if (flavor == null && outputMimeType == null) {  
+            return  (StreamPrintServiceFactory[])listOfSPSFactories.toArray(a);
+        }
+        // make a selection by 
+        l = listOfSPSFactories.size();
+        for (int i = 0; i < l; i++) {
+            factory = (StreamPrintServiceFactory) listOfSPSFactories.get(i);
+            if ((outputMimeType == null || 
+                    outputMimeType.equalsIgnoreCase(factory.getOutputFormat())
+                    ||(factory instanceof PSStreamPrintServiceFactory &&
+                    outputMimeType.equalsIgnoreCase("internal/postscript")))
+                && (flavor == null || 
+                    isElementOf(flavor, factory.getSupportedDocFlavors()))) {
+
+                   selectedSPSFactories.add(factory);
+               }
+        }
+        return (StreamPrintServiceFactory[]) selectedSPSFactories.toArray(a);
+    }
+    
+    /*
+     * auxilary method for element search
+     */    
+    private static boolean isElementOf(DocFlavor flavor, DocFlavor[] flavors) {
+        for (int i = 0; i < flavors.length; i++) {
+            if (flavor.equals(flavors[i])) {
+                return true;
+            }
+        }
+        return false;
+    }    
+     
+    public StreamPrintServiceFactory(){
+        super();
+    }
+      
+    public abstract String getOutputFormat();
+  
+    public abstract DocFlavor[] getSupportedDocFlavors();
+
+    public abstract StreamPrintService getPrintService(OutputStream out);
+    
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/StreamPrintServiceFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/URIException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/URIException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/URIException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/URIException.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print;
+
+import java.net.URI;
+
+
+public interface URIException {
+
+    static final int URIInaccessible = 1;
+
+    static final int URISchemeNotSupported = 2;
+
+    static final int URIOtherProblem = -1;
+
+    int getReason();
+
+    URI getUnsupportedURI();
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/URIException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/Attribute.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/Attribute.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/Attribute.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,32 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.6 $ 
+ */ 
+
+package javax.print.attribute;
+
+import java.io.Serializable;
+
+public interface Attribute extends Serializable {
+
+    Class getCategory();
+    //1.5 support requires the following changes
+    //Class<? extends Attribute> getCategory();
+
+    String getName();
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/Attribute.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,61 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.6 $ 
+ */ 
+
+package javax.print.attribute;
+
+/*
+ * @author esayapin
+ */
+
+public interface AttributeSet {
+
+    boolean add(Attribute attribute);
+    
+    boolean addAll(AttributeSet attributeSet);
+
+    void clear();
+    
+    boolean containsKey(Class attributeCategory);
+    //1.5 support requires the following changes 
+    //boolean containsKey(Class<?> attributeCategory);
+    
+    boolean containsValue(Attribute attribute);
+    
+    boolean equals(Object object);
+    
+    Attribute get(Class attributeCategory);
+    //1.5 support requires the following changes 
+    //Attribute get(Class<?> attributeCategory);
+    
+    int hashCode();
+    
+    boolean isEmpty();
+    
+    boolean remove(Attribute attribute);
+    
+    boolean remove(Class attributeCategory);
+    //1.5 support requires the following changes 
+    //boolean remove(Class<?> attributeCategory);
+
+    int size();
+    
+    Attribute[] toArray();
+    
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/javax/print/attribute/AttributeSet.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message