Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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.
*/
package org.jboss.weld.util.reflection;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor;
/**
* Utility class to produce friendly names e.g. for debugging
*
* @author Pete Muir
* @author Nicklas Karlsson
* @author Jozef Hartinger
*/
public class Formats {
private static final String SNAPSHOT = "SNAPSHOT";
private static final String NULL = "null";
private Formats() {
}
// see WELD-1454
public static String formatAsStackTraceElement(InjectionPoint ij) {
Member member;
if (ij.getAnnotated() instanceof AnnotatedField) {
AnnotatedField annotatedField = (AnnotatedField) ij.getAnnotated();
member = annotatedField.getJavaMember();
} else if (ij.getAnnotated() instanceof AnnotatedParameter>) {
AnnotatedParameter> annotatedParameter = (AnnotatedParameter>) ij.getAnnotated();
member = annotatedParameter.getDeclaringCallable().getJavaMember();
} else {
// Not throwing an exception, because this method is invoked when an exception is already being thrown.
// Throwing an exception here would hide the original exception.
return "-";
}
return member.getDeclaringClass().getName()
+ "." + (member instanceof Constructor> ? "" : member.getName())
+ "(" + getFileName(member.getDeclaringClass()) + ":" + getLineNumber(member) + ")";
}
private static int getLineNumber(Member member) {
// TODO find the actual line number where the member is declared
return 0;
}
private static String getFileName(Class> clazz) {
// TODO find the actual file name the class is declared in
return clazz.getSimpleName() + ".java";
}
/**
* A transformation from one object to a String.
*
* @param the type of the function input
*/
private interface Function {
/**
* Applies the function to an object of type {@code F}, resulting in an
* object of type String.
*
* @param from the source object
* @param position the position in the list the object is at
* @return the resulting object
*/
String apply(F from, int position);
}
private static final Function> SPACE_DELIMITER_FUNCTION = new Function