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 DNS label which contains more than just letters, digits and a hyphen.
015 *
016 */
017public abstract class NonLdhLabel extends DnsLabel {
018
019    protected NonLdhLabel(String label) {
020        super(label);
021    }
022
023    protected static DnsLabel fromInternal(String label) {
024        if (UnderscoreLabel.isUnderscoreLabelInternal(label)) {
025            return new UnderscoreLabel(label);
026        }
027
028        if (LeadingOrTrailingHyphenLabel.isLeadingOrTrailingHypenLabelInternal(label)) {
029            return new LeadingOrTrailingHyphenLabel(label);
030        }
031
032        return new OtherNonLdhLabel(label);
033    }
034
035}