Author: erodriguez
Date: Mon Jan 10 17:19:45 2005
New Revision: 124861

URL: http://svn.apache.org/viewcvs?view=rev&rev=124861
Log:
Basic DNS message, as immutable value, mutable companion.
Added:
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessage.java
   (contents, props changed)
   
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessageModifier.java

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessage.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessage.java?view=auto&rev=124861
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessage.java
 Mon Jan 10 17:19:45 2005
@@ -0,0 +1,200 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dns.messages;
+
+import org.apache.dns.records.QuestionRecord;
+import org.apache.dns.records.ResourceRecord;
+
+/**
+ * All communications inside of the domain protocol are carried in a single
+ * format called a message.  The top level format of message is divided
+ * into 5 sections (some of which are empty in certain cases) shown below:
+ *
+ *     +---------------------+
+ *     |        Header       |
+ *     +---------------------+
+ *     |       Question      | the question for the name server
+ *     +---------------------+
+ *     |        Answer       | ResourceRecords answering the question
+ *     +---------------------+
+ *     |      Authority      | ResourceRecords pointing toward an authority
+ *     +---------------------+
+ *     |      Additional     | ResourceRecords holding additional information
+ *     +---------------------+
+ */
+public class DnsMessage
+{
+       /**
+        * The header section is always present.  The header includes fields 
that
+        * specify which of the remaining sections are present, and also specify
+        * whether the message is a query or a response, a standard query or 
some
+        * other opcode, etc.
+        */
+       private short        transactionId;
+       private MessageType  messageType;
+       private OpCode       opCode;
+       private boolean      authoritativeAnswer;
+       private boolean      truncated;
+       private boolean      recursionDesired;
+       private boolean      recursionAvailable;
+       private boolean      reserved;
+       private boolean      acceptNonAuthenticatedData;
+       
+       private ResponseCode responseCode;
+       
+       private QuestionRecord[] questionRecords;
+       private ResourceRecord[] answerRecords;
+       private ResourceRecord[] authorityRecords;
+       private ResourceRecord[] additionalRecords;
+       
+       public DnsMessage( short transactionId, MessageType messageType,
+                       OpCode opCode, boolean authoritativeAnswer, boolean 
truncated,
+                       boolean recursionDesired, boolean recursionAvailable,
+                       boolean reserved, boolean acceptNonAuthenticatedData,
+                       ResponseCode responseCode, QuestionRecord[] question,
+                       ResourceRecord[] answer, ResourceRecord[] authority, 
ResourceRecord[] additional )
+       {
+               this.transactionId              = transactionId;
+               this.messageType                = messageType;
+               this.opCode                     = opCode;
+               this.authoritativeAnswer        = authoritativeAnswer;
+               this.truncated                  = truncated;
+               this.recursionDesired           = recursionDesired;
+               this.recursionAvailable         = recursionAvailable;
+               this.reserved                   = reserved;
+               this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
+               this.responseCode               = responseCode;
+               this.questionRecords            = question;
+               this.answerRecords              = answer;
+               this.authorityRecords           = authority;
+               this.additionalRecords          = additional;
+       }
+       
+       /**
+        * @return Returns the acceptNonAuthenticatedData.
+        */
+       public boolean isAcceptNonAuthenticatedData()
+       {
+               return acceptNonAuthenticatedData;
+       }
+       
+       /**
+        * @return Returns the additional.
+        */
+       public ResourceRecord[] getAdditionalRecords()
+       {
+               return additionalRecords;
+       }
+       
+       /**
+        * @return Returns the answer.
+        */
+       public ResourceRecord[] getAnswerRecords()
+       {
+               return answerRecords;
+       }
+       
+       /**
+        * @return Returns the authoritativeAnswer.
+        */
+       public boolean isAuthoritativeAnswer()
+       {
+               return authoritativeAnswer;
+       }
+       
+       /**
+        * @return Returns the authority.
+        */
+       public ResourceRecord[] getAuthorityRecords()
+       {
+               return authorityRecords;
+       }
+       
+       /**
+        * @return Returns the messageType.
+        */
+       public MessageType getMessageType()
+       {
+               return messageType;
+       }
+       
+       /**
+        * @return Returns the opCode.
+        */
+       public OpCode getOpCode()
+       {
+               return opCode;
+       }
+       
+       /**
+        * @return Returns the question.
+        */
+       public QuestionRecord[] getQuestionRecords()
+       {
+               return questionRecords;
+       }
+       
+       /**
+        * @return Returns the recursionAvailable.
+        */
+       public boolean isRecursionAvailable()
+       {
+               return recursionAvailable;
+       }
+       
+       /**
+        * @return Returns the recursionDesired.
+        */
+       public boolean isRecursionDesired()
+       {
+               return recursionDesired;
+       }
+       
+       /**
+        * @return Returns the reserved.
+        */
+       public boolean isReserved()
+       {
+               return reserved;
+       }
+       
+       /**
+        * @return Returns the responseCode.
+        */
+       public ResponseCode getResponseCode()
+       {
+               return responseCode;
+       }
+       
+       /**
+        * @return Returns the transactionId.
+        */
+       public short getTransactionId()
+       {
+               return transactionId;
+       }
+       
+       /**
+        * @return Returns the truncated.
+        */
+       public boolean isTruncated()
+       {
+               return truncated;
+       }
+}
+

