/** * Copyright 2013 Florian Schmaus * * All rights reserved. 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.jivesoftware.smack.util.dns; /** * @see 65535) throw new IllegalArgumentException( "DNS SRV records priority must be a 16-bit unsiged integer (i.e. between 0-65535. Priority was: " + priority); this.priority = priority; this.weight = weight; } public int getPriority() { return priority; } public int getWeight() { return weight; } @Override public int compareTo(SRVRecord other) { // According to RFC2782, // "[a] client MUST attempt to contact the target host with the lowest-numbered priority it can reach". // This means that a SRV record with a higher priority is 'less' then one with a lower. int res = other.priority - this.priority; if (res == 0) { res = this.weight - other.weight; } return res; } @Override public String toString() { return super.toString() + " prio:" + priority + ":w:" + weight; } }