| 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 DNS label with a leading or trailing hyphen ('-'). |
| 15 |
*/ |
| 16 |
public final class LeadingOrTrailingHyphenLabel extends NonLdhLabel { |
| 17 |
|
| 18 |
protected LeadingOrTrailingHyphenLabel(String label) { |
| 19 |
super(label); |
| 20 |
} |
| 21 |
|
| 22 |
protected static boolean isLeadingOrTrailingHypenLabelInternal(String label) { |
| 23 |
if (label.isEmpty()) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
|
| 27 |
if (label.charAt(0) == '-') { |
| 28 |
return true; |
| 29 |
} |
| 30 |
|
| 31 |
if (label.charAt(label.length() - 1) == '-') { |
| 32 |
return true; |
| 33 |
} |
| 34 |
|
| 35 |
return false; |
| 36 |
} |
| 37 |
} |