Added: 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessageModifier.java
Url: 
http://svn.apache.org/viewcvs/incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessageModifier.java?view=auto&rev=124861
==============================================================================
--- (empty file)
+++ 
incubator/directory/dns/trunk/core/src/java/org/apache/dns/messages/DnsMessageModifier.java
 Mon Jan 10 17:19:45 2005
@@ -0,0 +1,187 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.dns.messages;
+
+import org.apache.dns.records.QuestionRecord;
+import org.apache.dns.records.ResourceRecord;
+
+/**
+ * All communications inside of the domain protocol are carried in a single
+ * format called a message.  The top level format of message is divided
+ * into 5 sections (some of which are empty in certain cases) shown below:
+ *
+ *     +---------------------+
+ *     |        Header       |
+ *     +---------------------+
+ *     |       Question      | the question for the name server
+ *     +---------------------+
+ *     |        Answer       | ResourceRecords answering the question
+ *     +---------------------+
+ *     |      Authority      | ResourceRecords pointing toward an authority
+ *     +---------------------+
+ *     |      Additional     | ResourceRecords holding additional information
+ *     +---------------------+
+ */
+public class DnsMessageModifier
+{
+       /**
+        * The header section is always present.  The header includes fields 
that
+        * specify which of the remaining sections are present, and also specify
+        * whether the message is a query or a response, a standard query or 
some
+        * other opcode, etc.
+        */
+       private short        transactionId;
+       private MessageType  messageType;
+       private OpCode       opCode;
+       private boolean      authoritativeAnswer;
+       private boolean      truncated;
+       private boolean      recursionDesired;
+       private boolean      recursionAvailable;
+       private boolean      reserved;
+       private boolean      acceptNonAuthenticatedData;
+       
+       private ResponseCode responseCode;
+       
+       private QuestionRecord[] questionRecords;
+       private ResourceRecord[] answerRecords;
+       private ResourceRecord[] authorityRecords;
+       private ResourceRecord[] additionalRecords;
+       
+       
+       public DnsMessage getDnsMessage()
+       {
+               return new DnsMessage( transactionId, messageType, opCode,
+                               authoritativeAnswer, truncated, 
recursionDesired,
+                               recursionAvailable, reserved, 
acceptNonAuthenticatedData,
+                               responseCode, questionRecords, answerRecords, 
authorityRecords,
+                               additionalRecords );
+       }
+       
+       /**
+        * @param acceptNonAuthenticatedData The acceptNonAuthenticatedData to 
set.
+        */
+       public void setAcceptNonAuthenticatedData( boolean 
acceptNonAuthenticatedData )
+       {
+               this.acceptNonAuthenticatedData = acceptNonAuthenticatedData;
+       }
+       
+       /**
+        * @param additional The additional to set.
+        */
+       public void setAdditionalRecords( ResourceRecord[] additionalRecords )
+       {
+               this.additionalRecords = additionalRecords;
+       }
+       
+       /**
+        * @param answer The answer to set.
+        */
+       public void setAnswerRecords( ResourceRecord[] answerRecords )
+       {
+               this.answerRecords = answerRecords;
+       }
+       
+       /**
+        * @param authoritativeAnswer The authoritativeAnswer to set.
+        */
+       public void setAuthoritativeAnswer( boolean authoritativeAnswer )
+       {
+               this.authoritativeAnswer = authoritativeAnswer;
+       }
+       
+       /**
+        * @param authority The authority to set.
+        */
+       public void setAuthorityRecords( ResourceRecord[] authorityRecords )
+       {
+               this.authorityRecords = authorityRecords;
+       }
+       
+       /**
+        * @param messageType The messageType to set.
+        */
+       public void setMessageType( MessageType messageType )
+       {
+               this.messageType = messageType;
+       }
+       
+       /**
+        * @param opCode The opCode to set.
+        */
+       public void setOpCode( OpCode opCode )
+       {
+               this.opCode = opCode;
+       }
+       
+       /**
+        * @param question The question to set.
+        */
+       public void setQuestionRecords( QuestionRecord[] questionRecords )
+       {
+               this.questionRecords = questionRecords;
+       }
+       
+       /**
+        * @param recursionAvailable The recursionAvailable to set.
+        */
+       public void setRecursionAvailable( boolean recursionAvailable )
+       {
+               this.recursionAvailable = recursionAvailable;
+       }
+       
+       /**
+        * @param recursionDesired The recursionDesired to set.
+        */
+       public void setRecursionDesired( boolean recursionDesired )
+       {
+               this.recursionDesired = recursionDesired;
+       }
+       
+       /**
+        * @param reserved The reserved to set.
+        */
+       public void setReserved( boolean reserved )
+       {
+               this.reserved = reserved;
+       }
+       
+       /**
+        * @param responseCode The responseCode to set.
+        */
+       public void setResponseCode( ResponseCode responseCode )
+       {
+               this.responseCode = responseCode;
+       }
+       
+       /**
+        * @param transactionId The transactionId to set.
+        */
+       public void setTransactionId( short transactionId )
+       {
+               this.transactionId = transactionId;
+       }
+       
+       /**
+        * @param truncated The truncated to set.
+        */
+       public void setTruncated( boolean truncated )
+       {
+               this.truncated = truncated;
+       }
+}
+

Reply via email to