]>
git.ipfire.org Git - thirdparty/cups.git/blob - scripting/java/src/com/easysw/cups/IPP.java
c5a4e1ba8f224f20052da17ed99b2f5b7ecbc49d
1 package com
.easysw
.cups
;
4 * @version 0.00 06-NOV-2001
7 * Internet Printing Protocol definitions for the Common UNIX Printing
10 * Copyright 2007 by Apple Inc.
11 * Copyright 1997-2002 by Easy Software Products.
13 * These coded instructions, statements, and computer programs are the
14 * property of Apple Inc. and are protected by Federal copyright
15 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
16 * which should have been included with this file. If this file is
17 * file is missing or damaged, see the license at "http://www.cups.org/".
23 * An <code>IPP</code> object is used to hold the various
24 * attributes and status of an ipp request..
32 public IPPRequest request
; // The request header
33 public IPPStatus status
; // Status of request
34 public List attrs
; // Attributes list.
36 short state
; // Current IPP state (of request???)
37 int current
; // Index into attributes array.
38 int last
; // Index into attributes array.
42 // ------------------------------------------------------------------
49 attrs
= new LinkedList();
52 current_tag
= IPPDefs
.TAG_ZERO
;
58 * Add an attribute to the attibutes list
61 * @param a <code>IPPAttribute</code> to add.
62 * @return <code>true</code> always returns <code>true</code>
68 public boolean addAttribute( IPPAttribute a
)
75 * Get the current attribute pointed at by
76 * <code>current</code>.
78 * @return <code>IPPAttribute</code> Return the current attribute.
79 * @return <code>null</code> Return <code>null</code>
80 * if <code>current</code> is 0.
82 public IPPAttribute
getCurrentAttribute()
85 return( (IPPAttribute
)attrs
.get(current
) );
90 // public void setCurrentAttribute( IPPAttribute p_attr )
93 // return( (IPPAttribute)attrs.get(current) );
99 * Find the named attribute of the correct type. Both must match.
100 * This methos searches from the beginning of the attribute list,
101 * rather than from the current position.
103 * @param p_name <code>String</code> containing the name.
104 * @param p_type <code>int</code> attribute type.
106 * @return <code>IPPAttribute</code> Matching attribute if found.
107 * @return <code>null</code> <code>null</code> if not found.
109 public IPPAttribute
ippFindAttribute( String p_name
, int p_type
)
111 if (p_name
.length() < 1)
114 return(ippFindNextAttribute(p_name
, p_type
));
122 * Find the named attribute of the correct type. Both must match.
123 * This methos searches from the current position in the attribute list.
125 * @param p_name <code>String</code> containing the name.
126 * @param p_type <code>int</code> attribute type.
128 * @return <code>IPPAttribute</code> Matching attribute if found.
129 * @return <code>null</code> <code>null</code> if not found.
131 public IPPAttribute
ippFindNextAttribute( String p_name
, int p_type
)
135 if (p_name
.length() < 1)
138 if ((current
>= 0) && (current
< (attrs
.size() - 1)))
143 for (int i
= current
; i
< attrs
.size(); i
++)
145 IPPAttribute tmp
= (IPPAttribute
)attrs
.get(i
);
146 value_tag
= (tmp
.value_tag
& IPPDefs
.TAG_MASK
);
147 if ((tmp
.name
.length() > 0) && (tmp
.name
== p_name
) &&
148 (value_tag
== p_type
|| p_type
== IPPDefs
.TAG_ZERO
||
149 (value_tag
== IPPDefs
.TAG_TEXTLANG
&& p_type
== IPPDefs
.TAG_TEXT
) ||
150 (value_tag
== IPPDefs
.TAG_NAMELANG
&& p_type
== IPPDefs
.TAG_NAME
)))
161 * Get the size in bytes of an <code>IPP</code> request.
163 * @return <code>int</code> Number of bytes for the request.
165 public int sizeInBytes()
169 int last_group
= IPPDefs
.TAG_ZERO
;
171 for (int i
=0; i
< attrs
.size(); i
++)
173 a
= (IPPAttribute
)attrs
.get(i
);
174 bytes
+= a
.sizeInBytes(last_group
);
175 last_group
= a
.group_tag
;
177 bytes
++; // one for the end tag.
181 } // End of IPP.sizeInBytes()
196 * Set the <code>IPP</code> request ID.
198 * @param p_id <code>short</code> request id.
200 public void setRequestID( short p_id
)
202 request
.request_id
= p_id
;
206 * Set the <code>IPP</code> operation ID.
208 * @param p_operation_id <code>short</code> operation id.
210 public void setRequestOperationID( short p_operation_id
)
212 request
.operation_id
= p_operation_id
;
217 // Dump a list - for debugging.
219 public void dump_response()
222 int last_group
= IPPDefs
.TAG_ZERO
;
224 for (int i
=0; i
< attrs
.size(); i
++)
226 a
= (IPPAttribute
)attrs
.get(i
);
228 last_group
= a
.group_tag
;
232 } // End of IPP.dump_response()
235 } // End of IPP class