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


001:        /*
002:         * $RCSfile: CaselessStringArrayTable.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:56:59 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.util;
013:
014:        import java.util.Hashtable;
015:        import javax.media.jai.util.CaselessStringKey;
016:
017:        /**
018:         * A class that maps an array of <code>String</code>s or 
019:         * <code>CaselessStringKey</code>s into the array indices and
020:         * vice versa (all in a caseless fashion).
021:         *
022:         * This is used to map source names and parameter names to their
023:         * indices in a case insensitive fashion.
024:         */
025:        public class CaselessStringArrayTable implements  java.io.Serializable {
026:
027:            private CaselessStringKey[] keys;
028:            private Hashtable indices;
029:
030:            /**
031:             * Constructor for an array of <code>CaselessStringKey</code>s.
032:             */
033:            public CaselessStringArrayTable() {
034:                this ((CaselessStringKey[]) null);
035:            }
036:
037:            /**
038:             * Constructor for an array of <code>CaselessStringKey</code>s.
039:             */
040:            public CaselessStringArrayTable(CaselessStringKey[] keys) {
041:
042:                this .keys = keys;
043:                this .indices = new Hashtable();
044:
045:                if (keys != null)
046:                    for (int i = 0; i < keys.length; i++) {
047:                        this .indices.put(keys[i], new Integer(i));
048:                    }
049:            }
050:
051:            /**
052:             * Constructor for an array of <code>String</code>s.
053:             */
054:            public CaselessStringArrayTable(String[] keys) {
055:                this (toCaselessStringKey(keys));
056:            }
057:
058:            /**
059:             * Map an array of <code>String</code>s to <code>CaselessStringKey</code>s.
060:             */
061:            private static CaselessStringKey[] toCaselessStringKey(
062:                    String strings[]) {
063:                if (strings == null)
064:                    return null;
065:
066:                CaselessStringKey[] keys = new CaselessStringKey[strings.length];
067:
068:                for (int i = 0; i < strings.length; i++)
069:                    keys[i] = new CaselessStringKey(strings[i]);
070:
071:                return keys;
072:            }
073:
074:            /**
075:             * Get the index of the specified key.
076:             *
077:             * @throws IllegalArgumentException if the key is <code>null or
078:             *	if the key is not found.
079:             */
080:            public int indexOf(CaselessStringKey key) {
081:                if (key == null) {
082:                    throw new IllegalArgumentException(JaiI18N
083:                            .getString("CaselessStringArrayTable0"));
084:                }
085:
086:                Integer i = (Integer) indices.get(key);
087:
088:                if (i == null) {
089:                    throw new IllegalArgumentException(key.getName() + " - "
090:                            + JaiI18N.getString("CaselessStringArrayTable1"));
091:                }
092:
093:                return i.intValue();
094:            }
095:
096:            /**
097:             * Get the index of the specified key.
098:             *
099:             * @throws IllegalArgumentException if the key is <code>null or
100:             *	if the key is not found.
101:             */
102:            public int indexOf(String key) {
103:                return indexOf(new CaselessStringKey(key));
104:            }
105:
106:            /**
107:             * Get the <code>String</code> corresponding to the index <code>i</code>.
108:             *
109:             * @throws ArrayIndexOutOfBoundsException if <code>i</code> is out of range.
110:             */
111:            public String getName(int i) {
112:                if (keys == null)
113:                    throw new ArrayIndexOutOfBoundsException();
114:
115:                return keys[i].getName();
116:            }
117:
118:            /**
119:             * Get the <code>CaselessStringKey</code> corresponding to the
120:             * index <code>i</code>.
121:             *
122:             * @throws ArrayIndexOutOfBoundsException if <code>i</code> is out of range.
123:             */
124:            public CaselessStringKey get(int i) {
125:                if (keys == null)
126:                    throw new ArrayIndexOutOfBoundsException();
127:
128:                return keys[i];
129:            }
130:
131:            /**
132:             * Tests if this table contains the specified key.
133:             *
134:             * @return true if the key is present. false otherwise.
135:             */
136:            public boolean contains(CaselessStringKey key) {
137:                if (key == null) {
138:                    throw new IllegalArgumentException(JaiI18N
139:                            .getString("CaselessStringArrayTable0"));
140:                }
141:
142:                return indices.get(key) != null;
143:            }
144:
145:            /**
146:             * Tests if this table contains the specified key.
147:             *
148:             * @return true if the key is present. false otherwise.
149:             */
150:            public boolean contains(String key) {
151:                return contains(new CaselessStringKey(key));
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.