Source Code Cross Referenced for UUIDListBox.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » com » sun » media » imageioimpl » plugins » jpeg2000 » 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 » 6.0 JDK Modules » Java Advanced Imaging » com.sun.media.imageioimpl.plugins.jpeg2000 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: UUIDListBox.java,v $
003:         *
004:         * 
005:         * Copyright (c) 2005 Sun Microsystems, Inc. All  Rights Reserved.
006:         * 
007:         * Redistribution and use in source and binary forms, with or without
008:         * modification, are permitted provided that the following conditions
009:         * are met: 
010:         * 
011:         * - Redistribution of source code must retain the above copyright 
012:         *   notice, this  list of conditions and the following disclaimer.
013:         * 
014:         * - Redistribution in binary form must reproduce the above copyright
015:         *   notice, this list of conditions and the following disclaimer in 
016:         *   the documentation and/or other materials provided with the
017:         *   distribution.
018:         * 
019:         * Neither the name of Sun Microsystems, Inc. or the names of 
020:         * contributors may be used to endorse or promote products derived 
021:         * from this software without specific prior written permission.
022:         * 
023:         * This software is provided "AS IS," without a warranty of any 
024:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND 
025:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
026:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
027:         * EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL 
028:         * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 
029:         * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
030:         * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR 
031:         * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
032:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
033:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
034:         * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
035:         * POSSIBILITY OF SUCH DAMAGES. 
036:         * 
037:         * You acknowledge that this software is not designed or intended for 
038:         * use in the design, construction, operation or maintenance of any 
039:         * nuclear facility. 
040:         *
041:         * $Revision: 1.2 $
042:         * $Date: 2006/10/10 23:48:57 $
043:         * $State: Exp $
044:         */
045:        package com.sun.media.imageioimpl.plugins.jpeg2000;
046:
047:        import javax.imageio.metadata.IIOInvalidTreeException;
048:        import javax.imageio.metadata.IIOMetadataNode;
049:        import org.w3c.dom.Node;
050:        import org.w3c.dom.NodeList;
051:
052:        import com.sun.media.imageioimpl.common.ImageUtil;
053:
054:        /** This class is defined to represent a UUID list Box of JPEG JP2
055:         *  file format.  This type of box has a length, a type of "ulst".  Its
056:         *  contents include the number of UUID entry and a list of 16-byte UUIDs.
057:         */
058:        public class UUIDListBox extends Box {
059:            /** The data elements of this box. */
060:            private short num;
061:            private byte[][] uuids;
062:
063:            /** Constructs a <code>UUIDListBox</code> from the provided uuid number
064:             *  and uuids.  The provided uuids should have a size of 16; otherwise,
065:             *  <code>Exception</code> may thrown in later the process.  The provided
066:             *  number should consistent with the size of the uuid array.
067:             */
068:            public UUIDListBox(short num, byte[][] uuids) {
069:                super (10 + (uuids.length << 4), 0x756c7374, null);
070:                this .num = num;
071:                this .uuids = uuids;
072:            }
073:
074:            /** Constructs a <code>UUIDListBox</code> from the provided content
075:             *  data array.
076:             */
077:            public UUIDListBox(byte[] data) {
078:                super (8 + data.length, 0x756c7374, data);
079:            }
080:
081:            /** Constructs a <code>UUIDListBox</code> based on the provided
082:             *  <code>org.w3c.dom.Node</code>.
083:             */
084:            public UUIDListBox(Node node) throws IIOInvalidTreeException {
085:                super (node);
086:                NodeList children = node.getChildNodes();
087:                int index = 0;
088:
089:                for (int i = 0; i < children.getLength(); i++) {
090:                    Node child = children.item(i);
091:
092:                    if ("NumberUUID".equals(child.getNodeName())) {
093:                        num = (short) Box.getShortElementValue(child);
094:                        uuids = new byte[num][];
095:                    }
096:
097:                }
098:
099:                for (int i = 0; i < children.getLength(); i++) {
100:                    Node child = children.item(i);
101:
102:                    if ("UUID".equals(child.getNodeName()) && index < num) {
103:                        uuids[index++] = Box.getByteArrayElementValue(child);
104:                    }
105:                }
106:            }
107:
108:            /** Parses the data elements from the provided content data array. */
109:            protected void parse(byte[] data) {
110:                num = (short) (((data[0] & 0xFF) << 8) | (data[1] & 0xFF));
111:
112:                uuids = new byte[num][];
113:                int pos = 2;
114:                for (int i = 0; i < num; i++) {
115:                    uuids[i] = new byte[16];
116:                    System.arraycopy(data, pos, uuids[i], 0, 16);
117:                    pos += 16;
118:                }
119:            }
120:
121:            /** Creates an <code>IIOMetadataNode</code> from this UUID list
122:             *  box.  The format of this node is defined in the XML dtd and xsd
123:             *  for the JP2 image file.
124:             */
125:            public IIOMetadataNode getNativeNode() {
126:                IIOMetadataNode node = new IIOMetadataNode(Box
127:                        .getName(getType()));
128:                setDefaultAttributes(node);
129:
130:                IIOMetadataNode child = new IIOMetadataNode("NumberUUID");
131:                child.setUserObject(new Short(num));
132:                child.setNodeValue("" + num);
133:                node.appendChild(child);
134:
135:                for (int i = 0; i < num; i++) {
136:                    child = new IIOMetadataNode("UUID");
137:                    child.setUserObject(uuids[i]);
138:                    child.setNodeValue(ImageUtil
139:                            .convertObjectToString(uuids[i]));
140:                    node.appendChild(child);
141:                }
142:
143:                return node;
144:            }
145:
146:            protected void compose() {
147:                if (data != null)
148:                    return;
149:                data = new byte[2 + num * 16];
150:
151:                data[0] = (byte) (num >> 8);
152:                data[1] = (byte) (num & 0xFF);
153:
154:                for (int i = 0, pos = 2; i < num; i++) {
155:                    System.arraycopy(uuids[i], 0, data, pos, 16);
156:                    pos += 16;
157:                }
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.