Java String Sanitize sanitizeForCmisName(String in)

Here you can find the source of sanitizeForCmisName(String in)

Description

sanitize For Cmis Name

License

Apache License

Declaration

public static String sanitizeForCmisName(String in) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2012 Fatminds, Inc//from   www . ja va2s . c  om
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

public class Main {
    public static String sanitizeForCmisName(String in) {
        if (null == in || in.isEmpty()) {
            return null;
        }

        in = in.replaceAll("[^a-zA-Z_0-9]", "_").replaceAll("_{2,}+", "_");
        return in;
    }
}

Related

  1. sanitizeColumn(String colName, String relationName)
  2. sanitizeCompletion(String replace)
  3. sanitizeDescription(String description)
  4. sanitizeDir(String name)
  5. sanitizeFolderName(String s)
  6. sanitizeForCsv(String str)
  7. sanitizeForJson(String data)
  8. sanitizeForLogMessage(String unsanitizedString)
  9. sanitizeForSearch(String str)