Source Code Cross Referenced for HyperTextFilter.java in  » Portal » Open-Portal » graphical » 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 » Portal » Open Portal » graphical 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *	NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *	Copyright (c) 1996 Netscape Communications Corporation.
006:         *	All Rights Reserved.
007:         *	Use of this Source Code is subject to the terms of the applicable
008:         *	license agreement from Netscape Communications Corporation.
009:         */
010:
011:        package graphical;
012:
013:        import java.util.Hashtable;
014:        import netscape.application.KeyEvent;
015:        import netscape.application.TextFilter;
016:        import netscape.util.Vector;
017:        import util.Key;
018:
019:        /**
020:         * Encapsulate up the TextFilter for simple rejection/acceptance
021:         * handling based on a list.
022:         * Can be set to be either inclusive, accepting only characters
023:         * on the list, or exclusive, rejecting only characters on
024:         * the list.
025:         */
026:        public class HyperTextFilter implements  TextFilter {
027:            /**
028:             * Hashtable of values to be handled by the filter.
029:             * The key is assumed to be an Integer representing
030:             * the keyboard value,
031:             * the value is assumed to be a Character representing
032:             * the keyboard value.
033:             * @see #java.lang.Character
034:             * @see #java.lang.Integer
035:             */
036:            private Hashtable hashTable;
037:
038:            /**
039:             * If inclusive is true and the KeyEvent character is
040:             * on the list it is accepted; if inclusive is false
041:             * and the KeyEvent character is not on the list,
042:             * it is accepted; otherwise, it is rejected.
043:             */
044:            public boolean inclusive;
045:
046:            /**
047:             * If debug is true, print characters and accept or
048:             * reject status.
049:             */
050:            public boolean debug;
051:
052:            /**
053:             * Constructor.
054:             */
055:            public HyperTextFilter() {
056:                hashTable = new Hashtable();
057:                inclusive = true;
058:                debug = false;
059:            }
060:
061:            /**
062:             * Constructor.
063:             * @param n number of anticipated characters in the filter
064:             * @param b set value of the inclusive attribute
065:             */
066:            public HyperTextFilter(int n, boolean b) {
067:                hashTable = new Hashtable(n);
068:                inclusive = b;
069:            }
070:
071:            /**
072:             * Create a default inclusive alphanumeric filter.
073:             */
074:            public static HyperTextFilter createAlphaNumericFilter() {
075:                return createAlphaNumericFilter(Key.ALPHANUMERIC_COUNT, true);
076:            }
077:
078:            /**
079:             * Create an alphanumeric filter.
080:             * @param n number of slots in the filter
081:             * @param b inclusiveness
082:             */
083:            public static HyperTextFilter createAlphaNumericFilter(int n,
084:                    boolean b) {
085:                HyperTextFilter htf = new HyperTextFilter();
086:                htf.hashTable = Key.alphanumerics(n);
087:                htf.inclusive = b;
088:                return htf;
089:            }
090:
091:            /**
092:             * Create a default inclusive i18n alphanumeric filter.
093:             */
094:            public static HyperTextFilter createI18NAlphaNumericFilter() {
095:                return createI18NAlphaNumericFilter(Key.I18NALPHANUMERIC_COUNT,
096:                        true);
097:            }
098:
099:            /**
100:             * Create an i18n alphanumeric filter.
101:             * @param n number of slots in the filter
102:             * @param b inclusiveness
103:             */
104:            public static HyperTextFilter createI18NAlphaNumericFilter(int n,
105:                    boolean b) {
106:                HyperTextFilter htf = new HyperTextFilter();
107:                htf.hashTable = Key.i18nalphanumerics(n);
108:                htf.inclusive = b;
109:                return htf;
110:            }
111:
112:            /**
113:             * Determine whether to accept keystroke event.
114:             */
115:            public boolean acceptsEvent(Object textObject, KeyEvent event,
116:                    Vector events) {
117:                boolean accept = hashTable.containsKey(new Integer(event.key)) == inclusive;
118:                if (debug)
119:                    System.out.println("key: " + event.key
120:                            + (accept ? " accept" : " reject"));
121:                return accept;
122:            }
123:
124:            public void put(Integer i, Character c) {
125:                hashTable.put(i, c);
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.