java/alt2xml-lib-input/src/cz/frantovo/alt2xml/in/Functions.java
author František Kučera <franta-hg@frantovo.cz>
Sat, 06 Sep 2014 21:24:53 +0200
changeset 89 46c7cc4863c1
parent 88 9860586b3b87
child 111 e4900596abdb
permissions -rw-r--r--
in-ini: support and encode entry names with spaces
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@88
     7
 * the Free Software Foundation, either version 3 of the License, or
franta-hg@88
     8
 * (at your option) any later version.
franta-hg@88
     9
 *
franta-hg@88
    10
 * This program is distributed in the hope that it will be useful,
franta-hg@88
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@88
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@88
    13
 * GNU General Public License for more details.
franta-hg@88
    14
 *
franta-hg@88
    15
 * You should have received a copy of the GNU General Public License
franta-hg@88
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@88
    17
 */
franta-hg@88
    18
package cz.frantovo.alt2xml.in;
franta-hg@88
    19
franta-hg@88
    20
/**
franta-hg@88
    21
 *
franta-hg@88
    22
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@88
    23
 */
franta-hg@88
    24
public class Functions {
franta-hg@88
    25
franta-hg@88
    26
	/**
franta-hg@88
    27
	 * TODO: real lossless encoding + decoding (this is just a dummy code)
franta-hg@88
    28
	 *
franta-hg@88
    29
	 * @param name any string
franta-hg@88
    30
	 * @return valid name of XML element or attribute
franta-hg@88
    31
	 */
franta-hg@88
    32
	public static String encodeXmlName(String name) {
franta-hg@89
    33
		if (name == null) {
franta-hg@89
    34
			return String.valueOf(name);
franta-hg@89
    35
		} else {
franta-hg@89
    36
			return name.replaceAll("\\s", "-");
franta-hg@89
    37
		}
franta-hg@88
    38
	}
franta-hg@88
    39
franta-hg@88
    40
	private Functions() {
franta-hg@88
    41
	}
franta-hg@88
    42
}