Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 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.Map;
 public final class FaultBean {
     private static final String[] EXCLUDED_GETTER = new String[] {"getCause",
     public boolean faultBeanExists(final Class<?> exceptionClass) {
         String fb = getWebFaultBean(exceptionClass);
         if (!StringUtils.isEmpty(fb)) {
             try {
                 return AnnotationUtil.loadClass(fb,
                                                 exceptionClass.getClassLoader()) != null;
             } catch (Exception e) {
                 return false;
         return false
     private String getWebFaultBean(final Class<?> exceptionClass) {
         WebFault fault = exceptionClass.getAnnotation(WebFault.class);
         if (fault == null) {
             return null;
         return fault.faultBean();
     private boolean isWebFaultAbsent(final Class<?> exceptionClass) {
         return StringUtils.isEmpty(getWebFaultBean(exceptionClass));
     public WrapperBeanClass transform(final Class<?> exceptionClassfinal String defaultPackage) {
         WrapperBeanClass jClass = new WrapperBeanClass();
         if (isWebFaultAbsent(exceptionClass)) {
             jClass.setName(exceptionClass.getSimpleName() + "Bean");
         } else {
         String pkg = PackageUtils.getPackageName(exceptionClass);
         if (pkg.length() > 0) {
             jClass.setElementName(new QName(URIParserUtil.getNamespace(pkg),
         } else {
             jClass.setElementName(new QName(URIParserUtil.getNamespace(.),
         jClass.annotate(new WrapperBeanAnnotator(exceptionClass));
         return jClass;
     private String getFieldName(final Method method) {
         String name = method.getName().substring(3);
         char chars[] = name.toCharArray();
         chars[0] = Character.toLowerCase(chars[0]);
        return new String(chars);
    private boolean isIncludedGetter(final Method method) {
        return method.getName().startsWith("get")
            && !Arrays.asList().contains(method.getName());
    private void buildBeanFields(final Class<?> exceptionClassfinal JavaClass jClass) {
        Map<StringJavaFieldfields = new TreeMap<StringJavaField>(); 
        for (Method method : exceptionClass.getMethods()) {
            if (isIncludedGetter(method)) {
                JavaField field = new JavaField(getFieldName(method),
                fields.put(field.getName(), field);
        for (Map.Entry<StringJavaFieldent : fields.entrySet()) {
New to GrepCode? Check out our FAQ X