001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.dns.messages; 021 022 023import java.util.HashMap; 024import java.util.Map; 025 026import org.apache.directory.api.util.Strings; 027 028 029/** 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public class ResourceRecordModifier 033{ 034 private String dnsName; 035 private RecordType dnsType; 036 private RecordClass dnsClass; 037 private int dnsTtl; 038 039 private Map<String, Object> attributes = new HashMap<>(); 040 041 042 /** 043 * Returns the {@link ResourceRecord} built by this {@link ResourceRecordModifier}. 044 * 045 * @return The {@link ResourceRecord}. 046 */ 047 public ResourceRecord getEntry() 048 { 049 return new ResourceRecordImpl( dnsName, dnsType, dnsClass, dnsTtl, attributes ); 050 } 051 052 053 /** 054 * @param dnsName The dnsName to set. 055 */ 056 public void setDnsName( String dnsName ) 057 { 058 this.dnsName = dnsName; 059 } 060 061 062 /** 063 * @param dnsType The dnsType to set. 064 */ 065 public void setDnsType( RecordType dnsType ) 066 { 067 this.dnsType = dnsType; 068 } 069 070 071 /** 072 * @param dnsClass The dnsClass to set. 073 */ 074 public void setDnsClass( RecordClass dnsClass ) 075 { 076 this.dnsClass = dnsClass; 077 } 078 079 080 /** 081 * @param dnsTtl The dnsTtl to set. 082 */ 083 public void setDnsTtl( int dnsTtl ) 084 { 085 this.dnsTtl = dnsTtl; 086 } 087 088 089 /** 090 * @param id The id to set 091 * @param value The value to set 092 */ 093 public void put( String id, String value ) 094 { 095 attributes.put( Strings.toLowerCaseAscii( id ), value ); 096 } 097}