View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.dns.messages;
21  
22  
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  import org.apache.directory.api.util.Strings;
27  
28  
29  /**
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   */
32  public class ResourceRecordModifier
33  {
34      private String dnsName;
35      private RecordType dnsType;
36      private RecordClass dnsClass;
37      private int dnsTtl;
38  
39      private Map<String, Object> attributes = new HashMap<>();
40  
41  
42      /**
43       * Returns the {@link ResourceRecord} built by this {@link ResourceRecordModifier}.
44       *
45       * @return The {@link ResourceRecord}.
46       */
47      public ResourceRecord getEntry()
48      {
49          return new ResourceRecordImpl( dnsName, dnsType, dnsClass, dnsTtl, attributes );
50      }
51  
52  
53      /**
54       * @param dnsName The dnsName to set.
55       */
56      public void setDnsName( String dnsName )
57      {
58          this.dnsName = dnsName;
59      }
60  
61  
62      /**
63       * @param dnsType The dnsType to set.
64       */
65      public void setDnsType( RecordType dnsType )
66      {
67          this.dnsType = dnsType;
68      }
69  
70  
71      /**
72       * @param dnsClass The dnsClass to set.
73       */
74      public void setDnsClass( RecordClass dnsClass )
75      {
76          this.dnsClass = dnsClass;
77      }
78  
79  
80      /**
81       * @param dnsTtl The dnsTtl to set.
82       */
83      public void setDnsTtl( int dnsTtl )
84      {
85          this.dnsTtl = dnsTtl;
86      }
87  
88  
89      /**
90       * @param id The id to set
91       * @param value The value to set 
92       */
93      public void put( String id, String value )
94      {
95          attributes.put( Strings.toLowerCaseAscii( id ), value );
96      }
97  }