Source Code Cross Referenced for DefaultPDUFactory.java in  » Net » snmp4j » org » snmp4j » 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 » Net » snmp4j » org.snmp4j.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*_############################################################################
002:          _## 
003:          _##  SNMP4J - DefaultPDUFactory.java  
004:          _## 
005:          _##  Copyright (C) 2003-2008  Frank Fock and Jochen Katz (SNMP4J.org)
006:          _##  
007:          _##  Licensed under the Apache License, Version 2.0 (the "License");
008:          _##  you may not use this file except in compliance with the License.
009:          _##  You may obtain a copy of the License at
010:          _##  
011:          _##      http://www.apache.org/licenses/LICENSE-2.0
012:          _##  
013:          _##  Unless required by applicable law or agreed to in writing, software
014:          _##  distributed under the License is distributed on an "AS IS" BASIS,
015:          _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:          _##  See the License for the specific language governing permissions and
017:          _##  limitations under the License.
018:          _##  
019:          _##########################################################################*/
020:
021:        package org.snmp4j.util;
022:
023:        import org.snmp4j.*;
024:        import org.snmp4j.mp.SnmpConstants;
025:
026:        /**
027:         * The <code>DefaultPDUFactory</code> is a default implementation of the
028:         * <code>PDUFactory</code> interface. It creates PDUs depending on the
029:         * target's message processing model. That is, a {@link PDUv1} instance is
030:         * created for a SNMPv1 target whereas a {@link ScopedPDU} is created
031:         * for a SNMPv3 target. In all other cases a {@link PDU} instance is created.
032:         *
033:         * @author Frank Fock
034:         * @version 1.7.3
035:         * @since 1.0.4
036:         */
037:        public class DefaultPDUFactory implements  PDUFactory {
038:
039:            private int pduType = PDU.GET;
040:
041:            /**
042:             * Creates a PDU factory for the {@link PDU#GET} PDU type.
043:             */
044:            public DefaultPDUFactory() {
045:            }
046:
047:            /**
048:             * Creates a PDU factory for the specified PDU type.
049:             * @param pduType
050:             *    a PDU type as specified by {@link PDU}.
051:             */
052:            public DefaultPDUFactory(int pduType) {
053:                setPduType(pduType);
054:            }
055:
056:            public void setPduType(int pduType) {
057:                this .pduType = pduType;
058:            }
059:
060:            public int getPduType() {
061:                return pduType;
062:            }
063:
064:            /**
065:             * Create a <code>PDU</code> instance for the supplied target.
066:             *
067:             * @param target the <code>Target</code> where the PDU to be created will be
068:             *   sent.
069:             * @return PDU a PDU instance that is compatible with the supplied target.
070:             */
071:            public PDU createPDU(Target target) {
072:                return createPDU(target, pduType);
073:            }
074:
075:            /**
076:             * Create a <code>PDU</code> instance for the supplied target.
077:             *
078:             * @param target the <code>Target</code> where the PDU to be created will be
079:             *    sent.
080:             * @param pduType
081:             *    a PDU type as specified by {@link PDU}.
082:             * @return PDU
083:             *    a PDU instance that is compatible with the supplied target.
084:             */
085:            public static PDU createPDU(Target target, int pduType) {
086:                PDU request = createPDU(target.getVersion());
087:                request.setType(pduType);
088:                return request;
089:            }
090:
091:            /**
092:             * Create a <code>PDU</code> instance for the specified SNMP version.
093:             * @param targetVersion
094:             *    a SNMP version as defined by {@link SnmpConstants}.
095:             * @return
096:             *    a PDU instance that is compatible with the supplied target SNMP version.
097:             * @since 1.7.3
098:             */
099:            public static PDU createPDU(int targetVersion) {
100:                PDU request;
101:                switch (targetVersion) {
102:                case SnmpConstants.version3: {
103:                    request = new ScopedPDU();
104:                    break;
105:                }
106:                case SnmpConstants.version1: {
107:                    request = new PDUv1();
108:                    break;
109:                }
110:                default:
111:                    request = new PDU();
112:                }
113:                return request;
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.