| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.dnslabel; |
| 12 |
|
| 13 |
/** |
| 14 |
* A reserved LDH label (R-LDH label), which have the property that they contain "--" in the third and fourth characters. |
| 15 |
* |
| 16 |
*/ |
| 17 |
public class ReservedLdhLabel extends LdhLabel { |
| 18 |
|
| 19 |
protected ReservedLdhLabel(String label) { |
| 20 |
super(label); |
| 21 |
assert isReservedLdhLabelInternal(label); |
| 22 |
} |
| 23 |
|
| 24 |
public static boolean isReservedLdhLabel(String label) { |
| 25 |
if (!isLdhLabel(label)) { |
| 26 |
return false; |
| 27 |
} |
| 28 |
return isReservedLdhLabelInternal(label); |
| 29 |
} |
| 30 |
|
| 31 |
static boolean isReservedLdhLabelInternal(String label) { |
| 32 |
return label.length() >= 4 |
| 33 |
&& label.charAt(2) == '-' |
| 34 |
&& label.charAt(3) == '-'; |
| 35 |
} |
| 36 |
} |