当前位置: 首页>>代码示例>>Java>>正文


Java SingleMemberAnnotation.getValue方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.SingleMemberAnnotation.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java SingleMemberAnnotation.getValue方法的具体用法?Java SingleMemberAnnotation.getValue怎么用?Java SingleMemberAnnotation.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.SingleMemberAnnotation的用法示例。


在下文中一共展示了SingleMemberAnnotation.getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateUiHandlerFieldExistenceInUiXml

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void validateUiHandlerFieldExistenceInUiXml(
    MethodDeclaration uiHandlerDecl) {
  Annotation annotation = JavaASTUtils.findAnnotation(uiHandlerDecl,
      UiBinderConstants.UI_HANDLER_TYPE_NAME);

  if (annotation instanceof SingleMemberAnnotation) {
    SingleMemberAnnotation uiHandlerAnnotation = (SingleMemberAnnotation) annotation;
    Expression exp = uiHandlerAnnotation.getValue();
    if (exp instanceof StringLiteral) {
      validateFieldExistenceInUiXml(
          (TypeDeclaration) uiHandlerDecl.getParent(), exp,
          ((StringLiteral) exp).getLiteralValue());
    } else if (exp instanceof ArrayInitializer) {
      for (Expression element : (List<Expression>) ((ArrayInitializer) exp).expressions()) {
        if (element instanceof StringLiteral) {
          validateFieldExistenceInUiXml(
              (TypeDeclaration) uiHandlerDecl.getParent(), element,
              ((StringLiteral) element).getLiteralValue());
        }
      }
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:UiBinderJavaValidator.java

示例2: getExplicitMultiplicity

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private static Integer getExplicitMultiplicity(TypeDeclaration typeDeclaration, String annotationName) {
	for (Object modifier : typeDeclaration.modifiers()) {
		if (modifier instanceof SingleMemberAnnotation) {
			SingleMemberAnnotation annotation = (SingleMemberAnnotation) modifier;
			if (annotation.getTypeName().toString().equals(annotationName)) {
				Expression value = annotation.getValue();
				if (value instanceof NumberLiteral) {
					NumberLiteral num = (NumberLiteral) value;
					try {
						return new Integer(Integer.parseInt(num.getToken()));
					} catch (NumberFormatException e) {
						// Just let it fall through to returning 'null'
						// below.
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:21,代码来源:MultiplicityProvider.java

示例3: traverseMethodParams

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private void traverseMethodParams(MethodDeclaration methodDeclaration) throws IOException {
	List parameters = methodDeclaration.parameters();
	for (Iterator itParams = parameters.iterator(); itParams.hasNext();) {
		SingleVariableDeclaration param = (SingleVariableDeclaration) itParams.next();

		ITypeBinding type = param.resolveBinding().getType();
		if (hasAnnotation(param.modifiers()) && !type.isPrimitive()) {
			SingleMemberAnnotation annotation = getAnnotation(param.modifiers());
			Expression value = annotation.getValue();
			if (value instanceof StringLiteral) { //@Domain("D")
				StringLiteral annotValue = (StringLiteral)value;
				String parserInput = annotValue.getLiteralValue();
				AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
				DomainParams annot = annotInfo.getAnnotation();	
			boolean isDom = isDomain(methodDeclaration.resolveBinding().getDeclaringClass(), annot);
			boolean isDomPars = isDomainParams(methodDeclaration.resolveBinding().getDeclaringClass(), annot);
			
			ObjectMetricItem archMetricItem = new ObjectMetricItem(param.resolveBinding().getKey(),
				        param.getName().getFullyQualifiedName(),
				        param.getType().resolveBinding().getQualifiedName(),
				        parserInput,
				        methodDeclaration.resolveBinding().getDeclaringClass().getQualifiedName(),
				        param.toString(),
				        Modifier.isStatic(param.getModifiers()),
				        "MethodParams",
				        param.resolveBinding().getType().isArray(),
				        param.resolveBinding().getType().isEnum(),
				        param.resolveBinding().getType().isParameterizedType(),
				        isDom,
				        isDomPars,
				        annot.isObjectPublicDomain());
			if (!objectsHashtable.containsKey(archMetricItem.toString())) {
				objectsHashtable.put(archMetricItem.toString(), archMetricItem);
				}
				// TODO: src.triplets for Method Params
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:40,代码来源:AnnotatMetrics.java

示例4: getAnnotationList

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
public List<String> getAnnotationList(List<IExtendedModifier> paramModifiers, String annotation) {	
	List<String> found = new ArrayList<String>();
	
	for (IExtendedModifier o:paramModifiers){
		if (o instanceof SingleMemberAnnotation) {
			SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
			if (annot.getTypeName().toString().equals(annotation)) {

				Expression value = annot.getValue();
				if (value instanceof ArrayInitializer) { //@Domains( {"D", "U"})
					ArrayInitializer annotValueArray = (ArrayInitializer)value;
					found = new ArrayList<String>();
					for (Object s:annotValueArray.expressions()){
						if (s instanceof StringLiteral) {
							StringLiteral sLiteral = (StringLiteral)s;
							found.add(sLiteral.getLiteralValue());
						}
					}
					return found;
				}
				if (value instanceof StringLiteral) { //@Domains ("D")
					StringLiteral annotValue = (StringLiteral)value;
					String parserInput = annotValue.getLiteralValue();
					found = new ArrayList<String>();
					found.add(parserInput);
					return found;
				}
			}
		}
	}
	return found;
}
 
开发者ID:aroog,项目名称:code,代码行数:33,代码来源:AnnotatMetrics.java

示例5: visit

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
@Override
		public boolean visit(VariableDeclarationStatement param) {
			
			ITypeBinding type = param.getType().resolveBinding();
			if (hasAnnotation(param.modifiers()) && !type.isPrimitive()) {
				List<VariableDeclarationFragment> L = param.fragments();
				for (VariableDeclarationFragment oo : L) {

					SingleMemberAnnotation annotation = getAnnotation(param.modifiers());
					Expression value = annotation.getValue();
					if (value instanceof StringLiteral) { //@Domain("D")
						StringLiteral annotValue = (StringLiteral)value;
						String parserInput = annotValue.getLiteralValue();
						AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
						DomainParams annot = annotInfo.getAnnotation();	
						boolean b = annot.isObjectPublicDomain();
						if (b)
						{
							b = true;
						}


						boolean isDom = false;
						boolean isDomPars = false;
						String qualifiedName = "";
				
//						if (oo.resolveBinding().getDeclaringMethod() != null) {
//							qualifiedName = oo.resolveBinding().getDeclaringMethod().getDeclaringClass().getQualifiedName();
//
//							isDom = isDomain(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(), annot);
//							isDomPars = isDomainParams(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(),annot);
//
//
//						}
//						else 
						{

							qualifiedName = currentType.resolveBinding().getQualifiedName();

							isDom = isDomain(currentType.resolveBinding(), annot);
							isDomPars = isDomainParams(currentType.resolveBinding() , annot);		

						}
						
						ObjectMetricItem archMetricItem = new ObjectMetricItem(oo.resolveBinding().getKey(),oo.resolveBinding().getName().toString(),
								param.getType().resolveBinding().getQualifiedName().toString(),
								parserInput,
								qualifiedName,
								oo.toString(),
								Modifier.isStatic(param.getModifiers()),
								"LocalVariable",
								type.isArray(),
								type.isEnum(),
								type.isParameterizedType(),
								isDom,
								isDomPars,
								annot.isObjectPublicDomain()
							);
						
						
							
						if (!objectsHashtable.containsKey(archMetricItem.toString())) {
							objectsHashtable.put(archMetricItem.toString(), archMetricItem);
						}
						
						// TODO: src.triplets for Local variables
					}
				}
			}
				return super.visit(param);
		}
 
开发者ID:aroog,项目名称:code,代码行数:72,代码来源:AnnotatMetrics.java

示例6: getValue

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private String getValue(SingleMemberAnnotation currentAnnotation) {
 String value = "";
 if (currentAnnotation != null ) {
 	Expression value2 = currentAnnotation.getValue();
 	if (value2 instanceof StringLiteral ) {
 		return ((StringLiteral)value2).getLiteralValue();
 	}
 }
 return value;
}
 
开发者ID:aroog,项目名称:code,代码行数:11,代码来源:SaveAnnotations.java

示例7: obtainSingleMemberAnnotationValue

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
public static Expression obtainSingleMemberAnnotationValue(BodyDeclaration declaration, Class<?> annotationClass) {
	Annotation annotation = obtainAnnotation(declaration, annotationClass);
	if (annotation != null && annotation.isSingleMemberAnnotation()) {
		SingleMemberAnnotation singleMemberAnnot = (SingleMemberAnnotation) annotation;
		return singleMemberAnnot.getValue();
	}
	return null;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:9,代码来源:SharedUtils.java

示例8: traverseMethodReturn

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private void traverseMethodReturn(MethodDeclaration methodDeclaration) throws IOException {
	Type returnType2 = methodDeclaration.getReturnType2();
	if (returnType2 != null) {
		ITypeBinding resolveBinding = returnType2.resolveBinding();
		noMethods++;
		if (resolveBinding.getName().equals("void")) noVoidReturnTypes++;
		if (hasAnnotation(methodDeclaration.modifiers()) && !resolveBinding.isPrimitive()) {

			SingleMemberAnnotation annotation = getAnnotation(methodDeclaration.modifiers());
			Expression value = annotation.getValue();
			if (value instanceof StringLiteral) { //@Domain("D")
				StringLiteral annotValue = (StringLiteral)value;
				String parserInput = annotValue.getLiteralValue();
				AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
				DomainParams annot = annotInfo.getAnnotation();	

				boolean isDom = isDomain(methodDeclaration.resolveBinding().getDeclaringClass(), annot);
				boolean isDomPars = isDomainParams(methodDeclaration.resolveBinding().getDeclaringClass(), annot);


				ObjectMetricItem archMetricItem = new ObjectMetricItem(methodDeclaration.resolveBinding().getKey(),
						methodDeclaration.getName().getFullyQualifiedName(),
						resolveBinding.getQualifiedName(),
						parserInput,
						methodDeclaration.resolveBinding().getDeclaringClass().getQualifiedName(),
						returnType2.toString(),
						Modifier.isStatic(methodDeclaration.getModifiers()),
						"ReturnType",
						returnType2.resolveBinding().isArray(),
						returnType2.resolveBinding().isEnum(),
						returnType2.resolveBinding().isParameterizedType(),
						isDom,
						isDomPars,
						annot.isObjectPublicDomain());
				if (!objectsHashtable.containsKey(archMetricItem.toString())) {
					objectsHashtable.put(archMetricItem.toString(), archMetricItem);
				}
				// TODO: src.triplets for MethodReturn type					
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:43,代码来源:AnnotatMetrics.java

示例9: traverseFields

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入方法依赖的package包/类
private void traverseFields(TypeDeclaration declaration) {
	FieldDeclaration[] fieldDeclarations = declaration.getFields();
	for (int i = 0; i < fieldDeclarations.length; i++) {
		FieldDeclaration fieldDeclaration = fieldDeclarations[i];
		ITypeBinding type = fieldDeclaration.getType().resolveBinding();

		if (hasAnnotation(fieldDeclaration.modifiers()) && !type.isPrimitive()) {

			List ff = fieldDeclaration.fragments();
			for (Object ff1 : ff) {
				VariableDeclaration V = (VariableDeclaration) ff1;
				String key = V.resolveBinding().getKey();
				String name = V.getName().getIdentifier();
				String objectType = fieldDeclaration.getType().resolveBinding().getQualifiedName();
				
				String enclosingType = declaration.resolveBinding().getQualifiedName();
			
				String ast = fieldDeclaration.getAST().toString();
				boolean isStatic = Modifier.isStatic(fieldDeclaration.getModifiers());
				//					
				SingleMemberAnnotation annotation = getAnnotation(fieldDeclaration.modifiers());
				Expression value = annotation.getValue();
				if (value instanceof StringLiteral) { //@Domain("D")
					StringLiteral annotValue = (StringLiteral)value;
					String parserInput = annotValue.getLiteralValue();
					AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
					DomainParams annot = annotInfo.getAnnotation();	
				
					boolean isDomainParam = isDomainParams(declaration.resolveBinding(), annot);
					boolean isDomain = isDomain(declaration.resolveBinding(), annot);
					ObjectMetricItem archMetricItem = new ObjectMetricItem(key,name,
							objectType,
							parserInput,
							enclosingType,
							ast,
							isStatic,
							"Field",
							type.isArray(),
							type.isEnum(),
							type.isParameterizedType(),
							isDomain,
							isDomainParam,
							annot.isObjectPublicDomain()
					);
					// TODO: Do we need the following two lines?
					archMetricItem.setDomainParams(isDomainParam);
					archMetricItem.setDomain(isDomain);
					if (!objectsHashtable.containsKey(archMetricItem.toString())) {							
						objectsHashtable.put(archMetricItem.toString(), archMetricItem);
					}
					
					// TODO: src.triplets for Field
				}

				else
				{
					//this should not happen
					System.out.println("Error in field declaration: "+ value);
				}
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:64,代码来源:AnnotatMetrics.java


注:本文中的org.eclipse.jdt.core.dom.SingleMemberAnnotation.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。