Here you can find the source of shortenOperationName(String operation)
Parameter | Description |
---|---|
operation | name to shorten |
public static String shortenOperationName(String operation)
//package com.java2s; /**/*from w w w . ja va 2 s. c o m*/ * Copyright 2014 SAP AG * * 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 { /** * Shortens full qualified method names. Thus, * my.full.package.Class.operation() becomes m.f.p.Class.operation() * * @param operation * name to shorten * @return short method name */ public static String shortenOperationName(String operation) { String mainPart = operation.substring(0, operation.indexOf("(")); String[] packages = mainPart.split("\\."); String result = ""; for (int i = 0; i < packages.length - 2; i++) { result += packages[i].substring(0, 1); result += "."; } result += packages[packages.length - 2] + "." + packages[packages.length - 1]; result += "("; String[] parameters = operation.substring( operation.indexOf("(") + 1, operation.indexOf(")")).split( ","); boolean first = true; for (String p : parameters) { if (!first) { result += ","; } if (p.contains(".")) { result += p.substring(p.lastIndexOf(".") + 1); } else { result += p; } first = false; } result += ")"; return result; } }