Source Code Cross Referenced for IppAttributeGroup.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » x » print » ipp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.x.print.ipp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        package org.apache.harmony.x.print.ipp;
018:
019:        import java.io.ByteArrayOutputStream;
020:        import java.io.DataOutputStream;
021:        import java.io.IOException;
022:        import java.util.Vector;
023:
024:        /*
025:         * class IppAttributeGroup stores IPP attributes group
026:         */
027:        public class IppAttributeGroup extends Vector {
028:
029:            static final long serialVersionUID = -2197671478629444252L;
030:
031:            /* According to RFC2910 (http://ietf.org/rfc/rfc2910.txt?number=2910):
032:             *
033:             * Each "attribute-group" field MUST be encoded with the "begin-
034:             * attribute-group-tag" field followed by zero or more "attribute" sub-
035:             * fields.
036:             * 
037:             * The table below maps the model document group name to value of the
038:             * "begin-attribute-group-tag" field:
039:             * 
040:             * Model Document Group "begin-attribute-group-tag" field values
041:             * 
042:             * Operation Attributes "operations-attributes-tag" 
043:             * Job Template Attributes "job-attributes-tag" 
044:             * Job Object Attributes "job-attributes-tag" 
045:             * Requested Attributes "job-attributes-tag" (Get-Job-Attributes) 
046:             * Requested Attributes "printer-attributes-tag" (Get-Printer-Attributes) 
047:             * Unsupported Attributes * "unsupported-attributes-tag" 
048:             * Document Content in a special position as described above
049:             * 
050:             * 0x00 reserved for definition in a future IETF standards track document
051:             * 0x01 "operation-attributes-tag" 
052:             * 0x02 "job-attributes-tag" 
053:             * 0x03 "end-of-attributes-tag" 
054:             * 0x04 "printer-attributes-tag" 
055:             * 0x05 "unsupported-attributes-tag" 
056:             * 0x06-0x0f reserved for future delimiters in
057:             * IETF standards track documents
058:             */
059:            public static final byte TAG_RESERVED = 0x00;
060:            public static final byte TAG_OPERATION_ATTRIBUTES = 0x01;
061:            public static final byte TAG_JOB_ATTRIBUTES = 0x02;
062:            public static final byte TAG_JOB_TEMPLATE_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
063:            public static final byte TAG_JOB_OBJECT_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
064:            public static final byte TAG_GET_JOB_ATTRIBUTES = TAG_JOB_ATTRIBUTES;
065:            public static final byte TAG_END_OF_ATTRIBUTES = 0x03;
066:            public static final byte TAG_PRINTER_ATTRIBUTES = 0x04;
067:            public static final byte TAG_GET_PRINTER_ATTRIBUTES = TAG_PRINTER_ATTRIBUTES;
068:            public static final byte TAG_UNSUPPORTED_ATTRIBUTES = 0x05;
069:
070:            /*
071:             * @return Returns the name of the group.
072:             */
073:            public static String getGname(int agid) {
074:                switch (agid) {
075:                case TAG_RESERVED:
076:                    return IppResources
077:                            .getString("IppAttributesGroup.RESERVED");
078:                case TAG_OPERATION_ATTRIBUTES:
079:                    return IppResources
080:                            .getString("IppAttributesGroup.OPERATION_ATTRIBUTES");
081:                case TAG_JOB_ATTRIBUTES:
082:                    return IppResources
083:                            .getString("IppAttributesGroup.JOB_TEMPLATE_ATTRIBUTES");
084:                case TAG_PRINTER_ATTRIBUTES:
085:                    return IppResources
086:                            .getString("IppAttributesGroup.GET_PRINTER_ATTRIBUTES");
087:                case TAG_END_OF_ATTRIBUTES:
088:                    return IppResources
089:                            .getString("IppAttributesGroup.END_OF_ATTRIBUTES");
090:                case TAG_UNSUPPORTED_ATTRIBUTES:
091:                    return IppResources
092:                            .getString("IppAttributesGroup.UNSUPPORTED_ATTRIBUTES");
093:                }
094:                return "UNKNOWN_ATTRIBUTES";
095:            }
096:
097:            protected int agroupid;
098:
099:            public IppAttributeGroup(int agid) {
100:                super ();
101:                this .agroupid = agid;
102:            }
103:
104:            public IppAttributeGroup(Integer agid) {
105:                super ();
106:                this .agroupid = agid.byteValue();
107:            }
108:
109:            /*
110:             * change/add attributes in this group by attributes from parameter
111:             */
112:            public int set(IppAttributeGroup ag) {
113:                if (ag != null && agroupid == ag.agroupid && ag.size() > 0) {
114:                    int i1;
115:                    IppAttribute a;
116:
117:                    for (int ii = ag.size(), i = 0; i < ii; i++) {
118:                        a = (IppAttribute) ag.get(i);
119:                        i1 = findAttribute(new String(a.aname));
120:                        if (i1 >= 0) {
121:                            set(i1, a);
122:                        } else {
123:                            add(a);
124:                        }
125:                    }
126:                }
127:
128:                return size();
129:            }
130:
131:            public int findAttribute(String name) {
132:                for (int ii = size(), i = 0; i < ii; i++) {
133:                    if (name.equals(new String(((IppAttribute) get(i)).aname))) {
134:                        return i;
135:                    }
136:                }
137:
138:                return -1;
139:            }
140:
141:            /*
142:             * return array of byte presentation of group
143:             */
144:            public byte[] getBytes() {
145:                ByteArrayOutputStream ba = new ByteArrayOutputStream();
146:                IppAttribute a;
147:                byte[] b;
148:
149:                ba.write((byte) agroupid);
150:                for (int ii = size(), i = 0; i < ii; i++) {
151:                    a = (IppAttribute) get(i);
152:                    b = a.getBytes();
153:                    ba.write(b, 0, b.length);
154:                }
155:                return ba.toByteArray();
156:            }
157:
158:            /*
159:             * human readable form of group
160:             * 
161:             * @see java.lang.Object#toString()
162:             */
163:            public String toString() {
164:                ByteArrayOutputStream ab = new ByteArrayOutputStream();
165:                DataOutputStream ba = new DataOutputStream(ab);
166:                IppAttribute a;
167:                String s;
168:
169:                try {
170:                    ba.writeBytes("---- Attributes group: 0x"
171:                            + Integer.toHexString(agroupid) + "("
172:                            + getGname(agroupid) + ")" + "\n");
173:                    for (int ii = size(), i = 0; i < ii; i++) {
174:                        a = (IppAttribute) get(i);
175:                        s = a.toString();
176:                        ba.writeBytes(s + "\n");
177:                    }
178:                } catch (IOException e) {
179:                    // IGNORE exception
180:                    e.printStackTrace();
181:                }
182:
183:                return ab.toString();
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.