001/*
002 * Copyright 2015-2020 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.dnslabel;
012
013/**
014 * A reserved LDH label (R-LDH label), which have the property that they contain "--" in the third and fourth characters.
015 *
016 */
017public class ReservedLdhLabel extends LdhLabel {
018
019    protected ReservedLdhLabel(String label) {
020        super(label);
021        assert isReservedLdhLabelInternal(label);
022    }
023
024    public static boolean isReservedLdhLabel(String label) {
025        if (!isLdhLabel(label)) {
026            return false;
027        }
028        return isReservedLdhLabelInternal(label);
029    }
030
031    static boolean isReservedLdhLabelInternal(String label) {
032        return label.length() >= 4
033                && label.charAt(2) == '-'
034                && label.charAt(3) == '-';
035    }
036}