Java String Encode encodeSpecialMdxCharactersInNames(String name)

Here you can find the source of encodeSpecialMdxCharactersInNames(String name)

Description

We need to make sure that names of multidimensional elements do not carry any MDX special characters.

License

Apache License

Parameter

Parameter Description
name a parameter

Declaration

public static String encodeSpecialMdxCharactersInNames(String name) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    /**//from  ww w . ja v  a2 s  .c o  m
     * 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;
    }
}

Related

  1. encodeParams(String encoding, String... params)
  2. EncodePath(String path)
  3. encodePath(String path)
  4. encodePath(String str)
  5. encodeRfc5849(final String value)
  6. encodeState(Map params)
  7. encodeStr(String str)
  8. encodeStr(String str)
  9. encodeStr(String t)