Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Generates valid component id from component name (see general comments in
     * class {@link ComponentIDUtil})
     * 
     * @param compName
     * @return
     */
    public static String generateIDFromName(String compName) {
        String alphaDigitsUnderscoreDashString = compName.replaceAll("[^a-zA-Z0-9\\-\\_]+", "_");
        if (alphaDigitsUnderscoreDashString.matches("^[0-9].*")) {
            alphaDigitsUnderscoreDashString = "_" + alphaDigitsUnderscoreDashString;
        }
        return alphaDigitsUnderscoreDashString;
    }
}