Here you can find the source of splitTemplateName(String templateName)
Parameter | Description |
---|---|
templateName | String in form <code>identifier_field_locale</code> |
public static String[] splitTemplateName(String templateName)
//package com.java2s; /*/*from w ww . ja v a2s . 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. */ import java.util.*; public class Main { /** * Splits template name to get identifier, field name and locale * * @param templateName * String in form <code>identifier_field_locale</code> * @return Array containing identifier, field and locale or empty array if * string format is incorrect */ public static String[] splitTemplateName(String templateName) { ArrayList result = new ArrayList(); int k = templateName.lastIndexOf("_"); if (k != -1) { String locale = templateName.substring(k + 1); templateName = templateName.substring(0, k); k = templateName.lastIndexOf("_"); if (k != -1) { String field = templateName.substring(k + 1); templateName = templateName.substring(0, k); result.add(templateName); result.add(field); result.add(locale); } } return (String[]) result.toArray(new String[0]); } }