java/alt2xml-lib-input/src/cz/frantovo/alt2xml/in/Functions.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:56:03 +0200
changeset 111 e4900596abdb
parent 89 46c7cc4863c1
permissions -rw-r--r--
fix license version: GNU GPLv3
franta-hg@88
     1
/**
franta-hg@88
     2
 * Alt2XML
franta-hg@88
     3
 * Copyright © 2014 František Kučera (frantovo.cz)
franta-hg@88
     4
 *
franta-hg@88
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@88
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@111
     7
 * the Free Software Foundation, version 3 of the License.
franta-hg@88
     8
 *
franta-hg@88
     9
 * This program is distributed in the hope that it will be useful,
franta-hg@88
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@88
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@88
    12
 * GNU General Public License for more details.
franta-hg@88
    13
 *
franta-hg@88
    14
 * You should have received a copy of the GNU General Public License
franta-hg@88
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@88
    16
 */
franta-hg@88
    17
package cz.frantovo.alt2xml.in;
franta-hg@88
    18
franta-hg@88
    19
/**
franta-hg@88
    20
 *
franta-hg@88
    21
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@88
    22
 */
franta-hg@88
    23
public class Functions {
franta-hg@88
    24
franta-hg@88
    25
	/**
franta-hg@88
    26
	 * TODO: real lossless encoding + decoding (this is just a dummy code)
franta-hg@88
    27
	 *
franta-hg@88
    28
	 * @param name any string
franta-hg@88
    29
	 * @return valid name of XML element or attribute
franta-hg@88
    30
	 */
franta-hg@88
    31
	public static String encodeXmlName(String name) {
franta-hg@89
    32
		if (name == null) {
franta-hg@89
    33
			return String.valueOf(name);
franta-hg@89
    34
		} else {
franta-hg@89
    35
			return name.replaceAll("\\s", "-");
franta-hg@89
    36
		}
franta-hg@88
    37
	}
franta-hg@88
    38
franta-hg@88
    39
	private Functions() {
franta-hg@88
    40
	}
franta-hg@88
    41
}