Source Code Cross Referenced for PrefixedStringCodecFactory.java in  » Net » mina-2.0.0-M1 » org » apache » mina » filter » codec » prefixedstring » 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 » Net » mina 2.0.0 M1 » org.apache.mina.filter.codec.prefixedstring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.mina.filter.codec.prefixedstring;
002:
003:        import org.apache.mina.common.IoSession;
004:        import org.apache.mina.common.BufferDataException;
005:        import org.apache.mina.filter.codec.ProtocolCodecFactory;
006:        import org.apache.mina.filter.codec.ProtocolDecoder;
007:        import org.apache.mina.filter.codec.ProtocolEncoder;
008:
009:        import java.nio.charset.Charset;
010:
011:        /**
012:         * A {@link ProtocolCodecFactory} that performs encoding and decoding
013:         * of a Java String object using a fixed-length length prefix.
014:         *
015:         * @author The Apache MINA Project (dev@mina.apache.org)
016:         * @version $Rev: 596187 $, $Date: 2007-11-19 04:41:14 +0100 (ma, 19 nov 2007) $
017:         */
018:        public class PrefixedStringCodecFactory implements  ProtocolCodecFactory {
019:
020:            private final PrefixedStringEncoder encoder;
021:
022:            private final PrefixedStringDecoder decoder;
023:
024:            public PrefixedStringCodecFactory(Charset charset) {
025:                encoder = new PrefixedStringEncoder(charset);
026:                decoder = new PrefixedStringDecoder(charset);
027:            }
028:
029:            public PrefixedStringCodecFactory() {
030:                this (Charset.defaultCharset());
031:            }
032:
033:            /**
034:             * Returns the allowed maximum size of an encoded string.
035:             * If the size of the encoded String exceeds this value, the encoder
036:             * will throw a {@link IllegalArgumentException}.
037:             * The default value is {@link PrefixedStringEncoder#DEFAULT_MAX_DATA_LENGTH}.
038:             * <p/>
039:             * This method does the same job as {@link PrefixedStringEncoder#setMaxDataLength(int)}.
040:             *
041:             * @return the allowed maximum size of an encoded string.
042:             */
043:            public int getEncoderMaxDataLength() {
044:                return encoder.getMaxDataLength();
045:            }
046:
047:            /**
048:             * Sets the allowed maximum size of an encoded String.
049:             * If the size of the encoded String exceeds this value, the encoder
050:             * will throw a {@link IllegalArgumentException}.
051:             * The default value is {@link PrefixedStringEncoder#DEFAULT_MAX_DATA_LENGTH}.
052:             * <p/>
053:             * This method does the same job as {@link PrefixedStringEncoder#getMaxDataLength()}.
054:             *
055:             * @param maxDataLength allowed maximum size of an encoded String.
056:             */
057:            public void setEncoderMaxDataLength(int maxDataLength) {
058:                encoder.setMaxDataLength(maxDataLength);
059:            }
060:
061:            /**
062:             * Returns the allowed maximum size of a decoded string.
063:             * <p>
064:             * This method does the same job as {@link PrefixedStringEncoder#setMaxDataLength(int)}.
065:             * </p>
066:             *
067:             * @return the allowed maximum size of an encoded string.
068:             * @see #setDecoderMaxDataLength(int)
069:             */
070:            public int getDecoderMaxDataLength() {
071:                return decoder.getMaxDataLength();
072:            }
073:
074:            /**
075:             * Sets the maximum allowed value specified as data length in the decoded data
076:             * <p>
077:             * Useful for preventing an OutOfMemory attack by the peer.
078:             * The decoder will throw a {@link BufferDataException} when data length
079:             * specified in the incoming data is greater than maxDataLength
080:             * The default value is {@link PrefixedStringDecoder#DEFAULT_MAX_DATA_LENGTH}.
081:             *
082:             * This method does the same job as {@link PrefixedStringDecoder#setMaxDataLength(int)}.
083:             * </p>
084:             *
085:             * @param maxDataLength maximum allowed value specified as data length in the incoming data
086:             */
087:            public void setDecoderMaxDataLength(int maxDataLength) {
088:                decoder.setMaxDataLength(maxDataLength);
089:            }
090:
091:            /**
092:             * Sets the length of the prefix used by the decoder
093:             *
094:             * @param prefixLength the length of the length prefix (1, 2, or 4)
095:             */
096:            public void setDecoderPrefixLength(int prefixLength) {
097:                decoder.setPrefixLength(prefixLength);
098:            }
099:
100:            /**
101:             * Gets the length of the length prefix (1, 2, or 4) used by the decoder
102:             *
103:             * @return length of the length prefix
104:             */
105:            public int getDecoderPrefixLength() {
106:                return decoder.getPrefixLength();
107:            }
108:
109:            /**
110:             * Sets the length of the prefix used by the encoder
111:             *
112:             * @param prefixLength the length of the length prefix (1, 2, or 4)
113:             */
114:            public void setEncoderPrefixLength(int prefixLength) {
115:                encoder.setPrefixLength(prefixLength);
116:            }
117:
118:            /**
119:             * Gets the length of the length prefix (1, 2, or 4) used by the encoder
120:             *
121:             * @return length of the length prefix
122:             */
123:            public int getEncoderPrefixLength() {
124:                return encoder.getPrefixLength();
125:            }
126:
127:            public ProtocolEncoder getEncoder(IoSession session)
128:                    throws Exception {
129:                return encoder;
130:            }
131:
132:            public ProtocolDecoder getDecoder(IoSession session)
133:                    throws Exception {
134:                return decoder;
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.