Source Code Cross Referenced for SetResponse.java in  » Net » dnsjava » org » xbill » DNS » 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 » dnsjava » org.xbill.DNS 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
002:
003:        package org.xbill.DNS;
004:
005:        import java.util.*;
006:
007:        /**
008:         * The Response from a query to Cache.lookupRecords() or Zone.findRecords()
009:         * @see Cache
010:         * @see Zone
011:         *
012:         * @author Brian Wellington
013:         */
014:
015:        public class SetResponse {
016:
017:            /**
018:             * The Cache contains no information about the requested name/type
019:             */
020:            static final int UNKNOWN = 0;
021:
022:            /**
023:             * The Zone does not contain the requested name, or the Cache has
024:             * determined that the name does not exist.
025:             */
026:            static final int NXDOMAIN = 1;
027:
028:            /**
029:             * The Zone contains the name, but no data of the requested type,
030:             * or the Cache has determined that the name exists and has no data
031:             * of the requested type.
032:             */
033:            static final int NXRRSET = 2;
034:
035:            /**
036:             * A delegation enclosing the requested name was found.
037:             */
038:            static final int DELEGATION = 3;
039:
040:            /**
041:             * The Cache/Zone found a CNAME when looking for the name.
042:             * @see CNAMERecord
043:             */
044:            static final int CNAME = 4;
045:
046:            /**
047:             * The Cache/Zone found a DNAME when looking for the name.
048:             * @see DNAMERecord
049:             */
050:            static final int DNAME = 5;
051:
052:            /**
053:             * The Cache/Zone has successfully answered the question for the
054:             * requested name/type/class.
055:             */
056:            static final int SUCCESSFUL = 6;
057:
058:            private static final SetResponse unknown = new SetResponse(UNKNOWN);
059:            private static final SetResponse nxdomain = new SetResponse(
060:                    NXDOMAIN);
061:            private static final SetResponse nxrrset = new SetResponse(NXRRSET);
062:
063:            private int type;
064:            private Object data;
065:
066:            private SetResponse() {
067:            }
068:
069:            SetResponse(int type, RRset rrset) {
070:                if (type < 0 || type > 6)
071:                    throw new IllegalArgumentException("invalid type");
072:                this .type = type;
073:                this .data = rrset;
074:            }
075:
076:            SetResponse(int type) {
077:                if (type < 0 || type > 6)
078:                    throw new IllegalArgumentException("invalid type");
079:                this .type = type;
080:                this .data = null;
081:            }
082:
083:            static SetResponse ofType(int type) {
084:                switch (type) {
085:                case UNKNOWN:
086:                    return unknown;
087:                case NXDOMAIN:
088:                    return nxdomain;
089:                case NXRRSET:
090:                    return nxrrset;
091:                case DELEGATION:
092:                case CNAME:
093:                case DNAME:
094:                case SUCCESSFUL:
095:                    SetResponse sr = new SetResponse();
096:                    sr.type = type;
097:                    sr.data = null;
098:                    return sr;
099:                default:
100:                    throw new IllegalArgumentException("invalid type");
101:                }
102:            }
103:
104:            void addRRset(RRset rrset) {
105:                if (data == null)
106:                    data = new ArrayList();
107:                List l = (List) data;
108:                l.add(rrset);
109:            }
110:
111:            /** Is the answer to the query unknown? */
112:            public boolean isUnknown() {
113:                return (type == UNKNOWN);
114:            }
115:
116:            /** Is the answer to the query that the name does not exist? */
117:            public boolean isNXDOMAIN() {
118:                return (type == NXDOMAIN);
119:            }
120:
121:            /** Is the answer to the query that the name exists, but the type does not? */
122:            public boolean isNXRRSET() {
123:                return (type == NXRRSET);
124:            }
125:
126:            /** Is the result of the lookup that the name is below a delegation? */
127:            public boolean isDelegation() {
128:                return (type == DELEGATION);
129:            }
130:
131:            /** Is the result of the lookup a CNAME? */
132:            public boolean isCNAME() {
133:                return (type == CNAME);
134:            }
135:
136:            /** Is the result of the lookup a DNAME? */
137:            public boolean isDNAME() {
138:                return (type == DNAME);
139:            }
140:
141:            /** Was the query successful? */
142:            public boolean isSuccessful() {
143:                return (type == SUCCESSFUL);
144:            }
145:
146:            /** If the query was successful, return the answers */
147:            public RRset[] answers() {
148:                if (type != SUCCESSFUL)
149:                    return null;
150:                List l = (List) data;
151:                return (RRset[]) l.toArray(new RRset[l.size()]);
152:            }
153:
154:            /**
155:             * If the query encountered a CNAME, return it.
156:             */
157:            public CNAMERecord getCNAME() {
158:                return (CNAMERecord) ((RRset) data).first();
159:            }
160:
161:            /**
162:             * If the query encountered a DNAME, return it.
163:             */
164:            public DNAMERecord getDNAME() {
165:                return (DNAMERecord) ((RRset) data).first();
166:            }
167:
168:            /**
169:             * If the query hit a delegation point, return the NS set.
170:             */
171:            public RRset getNS() {
172:                return (RRset) data;
173:            }
174:
175:            /** Prints the value of the SetResponse */
176:            public String toString() {
177:                switch (type) {
178:                case UNKNOWN:
179:                    return "unknown";
180:                case NXDOMAIN:
181:                    return "NXDOMAIN";
182:                case NXRRSET:
183:                    return "NXRRSET";
184:                case DELEGATION:
185:                    return "delegation: " + data;
186:                case CNAME:
187:                    return "CNAME: " + data;
188:                case DNAME:
189:                    return "DNAME: " + data;
190:                case SUCCESSFUL:
191:                    return "successful";
192:                default:
193:                    return null;
194:                }
195:            }
196:
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.