Example usage for org.apache.commons.lang3 StringUtils replace

List of usage examples for org.apache.commons.lang3 StringUtils replace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils replace.

Prototype

public static String replace(final String text, final String searchString, final String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

A null reference passed to this method is a no-op.

 StringUtils.replace(null, *, *)        = null StringUtils.replace("", *, *)          = "" StringUtils.replace("any", null, *)    = "any" StringUtils.replace("any", *, null)    = "any" StringUtils.replace("any", "", *)      = "any" StringUtils.replace("aba", "a", null)  = "aba" StringUtils.replace("aba", "a", "")    = "b" StringUtils.replace("aba", "a", "z")   = "zbz" 

Usage

From source file:me.ryanhamshire.griefprevention.permission.GPPermissionHandler.java

public static Tristate getClaimPermission(GPClaim claim, ClaimFlag flag, Subject subject, String source,
        String target, Context context) {
    final String flagBasePermission = GPPermissions.FLAG_BASE + "." + flag.toString();
    String sourceId = getPermissionIdentifier(source, true);
    String targetPermission = flagBasePermission;
    String targetId = getPermissionIdentifier(target);
    String targetModPermission = null;
    if (!targetId.isEmpty()) {
        if (!sourceId.isEmpty()) {
            String[] parts = targetId.split(":");
            String targetMod = parts[0];
            // move target meta to end of permission
            Pattern p = Pattern.compile("\\.[\\d+]*$");
            Matcher m = p.matcher(targetId);
            String targetMeta = "";
            if (m.find()) {
                targetMeta = m.group(0);
                targetId = StringUtils.replace(targetId, targetMeta, "");
            }//from   w  w  w .j  a v  a 2s .c om
            targetModPermission = flagBasePermission + "." + targetMod + ".source." + sourceId + targetMeta;
            targetModPermission = StringUtils.replace(targetModPermission, ":", ".");
            targetPermission += "." + targetId + ".source." + sourceId + targetMeta;
        } else {
            targetPermission += "." + targetId;
        }
    }
    targetPermission = StringUtils.replace(targetPermission, ":", ".");
    Set<Context> contexts = new HashSet<>();
    contexts.add(context);
    return subject.getPermissionValue(contexts, targetPermission);
}

From source file:com.taobao.android.repatch.Utils.DefineUtils.java

public static String getDalvikClassName(String className) {
    if (className.startsWith("[")) {
        className = className.substring(1);
    }/* w w w  .jav  a 2  s.  c o  m*/
    if (className.charAt(0) != 'L' || className.charAt(className.length() - 1) != ';') {
        return className;
    }
    return StringUtils.replace(className.substring(1, className.length() - 1), "/", ".");
}

From source file:de.crowdcode.kissmda.core.uml.UmlHelper.java

/**
 * Check for parameterized type to get the template parameter substitution.
 * /*from   w ww .ja v  a 2  s .c  om*/
 * @param type
 *            UML2 type
 * @return Map of umlTypeName and umlQualifiedTypeName
 */
public Map<String, String> checkParameterizedTypeForTemplateParameterSubstitution(Type type) {
    Map<String, String> results = new HashMap<String, String>();

    String umlTypeName = type.getName();
    String umlQualifiedTypeName = type.getQualifiedName();

    List<String> templateSubstitutions = getTemplateParameterSubstitution(type);
    if (templateSubstitutions.size() != 0) {
        int index = 0;

        String paramTypeNames = StringUtils.substringAfter(umlTypeName, "<");
        paramTypeNames = StringUtils.removeEnd(paramTypeNames, ">");
        EList<String> paramTypeNameList = convertStringToList(paramTypeNames, ",");

        for (String paramTypeName : paramTypeNameList) {
            umlTypeName = StringUtils.replace(umlTypeName, paramTypeName, templateSubstitutions.get(index));
            umlQualifiedTypeName = StringUtils.replace(umlQualifiedTypeName, paramTypeName,
                    templateSubstitutions.get(index));
            index = index + 1;
        }
    }

    results.put("umlTypeName", umlTypeName);
    results.put("umlQualifiedTypeName", umlQualifiedTypeName);

    return results;
}

From source file:io.cloudslang.content.services.WSManRemoteShellService.java

private String replacePlaceholder(String document, String placeholderName, String placeholderValue)
        throws RuntimeException {
    if (StringUtils.containsIgnoreCase(document, placeholderName)) {
        return StringUtils.replace(document, placeholderName, placeholderValue);
    } else {/*from  w w w. j  a  va  2s  . c  o m*/
        throw new RuntimeException(PLACEHOLDER_NOT_FOUND + placeholderName);
    }
}

From source file:com.github.mavenplugins.doctest.ReportMojo.java

/**
 * Gets the javadoc comment situated over a doctest method.
 */// www.j  a  va2  s . c  om
protected String getJavaDoc(String source, String method) {
    Pattern methodPattern = Pattern.compile(
            "public\\s+void\\s+" + method + "\\s*\\((HttpResponse|"
                    + HttpResponse.class.getName().replaceAll("\\.", "\\\\.") + ")",
            Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
    Matcher matcher = methodPattern.matcher(source);
    int start, tmp, last, comment;
    String doc;

    if (matcher.find()) {
        start = matcher.start();
        last = -1;
        matcher = ANY_METHOD_FINDER.matcher(source);
        while (matcher.find() && (tmp = matcher.start()) < start) {
            last = tmp;
        }

        comment = source.lastIndexOf("/**", start);

        if (comment > 2 && (comment > last || last == -1)) {
            doc = source.substring(comment, source.indexOf("*/", comment));
            doc = doc.substring(3, doc.length() - 2);
            doc = JAVADOC_EMPTYLINE_FINDER.matcher(doc).replaceAll(LINE_SEPARATOR);
            doc = JAVADOC_STAR_FINDER.matcher(doc).replaceAll("");
            doc = StringUtils.replace(doc, " ", "&nbsp;");
            doc = StringUtils.replace(doc, LINE_SEPARATOR, "<br/>");
            return doc;
        }
    }

    return "";
}

From source file:it.wami.map.mongodeploy.OsmSaxHandler.java

/**
 * /*from   w w  w  .  j a v  a2 s  .c o m*/
 * @param atts
 */
private void appendMetadata(Attributes atts) {
    for (int i = 0; i < atts.getLength(); i++) {
        //System.out.println("qName: "+atts.getQName(i)+" value: "+atts.getValue(i));
        String attribute = atts.getQName(i);
        if (attribute == "id" || attribute == "lat" || attribute == "lon") {
            continue;
        }
        /*if(attribute.contains("www")){
           System.exit(0);
        }*/
        attribute = StringUtils.replace(attribute, ".", "[dot]");
        //attribute.replace(".", "[dot]");
        //System.out.println(attribute);
        entry.append(attribute, atts.getValue(i));
    }
}

From source file:com.github.mavenplugins.doctest.ReportMojo.java

/**
 * Escapes a single string.//from   ww w .ja  va 2s.  co m
 */
protected String escapeToHtml(String text) {
    return StringUtils.replace(StringUtils.replace(HtmlTools.escapeHTML(text, false), "&amp;#", "&#"),
            LINE_SEPARATOR, "<br/>");
}

From source file:cgeo.geocaching.connector.gc.GCParser.java

static SearchResult parseCacheFromText(final String pageIn, final CancellableHandler handler) {
    CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_details);

    if (StringUtils.isBlank(pageIn)) {
        Log.e("GCParser.parseCache: No page given");
        return null;
    }/*  w w w.  ja v a  2  s. c  o  m*/

    final SearchResult searchResult = new SearchResult();

    if (pageIn.contains(GCConstants.STRING_UNPUBLISHED_OTHER)
            || pageIn.contains(GCConstants.STRING_UNPUBLISHED_FROM_SEARCH)) {
        searchResult.setError(StatusCode.UNPUBLISHED_CACHE);
        return searchResult;
    }

    if (pageIn.contains(GCConstants.STRING_PREMIUMONLY_1)
            || pageIn.contains(GCConstants.STRING_PREMIUMONLY_2)) {
        searchResult.setError(StatusCode.PREMIUM_ONLY);
        return searchResult;
    }

    final String cacheName = Html.fromHtml(TextUtils.getMatch(pageIn, GCConstants.PATTERN_NAME, true, ""))
            .toString();
    if (GCConstants.STRING_UNKNOWN_ERROR.equalsIgnoreCase(cacheName)) {
        searchResult.setError(StatusCode.UNKNOWN_ERROR);
        return searchResult;
    }

    // first handle the content with line breaks, then trim everything for easier matching and reduced memory consumption in parsed fields
    String personalNoteWithLineBreaks = "";
    MatcherWrapper matcher = new MatcherWrapper(GCConstants.PATTERN_PERSONALNOTE, pageIn);
    if (matcher.find()) {
        personalNoteWithLineBreaks = matcher.group(1).trim();
    }

    final String page = TextUtils.replaceWhitespace(pageIn);

    final Geocache cache = new Geocache();
    cache.setDisabled(page.contains(GCConstants.STRING_DISABLED));

    cache.setArchived(page.contains(GCConstants.STRING_ARCHIVED));

    cache.setPremiumMembersOnly(TextUtils.matches(page, GCConstants.PATTERN_PREMIUMMEMBERS));

    cache.setFavorite(TextUtils.matches(page, GCConstants.PATTERN_FAVORITE));

    // cache geocode
    cache.setGeocode(TextUtils.getMatch(page, GCConstants.PATTERN_GEOCODE, true, cache.getGeocode()));

    // cache id
    cache.setCacheId(TextUtils.getMatch(page, GCConstants.PATTERN_CACHEID, true, cache.getCacheId()));

    // cache guid
    cache.setGuid(TextUtils.getMatch(page, GCConstants.PATTERN_GUID, true, cache.getGuid()));

    // name
    cache.setName(cacheName);

    // owner real name
    cache.setOwnerUserId(Network
            .decode(TextUtils.getMatch(page, GCConstants.PATTERN_OWNER_USERID, true, cache.getOwnerUserId())));

    cache.setUserModifiedCoords(false);

    String tableInside = page;

    final int pos = tableInside.indexOf(GCConstants.STRING_CACHEDETAILS);
    if (pos == -1) {
        Log.e("GCParser.parseCache: ID \"cacheDetails\" not found on page");
        return null;
    }

    tableInside = tableInside.substring(pos);

    if (StringUtils.isNotBlank(tableInside)) {
        // cache terrain
        String result = TextUtils.getMatch(tableInside, GCConstants.PATTERN_TERRAIN, true, null);
        if (result != null) {
            try {
                cache.setTerrain(Float.parseFloat(StringUtils.replaceChars(result, '_', '.')));
            } catch (final NumberFormatException e) {
                Log.e("Error parsing terrain value", e);
            }
        }

        // cache difficulty
        result = TextUtils.getMatch(tableInside, GCConstants.PATTERN_DIFFICULTY, true, null);
        if (result != null) {
            try {
                cache.setDifficulty(Float.parseFloat(StringUtils.replaceChars(result, '_', '.')));
            } catch (final NumberFormatException e) {
                Log.e("Error parsing difficulty value", e);
            }
        }

        // owner
        cache.setOwnerDisplayName(StringEscapeUtils.unescapeHtml4(TextUtils.getMatch(tableInside,
                GCConstants.PATTERN_OWNER_DISPLAYNAME, true, cache.getOwnerDisplayName())));

        // hidden
        try {
            String hiddenString = TextUtils.getMatch(tableInside, GCConstants.PATTERN_HIDDEN, true, null);
            if (StringUtils.isNotBlank(hiddenString)) {
                cache.setHidden(GCLogin.parseGcCustomDate(hiddenString));
            }
            if (cache.getHiddenDate() == null) {
                // event date
                hiddenString = TextUtils.getMatch(tableInside, GCConstants.PATTERN_HIDDENEVENT, true, null);
                if (StringUtils.isNotBlank(hiddenString)) {
                    cache.setHidden(GCLogin.parseGcCustomDate(hiddenString));
                }
            }
        } catch (final ParseException e) {
            // failed to parse cache hidden date
            Log.w("GCParser.parseCache: Failed to parse cache hidden (event) date");
        }

        // favorite
        try {
            cache.setFavoritePoints(Integer
                    .parseInt(TextUtils.getMatch(tableInside, GCConstants.PATTERN_FAVORITECOUNT, true, "0")));
        } catch (final NumberFormatException e) {
            Log.e("Error parsing favorite count", e);
        }

        // cache size
        cache.setSize(CacheSize.getById(
                TextUtils.getMatch(tableInside, GCConstants.PATTERN_SIZE, true, CacheSize.NOT_CHOSEN.id)));
    }

    // cache found
    cache.setFound(TextUtils.matches(page, GCConstants.PATTERN_FOUND)
            || TextUtils.matches(page, GCConstants.PATTERN_FOUND_ALTERNATIVE));

    // cache found date
    try {
        final String foundDateString = TextUtils.getMatch(page, GCConstants.PATTERN_FOUND_DATE, true, null);
        if (StringUtils.isNotBlank(foundDateString)) {
            cache.setVisitedDate(GCLogin.parseGcCustomDate(foundDateString).getTime());
        }
    } catch (final ParseException e) {
        // failed to parse cache found date
        Log.w("GCParser.parseCache: Failed to parse cache found date");
    }

    // cache type
    cache.setType(CacheType
            .getByPattern(TextUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType().id)));

    // on watchlist
    cache.setOnWatchlist(TextUtils.matches(page, GCConstants.PATTERN_WATCHLIST));

    // latitude and longitude. Can only be retrieved if user is logged in
    String latlon = TextUtils.getMatch(page, GCConstants.PATTERN_LATLON, true, "");
    if (StringUtils.isNotEmpty(latlon)) {
        try {
            cache.setCoords(new Geopoint(latlon));
            cache.setReliableLatLon(true);
        } catch (final Geopoint.GeopointException e) {
            Log.w("GCParser.parseCache: Failed to parse cache coordinates", e);
        }
    }

    // cache location
    cache.setLocation(TextUtils.getMatch(page, GCConstants.PATTERN_LOCATION, true, ""));

    // cache hint
    final String result = TextUtils.getMatch(page, GCConstants.PATTERN_HINT, false, null);
    if (result != null) {
        // replace linebreak and paragraph tags
        final String hint = GCConstants.PATTERN_LINEBREAK.matcher(result).replaceAll("\n");
        cache.setHint(StringUtils.replace(hint, "</p>", "").trim());
    }

    cache.checkFields();

    // cache personal note
    cache.setPersonalNote(personalNoteWithLineBreaks);

    // cache short description
    cache.setShortDescription(TextUtils.getMatch(page, GCConstants.PATTERN_SHORTDESC, true, ""));

    // cache description
    cache.setDescription(TextUtils.getMatch(page, GCConstants.PATTERN_DESC, true, ""));

    // cache attributes
    try {
        final String attributesPre = TextUtils.getMatch(page, GCConstants.PATTERN_ATTRIBUTES, true, null);
        if (null != attributesPre) {
            final MatcherWrapper matcherAttributesInside = new MatcherWrapper(
                    GCConstants.PATTERN_ATTRIBUTESINSIDE, attributesPre);

            final ArrayList<String> attributes = new ArrayList<String>();
            while (matcherAttributesInside.find()) {
                if (matcherAttributesInside.groupCount() > 1
                        && !matcherAttributesInside.group(2).equalsIgnoreCase("blank")) {
                    // by default, use the tooltip of the attribute
                    String attribute = matcherAttributesInside.group(2).toLowerCase(Locale.US);

                    // if the image name can be recognized, use the image name as attribute
                    final String imageName = matcherAttributesInside.group(1).trim();
                    if (StringUtils.isNotEmpty(imageName)) {
                        final int start = imageName.lastIndexOf('/');
                        final int end = imageName.lastIndexOf('.');
                        if (start >= 0 && end >= 0) {
                            attribute = imageName.substring(start + 1, end).replace('-', '_')
                                    .toLowerCase(Locale.US);
                        }
                    }
                    attributes.add(attribute);
                }
            }
            cache.setAttributes(attributes);
        }
    } catch (final RuntimeException e) {
        // failed to parse cache attributes
        Log.w("GCParser.parseCache: Failed to parse cache attributes");
    }

    // cache spoilers
    try {
        if (CancellableHandler.isCancelled(handler)) {
            return null;
        }
        CancellableHandler.sendLoadProgressDetail(handler,
                R.string.cache_dialog_loading_details_status_spoilers);

        final MatcherWrapper matcherSpoilersInside = new MatcherWrapper(GCConstants.PATTERN_SPOILER_IMAGE,
                page);

        while (matcherSpoilersInside.find()) {
            // the original spoiler URL (include .../display/... contains a low-resolution image
            // if we shorten the URL we get the original-resolution image
            final String url = matcherSpoilersInside.group(1).replace("/display", "");

            String title = null;
            if (matcherSpoilersInside.group(3) != null) {
                title = matcherSpoilersInside.group(3);
            }
            String description = null;
            if (matcherSpoilersInside.group(4) != null) {
                description = matcherSpoilersInside.group(4);
            }
            cache.addSpoiler(new Image(url, title, description));
        }
    } catch (final RuntimeException e) {
        // failed to parse cache spoilers
        Log.w("GCParser.parseCache: Failed to parse cache spoilers");
    }

    // cache inventory
    try {
        cache.setInventoryItems(0);

        final MatcherWrapper matcherInventory = new MatcherWrapper(GCConstants.PATTERN_INVENTORY, page);
        if (matcherInventory.find()) {
            if (cache.getInventory() == null) {
                cache.setInventory(new ArrayList<Trackable>());
            }

            if (matcherInventory.groupCount() > 1) {
                final String inventoryPre = matcherInventory.group(2);

                if (StringUtils.isNotBlank(inventoryPre)) {
                    final MatcherWrapper matcherInventoryInside = new MatcherWrapper(
                            GCConstants.PATTERN_INVENTORYINSIDE, inventoryPre);

                    while (matcherInventoryInside.find()) {
                        if (matcherInventoryInside.groupCount() > 0) {
                            final Trackable inventoryItem = new Trackable();
                            inventoryItem.setGuid(matcherInventoryInside.group(1));
                            inventoryItem.setName(matcherInventoryInside.group(2));

                            cache.getInventory().add(inventoryItem);
                            cache.setInventoryItems(cache.getInventoryItems() + 1);
                        }
                    }
                }
            }
        }
    } catch (final RuntimeException e) {
        // failed to parse cache inventory
        Log.w("GCParser.parseCache: Failed to parse cache inventory (2)");
    }

    // cache logs counts
    try {
        final String countlogs = TextUtils.getMatch(page, GCConstants.PATTERN_COUNTLOGS, true, null);
        if (null != countlogs) {
            final MatcherWrapper matcherLog = new MatcherWrapper(GCConstants.PATTERN_COUNTLOG, countlogs);

            while (matcherLog.find()) {
                final String typeStr = matcherLog.group(1);
                final String countStr = getNumberString(matcherLog.group(2));

                if (StringUtils.isNotBlank(typeStr) && LogType.UNKNOWN != LogType.getByIconName(typeStr)
                        && StringUtils.isNotBlank(countStr)) {
                    cache.getLogCounts().put(LogType.getByIconName(typeStr), Integer.parseInt(countStr));
                }
            }
        }
    } catch (final NumberFormatException e) {
        // failed to parse logs
        Log.w("GCParser.parseCache: Failed to parse cache log count");
    }

    // waypoints - reset collection
    cache.setWaypoints(Collections.<Waypoint>emptyList(), false);

    // add waypoint for original coordinates in case of user-modified listing-coordinates
    try {
        final String originalCoords = TextUtils.getMatch(page, GCConstants.PATTERN_LATLON_ORIG, false, null);

        if (null != originalCoords) {
            final Waypoint waypoint = new Waypoint(
                    CgeoApplication.getInstance().getString(R.string.cache_coordinates_original),
                    WaypointType.ORIGINAL, false);
            waypoint.setCoords(new Geopoint(originalCoords));
            cache.addOrChangeWaypoint(waypoint, false);
            cache.setUserModifiedCoords(true);
        }
    } catch (final Geopoint.GeopointException e) {
    }

    int wpBegin = page.indexOf("<table class=\"Table\" id=\"ctl00_ContentBody_Waypoints\">");
    if (wpBegin != -1) { // parse waypoints
        if (CancellableHandler.isCancelled(handler)) {
            return null;
        }
        CancellableHandler.sendLoadProgressDetail(handler,
                R.string.cache_dialog_loading_details_status_waypoints);

        String wpList = page.substring(wpBegin);

        int wpEnd = wpList.indexOf("</p>");
        if (wpEnd > -1 && wpEnd <= wpList.length()) {
            wpList = wpList.substring(0, wpEnd);
        }

        if (!wpList.contains("No additional waypoints to display.")) {
            wpEnd = wpList.indexOf("</table>");
            wpList = wpList.substring(0, wpEnd);

            wpBegin = wpList.indexOf("<tbody>");
            wpEnd = wpList.indexOf("</tbody>");
            if (wpBegin >= 0 && wpEnd >= 0 && wpEnd <= wpList.length()) {
                wpList = wpList.substring(wpBegin + 7, wpEnd);
            }

            final String[] wpItems = wpList.split("<tr");

            for (int j = 1; j < wpItems.length; j++) {
                String[] wp = wpItems[j].split("<td");

                // waypoint name
                // res is null during the unit tests
                final String name = TextUtils.getMatch(wp[6], GCConstants.PATTERN_WPNAME, true, 1,
                        CgeoApplication.getInstance().getString(R.string.waypoint), true);

                // waypoint type
                final String resulttype = TextUtils.getMatch(wp[3], GCConstants.PATTERN_WPTYPE, null);

                final Waypoint waypoint = new Waypoint(name, WaypointType.findById(resulttype), false);

                // waypoint prefix
                waypoint.setPrefix(TextUtils.getMatch(wp[4], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, true,
                        2, waypoint.getPrefix(), false));

                // waypoint lookup
                waypoint.setLookup(TextUtils.getMatch(wp[5], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, true,
                        2, waypoint.getLookup(), false));

                // waypoint latitude and longitude
                latlon = Html.fromHtml(TextUtils.getMatch(wp[7], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON,
                        false, 2, "", false)).toString().trim();
                if (!StringUtils.startsWith(latlon, "???")) {
                    waypoint.setLatlon(latlon);
                    waypoint.setCoords(new Geopoint(latlon));
                }

                j++;
                if (wpItems.length > j) {
                    wp = wpItems[j].split("<td");
                }

                // waypoint note
                waypoint.setNote(TextUtils.getMatch(wp[3], GCConstants.PATTERN_WPNOTE, waypoint.getNote()));

                cache.addOrChangeWaypoint(waypoint, false);
            }
        }
    }

    cache.parseWaypointsFromNote();

    // logs
    cache.setLogs(getLogsFromDetails(page, false));

    // last check for necessary cache conditions
    if (StringUtils.isBlank(cache.getGeocode())) {
        searchResult.setError(StatusCode.UNKNOWN_ERROR);
        return searchResult;
    }

    cache.setDetailedUpdatedNow();
    searchResult.addAndPutInCache(Collections.singletonList(cache));
    return searchResult;
}

From source file:com.gargoylesoftware.htmlunit.WebTestCase.java

/**
 * Returns the modified JavaScript after changing how 'alerts' are called.
 * @param html the html/*ww  w .  j a  v  a  2s  .c o  m*/
 * @return the modified html
 */
protected static String getModifiedContent(final String html) {
    // replace alert(x) by a storage in top scope
    // Convert to string here due to: http://code.google.com/p/webdriver/issues/detail?id=209
    return StringUtils.replace(html, "alert(", "(function(t){var x = top.__huCatchedAlerts; x = x ? x : []; "
            + "top.__huCatchedAlerts = x; x.push(String(t))})(");
}

From source file:com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl.java

protected String getParam(String name, XWikiContext context) {
    String param = "";
    try {//from  ww  w .j a  v  a2  s.  c o  m
        param = context.getWiki().getXWikiPreference(name, context);
    } catch (Exception e) {
    }

    if (param == null || "".equals(param)) {
        try {
            param = context.getWiki().Param("xwiki.authentication." + StringUtils.replace(name, "auth_", ""));
        } catch (Exception e) {
        }
    }

    if (param == null) {
        param = "";
    }

    return param;
}