Here you can find the source of encodeUriWithPrefix(String uri)
Parameter | Description |
---|---|
baseuri | The pure uri string to be encoded for MDX |
static String encodeUriWithPrefix(String uri)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**//w w w. j a v a 2s. c o m * Elements (identifiers) used in MDX need to follow certain rules in order * to be parseable from and to MDX. In fact, having it URL encoded is not * enough, also, % and . need to be replaced. * * @param baseuri * The pure uri string to be encoded for MDX * @return encoded string */ static String encodeUriWithPrefix(String uri) { // Since we do not manage prefixes, we have to come up with one // ourselves // (which if possible should be always the same): return encodeSpecialMdxCharactersInNames(uri); } /** * We need to make sure that names of multidimensional elements do not carry * any MDX special characters. * * Note: You can use a bash command for translating a URI into an MDX * applicable form: * * echo "http://lod.gesis.org/lodpilot/ALLBUS/geo.rdf#list" | sed * 's/\./YYY/g' | sed 's/-/ZZZ/g' | sed 's/%/XXX/g' * * @param name * @return */ public static String encodeSpecialMdxCharactersInNames(String name) { try { name = URLEncoder.encode(name, "UTF-8"); name = name.replace("%", "XXX"); name = name.replace(".", "YYY"); name = name.replace("-", "ZZZ"); return name; } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }