You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/10/09 07:33:21 UTC
svn commit: r454289 [15/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/mai...
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttribute.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttribute.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttribute.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttribute.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,385 @@
+/*
+ * 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.2 $
+ */
+package org.apache.harmony.x.print.ipp;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Vector;
+
+/*
+ * class IppAttribute stores IPP attribute (http://ietf.org/rfc/rfc2910.txt?number=2910)
+ *
+ * <pre>
+ * The following table specifies the out-of-band values for the
+ * value-tag field.
+ *
+ * Tag Value (Hex) Meaning
+ *
+ * 0x10 unsupported
+ * 0x11 reserved for 'default' for definition in a future
+ * IETF standards track document
+ * 0x12 unknown
+ * 0x13 no-value
+ * 0x14-0x1F reserved for "out-of-band" values in future IETF
+ * standards track documents.
+ *
+ * The following table specifies the integer values for the value-tag
+ * field:
+ *
+ * Tag Value (Hex) Meaning
+ *
+ * 0x20 reserved for definition in a future IETF
+ * standards track document
+ * 0x21 integer
+ * 0x22 boolean
+ * 0x23 enum
+ * 0x24-0x2F reserved for integer types for definition in
+ * future IETF standards track documents
+ *
+ * NOTE: 0x20 is reserved for "generic integer" if it should ever be
+ * needed.
+ *
+ * The following table specifies the octetString values for the value-tag field:
+ *
+ * Tag Value (Hex) Meaning
+ *
+ * 0x30 octetString with an unspecified format
+ * 0x31 dateTime
+ * 0x32 resolution
+ * 0x33 rangeOfInteger
+ * 0x34 reserved for definition in a future IETF * standards track document
+ * 0x35 textWithLanguage
+ * 0x36 nameWithLanguage
+ * 0x37-0x3F reserved for octetString type definitions in
+ * future IETF standards track documents
+ *
+ * The following table specifies the character-string values for the
+ * value-tag field:
+ *
+ * Tag Value (Hex) Meaning
+ *
+ * 0x40 reserved for definition in a future IETF standards track document
+ * 0x41 textWithoutLanguage
+ * 0x42 nameWithoutLanguage
+ * 0x43 reserved for definition in a future IETF standards track document
+ * 0x44 keyword
+ * 0x45 uri
+ * 0x46 uriScheme
+ * 0x47 charset
+ * 0x48 naturalLanguage
+ * 0x49 mimeMediaType
+ * 0x4A-0x5F reserved for character string type definitions
+ * in future IETF standards track documents
+ * </pre>
+ */
+public class IppAttribute {
+ // "out-of-band" values for the "value-tag" field.
+ public static final byte TAG_UNSUPPORTED = 0x10;
+ public static final byte TAG_UNKNOWN = 0x12;
+ public static final byte TAG_NO_VALUE = 0x13;
+
+ // integer values for the "value-tag" field.
+ public static final byte TAG_INTEGER = 0x21;
+ public static final byte TAG_BOOLEAN = 0x22;
+ public static final byte TAG_ENUM = 0x23;
+
+ // octetString values for the "value-tag" field.
+ public static final byte TAG_OCTETSTRINGUNSPECIFIEDFORMAT = 0x30;
+ public static final byte TAG_DATETIME = 0x31;
+ public static final byte TAG_RESOLUTION = 0x32;
+ public static final byte TAG_RANGEOFINTEGER = 0x33;
+ public static final byte TAG_TEXTWITHLANGUAGE = 0x35;
+ public static final byte TAG_NAMEWITHLANGUAGE = 0x36;
+
+ // character-string values for the "value-tag" field
+ public static final byte TAG_TEXTWITHOUTLANGUAGE = 0x41;
+ public static final byte TAG_NAMEWITHOUTLANGUAGE = 0x42;
+ public static final byte TAG_KEYWORD = 0x44;
+ public static final byte TAG_URI = 0x45;
+ public static final byte TAG_URISCHEME = 0x46;
+ public static final byte TAG_CHARSET = 0x47;
+ public static final byte TAG_NATURAL_LANGUAGE = 0x48;
+ public static final byte TAG_MIMEMEDIATYPE = 0x49;
+
+ /*
+ * The method just return names of attributes tags
+ */
+ public static String getTagName(byte atag) {
+ String sz = "";
+ switch (atag) {
+ // integer values for the "value-tag" field.
+ case TAG_BOOLEAN:
+ sz = "BOOLEAN";
+ break;
+ case TAG_INTEGER:
+ sz = "INTEGER";
+ break;
+ case TAG_ENUM:
+ sz = "ENUM";
+ break;
+ // octetString values for the "value-tag" field.
+ case TAG_OCTETSTRINGUNSPECIFIEDFORMAT:
+ case TAG_DATETIME:
+ case TAG_RESOLUTION:
+ case TAG_RANGEOFINTEGER:
+ case TAG_TEXTWITHLANGUAGE:
+ case TAG_NAMEWITHLANGUAGE:
+ sz = "OCTETSTRING";
+ break;
+ // character-string values for the "value-tag" field
+ case TAG_TEXTWITHOUTLANGUAGE:
+ case TAG_NAMEWITHOUTLANGUAGE:
+ case TAG_KEYWORD:
+ case TAG_URI:
+ case TAG_URISCHEME:
+ case TAG_CHARSET:
+ case TAG_NATURAL_LANGUAGE:
+ case TAG_MIMEMEDIATYPE:
+ sz = "CHARACTERSTRING";
+ break;
+ default:
+ sz = "UNKNOWN_ATTRIBUTE_TAG";
+ break;
+ }
+ return sz;
+ }
+
+ protected byte atag;
+ protected byte[] aname;
+ protected Vector avalue;
+
+ /*
+ * Constructors
+ */
+ public IppAttribute(byte tag, String name, int value) {
+ atag = tag;
+ aname = name.getBytes();
+ avalue = new Vector();
+ avalue.add(new Integer(value));
+ }
+
+ public IppAttribute(byte tag, String name, String value) {
+ atag = tag;
+ aname = name.getBytes();
+ avalue = new Vector();
+ avalue.add(value.getBytes());
+ }
+
+ public IppAttribute(byte tag, String name, byte[] value) {
+ atag = tag;
+ aname = name.getBytes();
+ avalue = new Vector();
+ avalue.add(value);
+ }
+
+ public IppAttribute(byte tag, String name, Vector value) {
+ atag = tag;
+ aname = name.getBytes();
+ avalue = value;
+ }
+
+ /*
+ * Getters
+ */
+ public byte getTag() {
+ return atag;
+ }
+
+ public byte[] getName() {
+ return aname;
+ }
+
+ public Vector getValue() {
+ return avalue;
+ }
+
+ /*
+ * The method return byte array of attribute
+ * Then these bytes can be wrote to http request
+ */
+ public byte[] getBytes() {
+ ByteArrayOutputStream bbuf = new ByteArrayOutputStream();
+ DataOutputStream dbuf = new DataOutputStream(bbuf);
+ byte[] bv;
+
+ try {
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ dbuf.writeByte(atag);
+ if (i == 0) {
+ dbuf.writeShort(aname.length);
+ dbuf.write(aname);
+ } else {
+ dbuf.writeShort(0);
+ }
+ switch (atag) {
+ // integer values for the "value-tag" field.
+ case TAG_BOOLEAN:
+ dbuf.writeShort(1);
+ dbuf.write(((Integer) avalue.get(i)).intValue());
+ break;
+ case TAG_INTEGER:
+ case TAG_ENUM:
+ dbuf.writeShort(4);
+ dbuf.writeInt(((Integer) avalue.get(i)).intValue());
+ break;
+ // octetString values for the "value-tag" field.
+ case TAG_OCTETSTRINGUNSPECIFIEDFORMAT:
+ case TAG_DATETIME:
+ case TAG_RESOLUTION:
+ case TAG_RANGEOFINTEGER:
+ case TAG_TEXTWITHLANGUAGE:
+ case TAG_NAMEWITHLANGUAGE:
+ bv = (byte[]) avalue.get(i);
+ dbuf.writeShort(bv.length);
+ dbuf.write(bv);
+ break;
+ // character-string values for the "value-tag" field
+ case TAG_TEXTWITHOUTLANGUAGE:
+ case TAG_NAMEWITHOUTLANGUAGE:
+ case TAG_KEYWORD:
+ case TAG_URI:
+ case TAG_URISCHEME:
+ case TAG_CHARSET:
+ case TAG_NATURAL_LANGUAGE:
+ case TAG_MIMEMEDIATYPE:
+ bv = (byte[]) avalue.get(i);
+ dbuf.writeShort(bv.length);
+ dbuf.write(bv);
+ break;
+ default:
+ break;
+ }
+ }
+ dbuf.flush();
+ dbuf.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return bbuf.toByteArray();
+ }
+
+ /*
+ * @see java.lang.Object#toString()
+ *
+ * Returns readable form of attribute
+ */
+ public String toString() {
+ ByteArrayOutputStream bbuf = new ByteArrayOutputStream();
+ DataOutputStream dbuf = new DataOutputStream(bbuf);
+
+ try {
+ dbuf.writeBytes("attribute tag: 0x" + Integer.toHexString(atag)
+ + "(" + getTagName(atag) + ")" + "\n");
+ dbuf.writeBytes("attribute name: " + new String(aname) + "\n");
+
+ switch (atag) {
+ // integer values for the "value-tag" field.
+ case TAG_INTEGER:
+ case TAG_BOOLEAN:
+ case TAG_ENUM:
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ Integer v = (Integer) avalue.get(i);
+ dbuf.writeBytes(v.toString() + "\n");
+ }
+ break;
+ // octetString values for the "value-tag" field.
+ case TAG_OCTETSTRINGUNSPECIFIEDFORMAT:
+ case TAG_RESOLUTION:
+ case TAG_TEXTWITHLANGUAGE:
+ case TAG_NAMEWITHLANGUAGE:
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ byte[] bv = (byte[]) avalue.get(i);
+ dbuf.writeBytes(new String(bv) + "\n");
+ }
+ break;
+ case TAG_DATETIME:
+ /*
+ * <pre> A date-time specification.
+ *
+ * field octets contents range ----- ------ -------- ----- 1 1-2
+ * year 0..65536 2 3 month 1..12 3 4 day 1..31 4 5 hour 0..23 5
+ * 6 minutes 0..59 6 7 seconds 0..60 (use 60 for leap-second) 7
+ * 8 deci-seconds 0..9 8 9 direction from UTC '+' / '-' 9 10
+ * hours from UTC 0..11 10 11 minutes from UTC 0..59 For
+ * example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
+ * displayed as: 1992-5-26,13:30:15.0,-4:0 </pre>
+ */
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ byte[] bv = (byte[]) avalue.get(i);
+ ByteArrayInputStream bi = new ByteArrayInputStream(bv);
+ DataInputStream di = new DataInputStream(bi);
+
+ dbuf.writeBytes(Integer.toString(di.readShort()) + "-"
+ + Integer.toString(di.readByte()) + "-"
+ + Integer.toString(di.readByte()) + ","
+ + Integer.toString(di.readByte()) + ":"
+ + Integer.toString(di.readByte()) + ":"
+ + Integer.toString(di.readByte()) + "."
+ + Integer.toString(di.readByte()) + ","
+ + (char) di.readByte()
+ + Integer.toString(di.readByte()) + ":"
+ + Integer.toString(di.readByte()) + "\n");
+ }
+ break;
+ case TAG_RANGEOFINTEGER:
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ byte[] bv = (byte[]) avalue.get(i);
+ ByteArrayInputStream bi = new ByteArrayInputStream(bv);
+ DataInputStream di = new DataInputStream(bi);
+ dbuf.writeBytes(Integer.toString(di.readInt()) + "..."
+ + Integer.toString(di.readInt()) + "\n");
+ }
+ break;
+ // character-string values for the "value-tag" field
+ case TAG_TEXTWITHOUTLANGUAGE:
+ case TAG_NAMEWITHOUTLANGUAGE:
+ case TAG_KEYWORD:
+ case TAG_URI:
+ case TAG_URISCHEME:
+ case TAG_CHARSET:
+ case TAG_NATURAL_LANGUAGE:
+ case TAG_MIMEMEDIATYPE:
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ byte[] bv = (byte[]) avalue.get(i);
+ dbuf.writeBytes(new String(bv) + "\n");
+ }
+ break;
+ default:
+ for (int ii = avalue.size(), i = 0; i < ii; i++) {
+ //byte[] bv = (byte[]) avalue.get(i);
+ //dbuf.writeBytes(new String(bv) + "\n");
+ }
+ break;
+ }
+
+ dbuf.flush();
+ dbuf.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return bbuf.toString();
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttribute.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroup.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroup.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroup.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroup.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,179 @@
+/*
+ * 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.2 $
+ */
+package org.apache.harmony.x.print.ipp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Vector;
+
+/*
+ * class IppAttributeGroup stores IPP attributes group
+ */
+public class IppAttributeGroup extends Vector {
+ /* According to RFC2910 (http://ietf.org/rfc/rfc2910.txt?number=2910):
+ *
+ * Each "attribute-group" field MUST be encoded with the "begin-
+ * attribute-group-tag" field followed by zero or more "attribute" sub-
+ * fields.
+ *
+ * The table below maps the model document group name to value of the
+ * "begin-attribute-group-tag" field:
+ *
+ * Model Document Group "begin-attribute-group-tag" field values
+ *
+ * Operation Attributes "operations-attributes-tag"
+ * Job Template Attributes "job-attributes-tag"
+ * Job Object Attributes "job-attributes-tag"
+ * Requested Attributes "job-attributes-tag" (Get-Job-Attributes)
+ * Requested Attributes "printer-attributes-tag" (Get-Printer-Attributes)
+ * Unsupported Attributes * "unsupported-attributes-tag"
+ * Document Content in a special position as described above
+ *
+ * 0x00 reserved for definition in a future IETF standards track document
+ * 0x01 "operation-attributes-tag"
+ * 0x02 "job-attributes-tag"
+ * 0x03 "end-of-attributes-tag"
+ * 0x04 "printer-attributes-tag"
+ * 0x05 "unsupported-attributes-tag"
+ * 0x06-0x0f reserved for future delimiters in
+ * IETF standards track documents
+ */
+ public static final byte TAG_RESERVED = 0x00;
+ public static final byte TAG_OPERATION_ATTRIBUTES = 0x01;
+ public static final byte TAG_JOB_ATTRIBUTES = 0x02;
+ public static final byte TAG_JOB_TEMPLATE_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
+ public static final byte TAG_JOB_OBJECT_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
+ public static final byte TAG_GET_JOB_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
+ public static final byte TAG_END_OF_ATTRIBUTES = 0x03;
+ public static final byte TAG_PRINTER_ATTRIBUTES = 0x04;
+ public static final byte TAG_GET_PRINTER_ATTRIBUTES = TAG_PRINTER_ATTRIBUTES;
+ public static final byte TAG_UNSUPPORTED_ATTRIBUTES = 0x05;
+
+ /*
+ * @return Returns the name of the group.
+ */
+ public static String getGname(int agid) {
+ switch (agid) {
+ case TAG_RESERVED:
+ return IppResources.getString("IppAttributesGroup.RESERVED");
+ case TAG_OPERATION_ATTRIBUTES:
+ return IppResources.getString("IppAttributesGroup.OPERATION_ATTRIBUTES");
+ case TAG_JOB_ATTRIBUTES:
+ return IppResources.getString("IppAttributesGroup.JOB_TEMPLATE_ATTRIBUTES");
+ case TAG_PRINTER_ATTRIBUTES:
+ return IppResources.getString("IppAttributesGroup.GET_PRINTER_ATTRIBUTES");
+ case TAG_END_OF_ATTRIBUTES:
+ return IppResources.getString("IppAttributesGroup.END_OF_ATTRIBUTES");
+ case TAG_UNSUPPORTED_ATTRIBUTES:
+ return IppResources.getString("IppAttributesGroup.UNSUPPORTED_ATTRIBUTES");
+ }
+ return "UNKNOWN_ATTRIBUTES";
+ }
+
+ protected int agroupid;
+
+ public IppAttributeGroup(int agid) {
+ super();
+ this.agroupid = agid;
+ }
+
+ public IppAttributeGroup(Integer agid) {
+ super();
+ this.agroupid = agid.byteValue();
+ }
+
+ /*
+ * change/add attributes in this group by attributes from parameter
+ */
+ public int set(IppAttributeGroup ag) {
+ if (ag != null && agroupid == ag.agroupid && ag.size() > 0) {
+ int i1;
+ IppAttribute a;
+
+ for (int ii = ag.size(), i = 0; i < ii; i++) {
+ a = (IppAttribute) ag.get(i);
+ i1 = findAttribute(new String(a.aname));
+ if (i1 >= 0) {
+ set(i1, a);
+ } else {
+ add(a);
+ }
+ }
+ }
+
+ return size();
+ }
+
+ public int findAttribute(String name) {
+ for (int ii = size(), i = 0; i < ii; i++) {
+ if (name.equals(new String(((IppAttribute) get(i)).aname))) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /*
+ * return array of byte presentation of group
+ */
+ public byte[] getBytes() {
+ ByteArrayOutputStream ba = new ByteArrayOutputStream();
+ IppAttribute a;
+ byte[] b;
+
+ ba.write((byte) agroupid);
+ for (int ii = size(), i = 0; i < ii; i++) {
+ a = (IppAttribute) get(i);
+ b = a.getBytes();
+ ba.write(b, 0, b.length);
+ }
+ return ba.toByteArray();
+ }
+
+ /*
+ * human readable form of group
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ ByteArrayOutputStream ab = new ByteArrayOutputStream();
+ DataOutputStream ba = new DataOutputStream(ab);
+ IppAttribute a;
+ String s;
+
+ try {
+ ba.writeBytes("---- Attributes group: 0x"
+ + Integer.toHexString(agroupid) + "(" + getGname(agroupid)
+ + ")" + "\n");
+ for (int ii = size(), i = 0; i < ii; i++) {
+ a = (IppAttribute) get(i);
+ s = a.toString();
+ ba.writeBytes(s + "\n");
+ }
+ } catch (IOException e) {
+ // IGNORE exception
+ e.printStackTrace();
+ }
+
+ return ab.toString();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroup.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroupSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroupSet.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroupSet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroupSet.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,201 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+/*
+ * Set of IppAttributeGroup
+ */
+public class IppAttributeGroupSet extends Hashtable {
+
+ static protected void sortAttributes(Vector va) {
+ Object v1, v2;
+ IppAttributeGroup g1, g2;
+ boolean the_end = false;
+
+ while (!the_end) {
+ the_end = true;
+ for (int ii = va.size(), i = 0; i < (ii - 1); i++) {
+ v1 = va.get(i);
+ v2 = va.get(i + 1);
+ if (v1 instanceof Vector) {
+ g1 = (IppAttributeGroup) ((Vector) v1).get(0);
+ } else {
+ g1 = (IppAttributeGroup) v1;
+ }
+ if (v2 instanceof Vector) {
+ g2 = (IppAttributeGroup) ((Vector) v2).get(0);
+ } else {
+ g2 = (IppAttributeGroup) v2;
+ }
+ if (g1 != null && g2 != null && g1.agroupid > g2.agroupid) {
+ the_end = false;
+ va.set(i, v2);
+ va.set(i + 1, v1);
+ }
+ }
+ }
+ }
+
+ public boolean setAttribute(String aname, Object avalue) {
+ Integer gtag;
+ byte vtag;
+ IppAttributeGroup group;
+
+ if (avalue == null || aname == null || aname.equals("")) {
+ return false;
+ }
+
+ gtag = new Integer(IppDefs.getAttributeGtag(aname));
+ vtag = IppDefs.getAttributeVtag(aname);
+ if (avalue instanceof IppAttribute) {
+ if (((IppAttribute) avalue).getTag() != vtag
+ || !aname.equals(new String(
+ ((IppAttribute) avalue).getName()))) {
+ return false;
+ }
+ }
+
+ group = (IppAttributeGroup) get(gtag);
+ if (group == null) {
+ put(gtag, new IppAttributeGroup(gtag));
+ group = (IppAttributeGroup) get(gtag);
+ }
+ if (group == null) {
+ return false;
+ }
+
+ int aindex = -1;
+
+ if (avalue instanceof IppAttribute) {
+ aname = new String(((IppAttribute) avalue).getName());
+ aindex = group.findAttribute(aname);
+ if (aindex >= 0) {
+ group.set(aindex, avalue);
+ } else {
+ group.add(avalue);
+ }
+ return true;
+ }
+
+ switch (vtag) {
+ case IppAttribute.TAG_INTEGER:
+ case IppAttribute.TAG_BOOLEAN:
+ case IppAttribute.TAG_ENUM:
+ avalue = new IppAttribute(vtag, aname,
+ ((Integer) avalue).intValue());
+ aindex = group.findAttribute(aname);
+ if (aindex >= 0) {
+ group.set(aindex, avalue);
+ } else {
+ group.add(avalue);
+ }
+ return true;
+ case IppAttribute.TAG_OCTETSTRINGUNSPECIFIEDFORMAT:
+ case IppAttribute.TAG_DATETIME:
+ case IppAttribute.TAG_RESOLUTION:
+ case IppAttribute.TAG_RANGEOFINTEGER:
+ case IppAttribute.TAG_TEXTWITHLANGUAGE:
+ case IppAttribute.TAG_NAMEWITHLANGUAGE:
+ avalue = new IppAttribute(vtag, aname, (byte[]) avalue);
+ aindex = group.findAttribute(aname);
+ if (aindex >= 0) {
+ group.set(aindex, avalue);
+ } else {
+ group.add(avalue);
+ }
+ return true;
+ case IppAttribute.TAG_TEXTWITHOUTLANGUAGE:
+ case IppAttribute.TAG_NAMEWITHOUTLANGUAGE:
+ case IppAttribute.TAG_KEYWORD:
+ case IppAttribute.TAG_URI:
+ case IppAttribute.TAG_URISCHEME:
+ case IppAttribute.TAG_CHARSET:
+ case IppAttribute.TAG_NATURAL_LANGUAGE:
+ case IppAttribute.TAG_MIMEMEDIATYPE:
+ case IppAttribute.TAG_UNSUPPORTED:
+ avalue = new IppAttribute(vtag, aname, (String) avalue);
+ aindex = group.findAttribute(aname);
+ if (aindex >= 0) {
+ group.set(aindex, avalue);
+ } else {
+ group.add(avalue);
+ }
+ return true;
+ case IppAttribute.TAG_UNKNOWN:
+ case IppAttribute.TAG_NO_VALUE:
+ break;
+ default:
+ break;
+ }
+
+ return false;
+ }
+
+ public byte[] getBytes() throws IppException{
+ ByteArrayOutputStream ab = new ByteArrayOutputStream();
+ DataOutputStream ba;
+ Iterator ai = values().iterator();
+ Object v;
+ IppAttributeGroup ag;
+ byte[] b;
+ Vector av = new Vector();
+
+ for (; ai.hasNext();) {
+ av.add(ai.next());
+ }
+ sortAttributes(av);
+
+ ba = new DataOutputStream(ab);
+
+ try {
+ for (int ii = av.size(), i = 0; i < ii; i++) {
+ v = av.get(i);
+ if (v != null && v instanceof Vector) {
+ for (int j = 0, jj = ((Vector) v).size(); j < jj; j++) {
+ ag = (IppAttributeGroup) ((Vector) v).get(j);
+ b = ag.getBytes();
+ ba.write(b);
+ }
+ } else {
+ ag = (IppAttributeGroup) v;
+ b = ag.getBytes();
+ ba.write(b);
+ }
+ }
+ ba.write(IppAttributeGroup.TAG_END_OF_ATTRIBUTES);
+ ba.flush();
+ ba.close();
+ } catch (IOException e) {
+ // e.printStackTrace();
+ throw new IppException(e.getMessage());
+ }
+
+ return ab.toByteArray();
+
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppAttributeGroupSet.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppByteBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppByteBuffer.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppByteBuffer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppByteBuffer.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,122 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+import java.nio.ByteBuffer;
+
+public class IppByteBuffer {
+ byte[] buf;
+ ByteBuffer bbuf;
+ int count = 0;
+
+ public IppByteBuffer() {
+ buf = new byte[512];
+ bbuf = ByteBuffer.wrap(buf);
+ }
+
+ public IppByteBuffer(byte[] rb) {
+ buf = new byte[rb.length];
+ bbuf = ByteBuffer.wrap(buf);
+
+ System.arraycopy(rb, 0, buf, 0, rb.length);
+ count = rb.length;
+ }
+
+ protected int addcapacity(int add) {
+ byte[] newbuf = new byte[buf.length + ((add / 512) + 1) * 512];
+ ByteBuffer newbbuf = ByteBuffer.wrap(newbuf);
+
+ System.arraycopy(buf, 0, newbuf, 0, buf.length);
+ buf = newbuf;
+ bbuf = newbbuf;
+
+ return buf.length;
+ }
+
+ public byte[] put(int index, byte value) {
+ if (index >= buf.length) {
+ addcapacity(index + 1 - buf.length);
+ }
+ //bbuf.put(index, value);
+ buf[index] = value;
+ count = (index + 1) > count ? index + 1 : count;
+
+ return buf;
+ }
+
+ public byte get(int index) {
+ return bbuf.get(index);
+ }
+
+ public byte[] put(int index, short value) {
+ if ((index + 2) > buf.length) {
+ addcapacity(index + 2 - buf.length);
+ }
+ bbuf.putShort(index, value);
+ count = (index + 2) > count ? index + 2 : count;
+
+ return buf;
+ }
+
+ public short getShort(int index) {
+ return bbuf.getShort(index);
+ }
+
+ public byte[] put(int index, int value) {
+ if ((index + 4) > buf.length) {
+ addcapacity(index + 4 - buf.length);
+ }
+ bbuf.putInt(index, value);
+ count = (index + 4) > count ? index + 4 : count;
+
+ return buf;
+ }
+
+ public int getInt(int index) {
+ return bbuf.getInt(index);
+ }
+
+ public byte[] put(int index, byte[] value) {
+ if ((index + value.length) > buf.length) {
+ addcapacity(index + value.length - buf.length);
+ }
+ System.arraycopy(value, 0, buf, index, value.length);
+ count = (index + value.length) > count ? index + value.length : count;
+
+ return buf;
+ }
+
+ public byte[] get(int index, int length) {
+ byte[] bb = new byte[length];
+
+ System.arraycopy(buf, index, bb, 0, length);
+ return bb;
+ }
+
+ public byte[] getBytes() {
+ return get(0, count);
+ }
+
+ public byte[] getBuf() {
+ return buf;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppByteBuffer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppClient.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppClient.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppClient.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppClient.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,266 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+/*
+ * IppClient is a print client based on IPP protocol.
+ * (see Internet Printing Protocol, http://www.pwg.org/ipp/index.html)
+ */
+
+
+public class IppClient {
+ protected static int verbose = 0;
+
+ protected URI uri;
+ protected URL url;
+ protected HttpURLConnection server;
+
+ public static int getVerbose() {
+ return verbose;
+ }
+
+ public static void setVerbose(int newverbose) {
+ verbose = newverbose;
+ }
+
+ public static void doVerbose(String v) {
+ System.out.println(v);
+ }
+
+ public static void doVerbose(int level, String v) {
+ if (verbose >= level) {
+ System.out.println(v);
+ }
+ }
+
+ public IppClient(URI clienturi) throws Exception {
+ this.uri = clienturi;
+ this.url = new URL("http", uri.getHost(), (uri.getPort() == -1 ? 631
+ : uri.getPort()), (uri.getPath() == null ? "" : uri.getPath()));
+ }
+
+ public void request(String method, String content_type) throws Exception {
+ connect();
+ server.setDoInput(true);
+ server.setDoOutput(true);
+ server.setRequestMethod(method);
+ server.setRequestProperty("Content-type", content_type);
+ server.setAllowUserInteraction(false);
+ server.connect();
+ }
+
+ public IppResponse request(byte[] data) throws Exception {
+ connect();
+ request("POST", "application/ipp", data);
+ IppResponse response = new IppResponse(response().toByteArray());
+ disconnect();
+
+ return response;
+ }
+
+ public IppResponse request(IppRequest request) throws Exception {
+ connect();
+ request("POST", "application/ipp", request);
+ IppResponse response = new IppResponse(response().toByteArray());
+ disconnect();
+
+ return response;
+ }
+
+ public void request(String method, String content_type, byte[] data)
+ throws Exception {
+ connect();
+ server.setDoInput(true);
+ server.setDoOutput(true);
+ server.setRequestMethod(method);
+ server.setRequestProperty("Content-type", content_type);
+ server.setAllowUserInteraction(false);
+ server.connect();
+
+ doVerbose(2, "IppClient.java: request(): Write data to output stream");
+ BufferedOutputStream bw = new BufferedOutputStream(server
+ .getOutputStream());
+ bw.write(data, 0, data.length);
+ bw.flush();
+ bw.close();
+ doVerbose(2, "IppClient.java: request(): Write " + data.length
+ + " bytes OK");
+ }
+
+ public void request(String method, String content_type, IppRequest request)
+ throws Exception {
+ connect();
+ server.setDoInput(true);
+ server.setDoOutput(true);
+ server.setRequestMethod(method);
+ server.setRequestProperty("Content-type", content_type);
+ server.setAllowUserInteraction(false);
+ server.connect();
+
+ doVerbose(2, "IppClient.java: request(): Write data to output stream");
+ DataOutputStream bw = new DataOutputStream(new BufferedOutputStream(
+ server.getOutputStream()));
+
+ byte[] data = request.getAgroups().getBytes();
+ Object document = request.getDocument();
+
+ bw.write(request.getVersion());
+ bw.writeShort(request.getOperationId());
+ bw.writeInt(request.getRequestId());
+ bw.write(data, 0, data.length);
+ doVerbose(2, "IppClient.java: request(): Write header OK");
+
+ if (document != null) {
+ if (document instanceof InputStream) {
+ InputStream stream = (InputStream) document;
+ byte[] buf = new byte[1024 * 8];
+ int count = 0;
+
+ doVerbose(
+ 2,
+ "IppClient.java: request(): Write document data to output stream from InpuStream");
+ while ((count = stream.read(buf, 0, buf.length - 10)) != -1) {
+ doVerbose(2, "IppClient.java: request(): Read " + count
+ + " bytes");
+ bw.write(buf, 0, count);
+ doVerbose(2, "IppClient.java: request(): Wrote " + count
+ + " bytes");
+ }
+ ((InputStream) document).close();
+ doVerbose(2, "IppClient.java: request(): Close InputStream");
+ } else if (document instanceof URL) {
+ URLConnection urlconnection = ((URL) document).openConnection();
+
+ doVerbose(2,
+ "IppClient.java: request(): Write document data to printer's stream from URL");
+ doVerbose(1, "IppClient.java: request(): document to print: "
+ + ((URL) document).toString());
+ try {
+ BufferedInputStream stream = new BufferedInputStream(
+ urlconnection.getInputStream());
+ byte[] buf = new byte[1024 * 8];
+ int count = 0;
+ while ((count = stream.read(buf, 0, buf.length)) != -1) {
+ doVerbose(2, "IppClient.java: request(): Read " + count
+ + " bytes from " + stream.toString());
+ bw.write(buf, 0, count);
+ doVerbose(2, "IppClient.java: request(): Wrote "
+ + count + " bytes");
+ }
+ stream.close();
+ doVerbose(2,
+ "IppClient.java: request(): Close InputStream "
+ + stream.toString());
+ } catch (IOException e) {
+ if (urlconnection instanceof HttpURLConnection
+ && ((HttpURLConnection) urlconnection)
+ .getResponseCode() == 401) {
+ throw new IppException(
+ "HTTP/1.x 401 Unauthorized access to \n\t"
+ + ((URL) document).toString());
+ }
+ throw e;
+ }
+ } else if (document instanceof byte[]) {
+ InputStream stream = new ByteArrayInputStream((byte[]) document);
+ byte[] buf = new byte[1024 * 8];
+ int count = 0;
+
+ while ((count = stream.read(buf, 0, buf.length)) != -1) {
+ bw.write(buf, 0, count);
+ }
+ stream.close();
+ } else if (document instanceof char[]) {
+ CharArrayReader stream = new CharArrayReader((char[]) document);
+ char[] buf = new char[1024 * 8];
+ int count = 0;
+
+ while ((count = stream.read(buf, 0, buf.length)) != -1) {
+ bw.writeChars(new String(buf, 0, count));
+ }
+ stream.close();
+ } else if (document instanceof String) {
+ bw.writeChars((String) document);
+ } else if (document instanceof Reader) {
+ char[] buf = new char[1024 * 8];
+ int count = 0;
+
+ while ((count = ((Reader) document).read(buf, 0, buf.length)) != -1) {
+ bw.writeChars(new String(buf, 0, count));
+ }
+ ((Reader) document).close();
+ }
+ }
+
+ bw.flush();
+ bw.close();
+ doVerbose(2, "IppClient.java: request(): Write OK");
+ }
+
+ public ByteArrayOutputStream response() throws Exception {
+ ByteArrayOutputStream resp = new ByteArrayOutputStream(1024);
+ byte[] buf = new byte[1024 * 8];
+ int hasread = 0;
+
+ doVerbose(2, "IppClient.java: response(): Read from server '"
+ + server.toString() + "' to ByteArrayOutputStream");
+ BufferedInputStream s = new BufferedInputStream(server.getInputStream());
+ while ((hasread = s.read(buf, 0, buf.length)) > 0) {
+ doVerbose(2, "IppClient.java: response(): Read " + hasread
+ + " bytes from BufferedInputStream");
+ resp.write(buf, 0, hasread);
+ doVerbose(2, "IppClient.java: response(): Write " + hasread
+ + " bytes to ByteArrayOutputStream");
+ }
+ s.close();
+ doVerbose(2, "IppClient.java: response(): Close BufferedInputStream");
+
+ return resp;
+ }
+
+ public HttpURLConnection connect() throws IOException {
+ if (server == null) {
+ //Authenticator.setDefault(new IppHttpAuthenticator());
+ server = (HttpURLConnection) url.openConnection();
+ }
+ return server;
+ }
+
+ public void disconnect() {
+ server.disconnect();
+ server = null;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppClient.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDefs.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDefs.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDefs.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDefs.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,403 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+/**
+ * This class represents Job and Printer Set Operations
+ * described in RFC 3380 (http://ietf.org/rfc/rfc3380.txt?number=3380)
+ */
+
+public class IppDefs {
+ public static final Object[] JOBTEMPLATEATTRIBUTES = { "job-priority",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-priority-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-priority-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+
+ "job-hold-until",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-hold-until-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-hold-until-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+
+ "job-sheets",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-sheets-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-sheets-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+
+ "multiple-document-handling",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "multiple-document-handling-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "multiple-document-handling-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+
+ "copies",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "copies-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "copies-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_RANGEOFINTEGER },
+
+ "finishings",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "finishings-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "finishings-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+
+ "page-ranges",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_RANGEOFINTEGER },
+ "page-ranges-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_BOOLEAN },
+
+ "sides",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "sides-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "sides-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+
+ "number-up",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "number-up-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "number-up-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+
+ "orientation-requested",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "orientation-requested-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "orientation-requested-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+
+ "media",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "media-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "media-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "media-ready",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+
+ "printer-resolution",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_RESOLUTION },
+ "printer-resolution-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_RESOLUTION },
+ "printer-resolution-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_RESOLUTION },
+
+ "print-quality",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "print-quality-default",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "print-quality-supported",
+ new byte[] { IppAttributeGroup.TAG_JOB_TEMPLATE_ATTRIBUTES,
+ IppAttribute.TAG_ENUM } };
+
+ public static final Object[] JOBDESCRIPTIONATTRIBUTES = { "job-uri",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "job-id",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-printer-uri",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "job-more-info",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+// "job-name",
+// new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+// IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "job-originating-user-name",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "job-state",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "job-state-reasons",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-state-message",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "job-detailed-status-messages",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "job-document-access-errors",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "number-of-documents",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "output-device-assigned",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "time-at-creation",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "time-at-processing",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "time-at-completed",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-printer-up-time",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "date-time-at-creation",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_DATETIME },
+ "date-time-at-processing",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_DATETIME },
+ "date-time-at-completed",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_DATETIME },
+ "number-of-intervening-jobs",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-message-from-operator",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "job-k-octets",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-impressions",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-media-sheets",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-k-octets-processed",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-impressions-completed",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "job-media-sheets-completed",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "attributes-charset",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_CHARSET },
+ "attributes-natural-language",
+ new byte[] { IppAttributeGroup.TAG_JOB_ATTRIBUTES,
+ IppAttribute.TAG_NATURAL_LANGUAGE } };
+
+ public static final Object[] PRINTERDESCRIPTIONATTRIBUTES = { "printer-uri-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "uri-security-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "uri-authentication-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "printer-name",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "printer-location",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "printer-info",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "printer-more-info",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "printer-driver-installer",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "printer-make-and-model",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "printer-more-info-manufacturer",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_URI },
+ "printer-state",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "printer-state-reasons",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "printer-state-message",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "ipp-versions-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "operations-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_ENUM },
+ "multiple-document-jobs-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_BOOLEAN },
+ "charset-configured",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_CHARSET },
+ "charset-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_CHARSET },
+ "natural-language-configured",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_NATURAL_LANGUAGE },
+ "generated-natural-language-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_NATURAL_LANGUAGE },
+ "document-format-default",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_MIMEMEDIATYPE },
+ "document-format-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_MIMEMEDIATYPE },
+ "printer-is-accepting-jobs",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_BOOLEAN },
+ "queued-job-count",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "printer-message-from-operator",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_TEXTWITHOUTLANGUAGE },
+ "color-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_BOOLEAN },
+ "reference-uri-schemes-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_URISCHEME },
+ "pdl-override-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "printer-up-time",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "printer-current-time",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_DATETIME },
+ "multiple-operation-time-out",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "compression-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_KEYWORD },
+ "job-k-octets-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_RANGEOFINTEGER },
+ "job-impressions-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_RANGEOFINTEGER },
+ "job-media-sheets-supported",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_RANGEOFINTEGER },
+ "pages-per-minute",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER },
+ "pages-per-minute-color",
+ new byte[] { IppAttributeGroup.TAG_PRINTER_ATTRIBUTES,
+ IppAttribute.TAG_INTEGER } };
+
+ public static final Object[] PRINTEROPERATIONATTRIBUTES = { "requesting-user-name",
+ new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "job-name",
+ new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE },
+ "document-name",
+ new byte[] { IppAttributeGroup.TAG_OPERATION_ATTRIBUTES,
+ IppAttribute.TAG_NAMEWITHOUTLANGUAGE } };
+
+ public static final Object[] ATAGS = { JOBTEMPLATEATTRIBUTES,
+ JOBDESCRIPTIONATTRIBUTES,
+ PRINTERDESCRIPTIONATTRIBUTES,
+ PRINTEROPERATIONATTRIBUTES };
+
+ // TODO need to tune for perfomance
+ public static byte getAttributeGtag(String aname) {
+ for (int ii = ATAGS.length, i = 0; i < ii; i += 1) {
+ Object[] atags = (Object[]) ATAGS[i];
+ for (int j = 0, jj = atags.length; j < jj; j+=2) {
+ if (aname.equals(atags[j])) {
+ return ((byte[]) atags[j + 1])[0];
+ }
+ }
+ }
+ return -1;
+ }
+
+ // TODO need to tune for perfomance
+ public static byte getAttributeVtag(String aname) {
+ for (int ii = ATAGS.length, i = 0; i < ii; i += 1) {
+ Object[] atags = (Object[]) ATAGS[i];
+ for (int j = 0, jj = atags.length; j < jj; j+=2) {
+ if (aname.equals(atags[j])) {
+ return ((byte[]) atags[j + 1])[1];
+ }
+ }
+ }
+ return -1;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDefs.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDocument.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDocument.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDocument.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDocument.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,118 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.harmony.x.print.ipp.util.IppMimeType;
+
+
+public class IppDocument {
+ static int doccount;
+
+ protected String docname;
+ protected String format; /* MIME type */
+ protected Object document; /* String or DataInputStream */
+ protected IppAttributeGroupSet agroups; /* all attributes as in IppRequest */
+
+ public IppDocument(String name, String mime, Object data)
+ throws IppException {
+ if (data != null
+ && mime != null
+ && (data instanceof InputStream || data instanceof byte[]
+ || data instanceof char[] || data instanceof String
+ || data instanceof Reader || data instanceof URL)) {
+ this.document = data;
+ this.format = new IppMimeType(mime).getIppSpecificForm();
+
+ if (name == null || name.equals("")) {
+ this.docname = new String(
+ (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("user.name");
+ }
+ })
+ + "-" + doccount);
+ } else {
+ this.docname = name;
+ }
+
+ this.agroups = new IppAttributeGroupSet();
+ } else {
+ throw new IppException("Wrong argument(s) for IPP document");
+ }
+ }
+
+ public IppAttributeGroupSet getAgroups() {
+ return agroups;
+ }
+
+ public void setAgroups(IppAttributeGroupSet attrgroups) {
+ this.agroups = attrgroups;
+ }
+
+ public String getName() {
+ return docname;
+ }
+
+ public void setName(String name) {
+ this.docname = name;
+ }
+
+ public Object getDocument() {
+ return document;
+ }
+
+ public void setDocument(Object data) throws IppException {
+ if (data instanceof InputStream || data instanceof byte[]
+ || data instanceof char[] || data instanceof String
+ || data instanceof Reader || data instanceof URL) {
+ this.document = data;
+ } else {
+ throw new IppException("Wrong type for IPP document");
+ }
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String mime) {
+ this.format = new IppMimeType(mime).getIppSpecificForm();
+ }
+
+ public boolean setAttribute(String aname, int avalue) {
+ return setAttribute(aname, new Integer(avalue));
+ }
+
+ public boolean setAttribute(String aname, String avalue) {
+ return setAttribute(aname, (Object) avalue);
+ }
+
+ public boolean setAttribute(String aname, Object avalue) {
+ return agroups.setAttribute(aname, avalue);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppDocument.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppException.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppException.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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+public class IppException extends Exception {
+ IppException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppException.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppOperation.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppOperation.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppOperation.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppOperation.java Sun Oct 8 22:33:09 2006
@@ -0,0 +1,88 @@
+/*
+ * 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.2 $
+ */
+
+package org.apache.harmony.x.print.ipp;
+
+public class IppOperation {
+ public static final short PRINT_JOB = 0x0002;
+ public static final short PRINT_URI = 0x0003;
+ public static final short VALIDATE_JOB = 0x0004;
+ public static final short CREATE_JOB = 0x0005;
+ public static final short SEND_DOCUMENT = 0x0006;
+ public static final short SEND_URI = 0x0007;
+ public static final short CANCEL_JOB = 0x0008;
+ public static final short GET_JOB_ATTRIBUTES = 0x0009;
+ public static final short GET_JOBS = 0x000A;
+ public static final short GET_PRINTER_ATTRIBUTES = 0x000B;
+ public static final short HOLD_JOB = 0x000C;
+ public static final short RELEASE_JOB = 0x000D;
+ public static final short RESTART_JOB = 0x000E;
+ public static final short RESERVED_FOR_A_FUTURE_OPERATION = 0x000F;
+ public static final short PAUSE_PRINTER = 0x0010;
+ public static final short RESUME_PRINTER = 0x0011;
+ public static final short PURGE_JOBS = 0x0012;
+ public static final short TAG_CUPS_GET_DEFAULT = 0x4001;
+ public static final short TAG_CUPS_GET_PRINTERS = 0x4002;
+
+ public static String getString(String op) {
+ return IppResources.getString("IppOperation." + op);
+ }
+
+ public static String getString(int op) {
+ switch (op) {
+ case PRINT_JOB:
+ return IppResources.getString("IppOperation.PRINT_JOB");
+ case PRINT_URI:
+ return IppResources.getString("IppOperation.PRINT_URI");
+ case VALIDATE_JOB:
+ return IppResources.getString("IppOperation.VALIDATE_JOB");
+ case CREATE_JOB:
+ return IppResources.getString("IppOperation.CREATE_JOB");
+ case SEND_DOCUMENT:
+ return IppResources.getString("IppOperation.SEND_DOCUMENT");
+ case SEND_URI:
+ return IppResources.getString("IppOperation.SEND_URI");
+ case CANCEL_JOB:
+ return IppResources.getString("IppOperation.CANCEL_JOB");
+ case GET_JOB_ATTRIBUTES:
+ return IppResources.getString("IppOperation.GET_JOB_ATTRIBUTES");
+ case GET_JOBS:
+ return IppResources.getString("IppOperation.GET_JOBS");
+ case GET_PRINTER_ATTRIBUTES:
+ return IppResources.getString("IppOperation.GET_PRINTER_ATTRIBUTES");
+ case HOLD_JOB:
+ return IppResources.getString("IppOperation.HOLD_JOB");
+ case RELEASE_JOB:
+ return IppResources.getString("IppOperation.RELEASE_JOB");
+ case RESTART_JOB:
+ return IppResources.getString("IppOperation.RESTART_JOB");
+ case RESERVED_FOR_A_FUTURE_OPERATION:
+ return IppResources.getString("IppOperation.RESERVED_FOR_A_FUTURE_OPERATION");
+ case PAUSE_PRINTER:
+ return IppResources.getString("IppOperation.PAUSE_PRINTER");
+ case RESUME_PRINTER:
+ return IppResources.getString("IppOperation.RESUME_PRINTER");
+ case PURGE_JOBS:
+ return IppResources.getString("IppOperation.PURGE_JOBS");
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/main/java/common/org/apache/harmony/x/print/ipp/IppOperation.java
------------------------------------------------------------------------------
svn:executable = *