|
Java example source code file (Names.java)
The Names.java Java example source code/* * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.internal.ws.processor.generator; import com.sun.istack.internal.NotNull; import com.sun.tools.internal.ws.processor.model.Fault; import com.sun.tools.internal.ws.processor.model.ModelProperties; import com.sun.tools.internal.ws.processor.model.Port; import com.sun.tools.internal.ws.processor.model.java.JavaInterface; import com.sun.tools.internal.ws.processor.model.java.JavaStructureMember; import com.sun.tools.internal.ws.processor.modeler.ModelerConstants; import com.sun.tools.internal.ws.util.ClassNameInfo; import com.sun.xml.internal.ws.util.StringUtils; import javax.xml.namespace.QName; import java.util.HashMap; import java.util.Map; /** * Names provides utility methods used by other wscompile classes * for dealing with identifiers. * * @author WS Development Team */ public final class Names { private Names() { } public static String getPortName(Port port) { String javaPortName = (String) port.getProperty(ModelProperties.PROPERTY_JAVA_PORT_NAME); if (javaPortName != null) { return javaPortName; } else { QName portName = (QName) port.getProperty( ModelProperties.PROPERTY_WSDL_PORT_NAME); if (portName != null) { return portName.getLocalPart(); } else { String name = stripQualifier(port.getJavaInterface().getName()); return ClassNameInfo.replaceInnerClassSym(name); } } } public static String stripQualifier(String name) { return ClassNameInfo.getName(name); } public static String getPackageName(String className) { String packageName = ClassNameInfo.getQualifier(className); return packageName != null ? packageName : ""; } public static String customJavaTypeClassName(JavaInterface intf) { return intf.getName(); } public static String customExceptionClassName(Fault fault) { return fault.getJavaException().getName(); } public static String getExceptionClassMemberName(){ return GeneratorConstants.FAULT_CLASS_MEMBER_NAME.getValue(); } public static boolean isJavaReservedWord(String name) { return RESERVED_WORDS.get(name) != null; } /** * See if its a java keyword name, if so then mangle the name */ public static @NotNull String getJavaReserverVarialbeName(@NotNull String name){ return (RESERVED_WORDS.get(name) == null) ? name : RESERVED_WORDS.get(name); } /* here we check on wether return values datatype is boolean. If its boolean, instead of a get method its set a is<MethodName> to comply with JavaBeans Pattern spec */ public static String getJavaMemberReadMethod(JavaStructureMember member) { String return_value; if (member.getType().getRealName().equals(ModelerConstants.BOOLEAN_CLASSNAME.getValue())) { return_value = GeneratorConstants.IS.getValue() + StringUtils.capitalize(member.getName()); } else { return_value = GeneratorConstants.GET.getValue() + StringUtils.capitalize(member.getName()); } return (return_value); } public static String getResponseName(String messageName) { return messageName + GeneratorConstants.RESPONSE.getValue(); } private static final Map<String, String> RESERVED_WORDS = new HashMap Other Java examples (source code examples)Here is a short list of links related to this Java Names.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.