]>
git.ipfire.org Git - thirdparty/cups.git/blob - scripting/java/src/com/easysw/cups/IPP.java
1 package com
.easysw
.cups
;
4 * @version 0.00 06-NOV-2001
5 * @author Easy Software Products
7 * Internet Printing Protocol definitions for the Common UNIX Printing
10 * Copyright 1997-2002 by Easy Software Products.
12 * These coded instructions, statements, and computer programs are the
13 * property of Easy Software Products and are protected by Federal
14 * copyright law. Distribution and use rights are outlined in the file
15 * "LICENSE.txt" which should have been included with this file. If this
16 * file is missing or damaged please contact Easy Software Products
19 * Attn: CUPS Licensing Information
20 * Easy Software Products
21 * 44141 Airport View Drive, Suite 204
22 * Hollywood, Maryland 20636-3111 USA
24 * Voice: (301) 373-9603
25 * EMail: cups-info@cups.org
26 * WWW: http://www.cups.org
32 * An <code>IPP</code> object is used to hold the various
33 * attributes and status of an ipp request..
41 public IPPRequest request
; // The request header
42 public IPPStatus status
; // Status of request
43 public List attrs
; // Attributes list.
45 short state
; // Current IPP state (of request???)
46 int current
; // Index into attributes array.
47 int last
; // Index into attributes array.
51 // ------------------------------------------------------------------
58 attrs
= new LinkedList();
61 current_tag
= IPPDefs
.TAG_ZERO
;
67 * Add an attribute to the attibutes list
70 * @param a <code>IPPAttribute</code> to add.
71 * @return <code>true</code> always returns <code>true</code>
77 public boolean addAttribute( IPPAttribute a
)
84 * Get the current attribute pointed at by
85 * <code>current</code>.
87 * @return <code>IPPAttribute</code> Return the current attribute.
88 * @return <code>null</code> Return <code>null</code>
89 * if <code>current</code> is 0.
91 public IPPAttribute
getCurrentAttribute()
94 return( (IPPAttribute
)attrs
.get(current
) );
99 // public void setCurrentAttribute( IPPAttribute p_attr )
102 // return( (IPPAttribute)attrs.get(current) );
108 * Find the named attribute of the correct type. Both must match.
109 * This methos searches from the beginning of the attribute list,
110 * rather than from the current position.
112 * @param p_name <code>String</code> containing the name.
113 * @param p_type <code>int</code> attribute type.
115 * @return <code>IPPAttribute</code> Matching attribute if found.
116 * @return <code>null</code> <code>null</code> if not found.
118 public IPPAttribute
ippFindAttribute( String p_name
, int p_type
)
120 if (p_name
.length() < 1)
123 return(ippFindNextAttribute(p_name
, p_type
));
131 * Find the named attribute of the correct type. Both must match.
132 * This methos searches from the current position in the attribute list.
134 * @param p_name <code>String</code> containing the name.
135 * @param p_type <code>int</code> attribute type.
137 * @return <code>IPPAttribute</code> Matching attribute if found.
138 * @return <code>null</code> <code>null</code> if not found.
140 public IPPAttribute
ippFindNextAttribute( String p_name
, int p_type
)
144 if (p_name
.length() < 1)
147 if ((current
>= 0) && (current
< (attrs
.size() - 1)))
152 for (int i
= current
; i
< attrs
.size(); i
++)
154 IPPAttribute tmp
= (IPPAttribute
)attrs
.get(i
);
155 value_tag
= (tmp
.value_tag
& IPPDefs
.TAG_MASK
);
156 if ((tmp
.name
.length() > 0) && (tmp
.name
== p_name
) &&
157 (value_tag
== p_type
|| p_type
== IPPDefs
.TAG_ZERO
||
158 (value_tag
== IPPDefs
.TAG_TEXTLANG
&& p_type
== IPPDefs
.TAG_TEXT
) ||
159 (value_tag
== IPPDefs
.TAG_NAMELANG
&& p_type
== IPPDefs
.TAG_NAME
)))
170 * Get the size in bytes of an <code>IPP</code> request.
172 * @return <code>int</code> Number of bytes for the request.
174 public int sizeInBytes()
178 int last_group
= IPPDefs
.TAG_ZERO
;
180 for (int i
=0; i
< attrs
.size(); i
++)
182 a
= (IPPAttribute
)attrs
.get(i
);
183 bytes
+= a
.sizeInBytes(last_group
);
184 last_group
= a
.group_tag
;
186 bytes
++; // one for the end tag.
190 } // End of IPP.sizeInBytes()
205 * Set the <code>IPP</code> request ID.
207 * @param p_id <code>short</code> request id.
209 public void setRequestID( short p_id
)
211 request
.request_id
= p_id
;
215 * Set the <code>IPP</code> operation ID.
217 * @param p_operation_id <code>short</code> operation id.
219 public void setRequestOperationID( short p_operation_id
)
221 request
.operation_id
= p_operation_id
;
226 // Dump a list - for debugging.
228 public void dump_response()
231 int last_group
= IPPDefs
.TAG_ZERO
;
233 for (int i
=0; i
< attrs
.size(); i
++)
235 a
= (IPPAttribute
)attrs
.get(i
);
237 last_group
= a
.group_tag
;
241 } // End of IPP.dump_response()
244 } // End of IPP class