本文整理汇总了Java中org.eclipse.jdt.core.IMemberValuePair.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java IMemberValuePair.getValue方法的具体用法?Java IMemberValuePair.getValue怎么用?Java IMemberValuePair.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IMemberValuePair
的用法示例。
在下文中一共展示了IMemberValuePair.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSilencedGeneratedAnnotation
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
if ("javax.annotation.Generated".equals(annotation.getElementName())) {
IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair m : memberValuePairs) {
if ("value".equals(m.getMemberName()) && IMemberValuePair.K_STRING == m.getValueKind()) {
if (m.getValue() instanceof String) {
return SILENCED_CODEGENS.contains(m.getValue());
} else if (m.getValue() instanceof Object[]) {
for (Object val : (Object[]) m.getValue()) {
if (SILENCED_CODEGENS.contains(val)) {
return true;
}
}
}
}
}
}
return false;
}
示例2: isSilencedGeneratedAnnotation
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private static boolean isSilencedGeneratedAnnotation(IAnnotation annotation) throws JavaModelException {
if ("javax.annotation.Generated".equals(annotation.getElementName())) {
IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair m : memberValuePairs) {
if ("value".equals(m.getMemberName())
&& IMemberValuePair.K_STRING == m.getValueKind()) {
if (m.getValue() instanceof String) {
return SILENCED_CODEGENS.contains(m.getValue());
} else if (m.getValue() instanceof Object[]) {
for (Object val : (Object[])m.getValue()) {
if(SILENCED_CODEGENS.contains(val)) {
return true;
}
}
}
}
}
}
return false;
}
示例3: sameAnnotationStringValue
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private boolean sameAnnotationStringValue(IAnnotation annotation,
String actionValue) throws JavaModelException {
boolean res = false;
if (annotation.exists()) {
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs) {
res = valuePair.getValueKind() == IMemberValuePair.K_STRING
&& valuePair.getValue() instanceof String
&& ANNOTATION_VALUE.equals(valuePair.getMemberName())
&& actionValue.equals(valuePair.getValue());
if (res) {
break;
}
}
}
return res;
}
示例4: getAnnotationMemberValue
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
public static String getAnnotationMemberValue(IAnnotation annotation, String memberName)
{
try
{
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs)
{
if (memberName.equals(valuePair.getMemberName()))
{
return (String)valuePair.getValue();
}
}
}
catch (JavaModelException e)
{
Activator.log(Status.ERROR, "Failed to get member value pairs.", e);
}
return null;
}
示例5: matches
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
@Override
public boolean matches(IMethod method) throws JavaModelException
{
for (IAnnotation annotation : method.getAnnotations())
{
String annotationName = annotation.getElementName();
if (MybatipseConstants.ANNOTATION_RESULTS.equals(annotationName))
{
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs)
{
if ("id".equals(valuePair.getMemberName()))
{
String resultsId = (String)valuePair.getValue();
return nameMatches(resultsId, matchString, exactMatch);
}
}
}
}
return false;
}
示例6: getMemberValue
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
/**
* Retourne la valeur du membre d'une annotation donnée.
*
* @param annotation Annotation.
* @param memberName Nom du membre.
* @return Valeur du membre.
*/
public static Object getMemberValue(IAnnotation annotation, String memberName) {
try {
for (IMemberValuePair pair : annotation.getMemberValuePairs()) {
if (memberName.equals(pair.getMemberName())) {
return pair.getValue();
}
}
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
return null;
}
示例7: fromAnnotation
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private static Requirement fromAnnotation(
IAnnotation requiredAnnotation, MajorVersion majorVersion) {
if (!requiredAnnotation.exists()) {
return new Requirement(false, Collections.<String>emptySet());
}
IMemberValuePair[] memberValuePairs;
try {
memberValuePairs = requiredAnnotation.getMemberValuePairs();
} catch (JavaModelException e) {
DataflowCorePlugin.logError(e, "Error while retrieving Member Value Pairs for"
+ " Validation.Required annotation %s in Java Element %s", requiredAnnotation,
requiredAnnotation.getParent());
return new Requirement(true, Collections.<String>emptySet());
}
for (IMemberValuePair memberValuePair : memberValuePairs) {
String memberName = memberValuePair.getMemberName();
Object memberValueObj = memberValuePair.getValue();
if (memberName.equals(PipelineOptionsNamespaces.validationRequiredGroupField(majorVersion))
&& memberValueObj instanceof Object[]
&& memberValuePair.getValueKind() == IMemberValuePair.K_STRING) {
Set<String> groups = new HashSet<>();
for (Object group : (Object[]) memberValueObj) {
groups.add(group.toString());
}
return new Requirement(true, groups);
}
}
return new Requirement(true, Collections.<String>emptySet());
}
示例8: createTestSuiteFrame
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
/**
* Creates the test suite frame.
*
* @param testSuiteName
* @param testSuite
* @param testClasses
* @param newTestSuiteElementName
* @param generatedTestSuites
* @param createNew
* @return the test-suite
* @throws JavaModelException
*/
protected IType createTestSuiteFrame(String testSuiteName, ICompilationUnit testSuite,
ICompilationUnit[] testClasses, String newTestSuiteElementName, HashSet<String> generatedTestSuites,
boolean createNew) throws JavaModelException {
IType type = testSuite.getType(testSuiteName);
String testElementList;
if (type.exists()) {
if (!createNew) {
for (IAnnotation annotation : type.getAnnotations()) {
if ("Suite.SuiteClasses".equals(annotation.getElementName())) {
for (IMemberValuePair memberValuePairs : annotation.getMemberValuePairs()) {
Object value = memberValuePairs.getValue();
String suiteClassName;
if (value instanceof Object[]) {
for (Object testSuiteObject : (Object[]) value) {
suiteClassName = testSuiteObject.toString();
if (suiteClassName.startsWith(TESTSUITE_PREFIX)) {
generatedTestSuites.add(suiteClassName + ".class");
}
if (suiteClassName.equals(newTestSuiteElementName)) {
return null;
}
}
}
}
}
}
}
}
testElementList = createCommaSeparatedClassList(testClasses, generatedTestSuites);
return refreshTestSuiteElements(testSuite, testSuiteName, testElementList);
}
示例9: checkMethodReference
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
public static boolean checkMethodReference(String baseMethodName,
String baseMethodSignature, IMethod methodToCheck)
throws JavaModelException {
IAnnotation anno = methodToCheck.getAnnotation("MethodRef");
if (anno == null || !anno.exists()) {
return false;
}
IMemberValuePair[] valuePair = anno.getMemberValuePairs();
boolean signatureFound = false, nameFound = false;
for (IMemberValuePair vP : valuePair) {
Object o = vP.getValue();
if (o != null) {
String methodRefValue = o.toString();
if ("signature".equals(vP.getMemberName())) {
if (methodRefValue.equals(baseMethodSignature)) {
signatureFound = true;
} else {
return false;
}
} else if ("name".equals(vP.getMemberName())) {
if (methodRefValue.equals(baseMethodName)) {
nameFound = true;
} else {
return false;
}
}
}
}
return signatureFound && nameFound;
}
示例10: fetchAnnotationStringValue
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private String fetchAnnotationStringValue(IAnnotation annotation)
throws JavaModelException {
if (annotation.exists()) {
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs) {
if (valuePair.getValueKind() == IMemberValuePair.K_STRING
&& valuePair.getValue() instanceof String
&& ANNOTATION_VALUE.equals(valuePair.getMemberName())) {
return (String) valuePair.getValue();
}
}
}
return null;
}
示例11: readValueFromAnnotation
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
public static void readValueFromAnnotation(
IAnnotation annotation, String memberName, IProject project, AST ast,
ObjectCallback<String, JavaModelException> callback)
throws JavaModelException
{
if (annotation == null)
{
return;
}
IMemberValuePair[] pairs = annotation.getMemberValuePairs();
for (IMemberValuePair pair : pairs)
{
if (memberName.equals(pair.getMemberName()))
{
if (pair.getValueKind() == IMemberValuePair.K_UNKNOWN)
{
// The value is unknown at this stage
continue;
}
else
{
Object[] values = pair.getValue().getClass().isArray()
? (Object[]) pair.getValue()
: new Object[] { pair.getValue() };
for (Object value : values)
{
String eval = eval(value, pair.getValueKind(), ast, project);
callback.callback(eval);
}
}
}
}
}
示例12: fetchActionAnnotationValue
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private List<IAnnotation> fetchActionAnnotationValue(
IAnnotatable annotatable, boolean actionsImportExist,
boolean actionImportExist) throws JavaModelException {
List<IAnnotation> result = new ArrayList<IAnnotation>();
IAnnotation[] annotations = annotatable.getAnnotations();
for (IAnnotation annotation : annotations) {
if (annotation.exists()) {
boolean fetchValue = ACTIONS_ANNOTATION_FQN.equals(annotation
.getElementName())
|| (ACTIONS_ANNOTATION.equals(annotation
.getElementName()) && actionsImportExist);
if (fetchValue) {
IMemberValuePair[] valuePairs = annotation
.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs) {
if (valuePair.getValueKind() == IMemberValuePair.K_ANNOTATION
&& ANNOTATION_VALUE.equals(valuePair
.getMemberName())) {
// single value
if (valuePair.getValue() instanceof IAnnotation) {
result.add((IAnnotation) valuePair.getValue());
} else {
// array
Object[] objs = (Object[]) valuePair.getValue();
for (Object o : objs) {
result.add((IAnnotation) o);
}
}
}
}
} else {
fetchValue = ACTION_ANNOTATION_FQN.equals(annotation
.getElementName())
|| (ACTION_ANNOTATION.equals(annotation
.getElementName()) && actionImportExist);
if (fetchValue) {
result.add(annotation);
}
}
}
}
return result;
}
示例13: add
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
@Override
public void add(IMethod method)
{
found = true;
try
{
ILocalVariable[] parameters = method.getParameters();
boolean foundParamAnnotation = false;
for (int i = 0; i < parameters.length; i++)
{
String paramFqn = Signature.toString(parameters[i].getTypeSignature());
foundParamAnnotation = false;
for (IAnnotation annotation : parameters[i].getAnnotations())
{
if (MybatipseConstants.ANNOTATION_PARAM.equals(annotation.getElementName()))
{
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
if (valuePairs.length == 1)
{
IMemberValuePair valuePair = valuePairs[0];
String paramValue = (String)valuePair.getValue();
paramMap.put(paramValue, paramFqn);
foundParamAnnotation = true;
}
}
}
if (!foundParamAnnotation && isParamAttrGenerated())
{
paramMap.put(parameters[i].getElementName(), paramFqn);
}
paramMap.put("param" + (i + 1), paramFqn);
}
if (parameters.length == 1 && !foundParamAnnotation)
{
// Statement has a sole unnamed parameter
paramMap.clear();
putSoleParam(Signature.toString(parameters[0].getTypeSignature()));
}
}
catch (JavaModelException e)
{
Activator.log(Status.ERROR,
"Failed to collect parameters of method " + method.getElementName() + " in "
+ method.getDeclaringType().getFullyQualifiedName(),
e);
}
}
示例14: parseBinaryMapper
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private static void parseBinaryMapper(final IJavaProject project, final IType mapperType,
final MapperInfo mapperInfo) throws JavaModelException
{
for (IMethod method : mapperType.getMethods())
{
if (Flags.isDefaultMethod(method.getFlags()))
continue;
String statementAnno = null;
for (IAnnotation annotation : method.getAnnotations())
{
String annoName = annotation.getElementName();
if (MybatipseConstants.STATEMENT_ANNOTATIONS.contains(annoName))
{
statementAnno = annoName;
}
else if (MybatipseConstants.ANNOTATION_RESULTS.equals(annoName))
{
IMemberValuePair[] valuePairs = annotation.getMemberValuePairs();
for (IMemberValuePair valuePair : valuePairs)
{
if ("id".equals(valuePair.getMemberName()))
{
String resultsId = (String)valuePair.getValue();
if (resultsId != null)
mapperInfo.addResultMap(resultsId, method);
}
}
}
}
mapperInfo.addMethod(method, statementAnno);
String[] superInterfaces = mapperType.getSuperInterfaceNames();
for (String superInterface : superInterfaces)
{
if (!Object.class.getName().equals(superInterface))
{
IType superInterfaceType = project.findType(superInterface.replace('$', '.'));
parseMapper(project, superInterfaceType, mapperInfo);
}
}
}
}
示例15: findSubModules
import org.eclipse.jdt.core.IMemberValuePair; //导入方法依赖的package包/类
private synchronized void findSubModules(IProgressMonitor monitor)
{
if (subModules != null)
{
return;
}
subModules = new ArrayList<TapestryModule>();
try
{
final IAnnotation annotation = findSubmoduleAnnotation();
if (annotation == null)
{
return;
}
for (IMemberValuePair pair : annotation.getMemberValuePairs())
{
Object[] classes = pair.getValue().getClass().isArray()
? (Object[]) pair.getValue()
: new Object[] { pair.getValue() };
for (Object className : classes)
{
if (monitor.isCanceled())
{
return;
}
String typeName = EclipseUtils.toClassNameFromImports(
getEclipseProject(),
moduleClass,
(String) className);
IType subModuleClass = EclipseUtils.findTypeDeclaration(
moduleClass.getJavaProject().getProject(),
IJavaSearchConstants.CLASS,
typeName);
if (subModuleClass != null)
{
subModules.add(
Activator.getDefault()
.getTapestryModuleFactory()
.createTapestryModule(
project,
subModuleClass,
new ObjectCallback<TapestryModule, RuntimeException>()
{
@Override
public void callback(TapestryModule obj)
{
obj.addReference(new TapestryModuleReference(new JavaElementReference(obj, annotation), false)
{
@Override
public String getLabel()
{
String annotationName = TapestryUtils.getSimpleName(annotation.getElementName());
return "via @" + annotationName + " of " + getName();
}
});
}
}));
}
}
}
}
catch (JavaModelException e)
{
Activator.getDefault().logError("Error getting submodules for " + getName(), e);
}
}