本文整理汇总了Java中org.aikodi.chameleon.core.modifier.Modifier类的典型用法代码示例。如果您正苦于以下问题:Java Modifier类的具体用法?Java Modifier怎么用?Java Modifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Modifier类属于org.aikodi.chameleon.core.modifier包,在下文中一共展示了Modifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCodeVariable
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
/********************
* MEMBER VARIABLES *
********************/
// public String toCodeMemberVariable(RegularMemberVariable var) {
// return startLine() + toCodeVariable(var);
// }
public String toCodeVariable(FormalParameter var) {
final StringBuffer result = new StringBuffer();
new Visitor() {
public void visit(Object element) {
result.append((toCodeModifier((Modifier)element)));
result.append(" ");
}
}.applyTo(var.modifiers());
result.append(toCode(var.getTypeReference()));
result.append(" ");
result.append(var.name());
// if(var.getInitialization() != null) {
// result.append(" = ");
// result.append(toCode(var.getInitialization()));
// }
// result.append(";");
return result.toString();
}
示例2: getFilterModifiers
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
@Override
public List<Modifier> getFilterModifiers() {
List<Modifier> result = new ArrayList<Modifier>();
result.add(new Private());
result.add(new Protected());
result.add(new Public());
result.add(new Default());
result.add(new Static());
result.add(new Final());
result.add(new Abstract());
result.add(new Constructor());
result.add(new Interface());
result.add(new Native());
return result;
}
示例3: toCodeModifier
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
protected String toCodeModifier(Modifier element) {
if(element instanceof Public) {
return "public";
} else if(element instanceof Protected) {
return "protected";
} else if(element instanceof Private) {
return "private";
} else if(element instanceof Default) {
return "default";
} else if(element instanceof Abstract) {
return "abstract";
} else if(element instanceof Static) {
return "static";
} else if(element instanceof Final) {
return "final";
} else if(element instanceof StrictFP) {
return "strictfp";
} else if(element instanceof Synchronized) {
return "synchronized";
} else if(element instanceof Constructor) {
return "";
} else if(element instanceof Native) {
return "native";
} else if(element instanceof Interface) {
return "";
} else if(element instanceof AnnotationModifier) {
return "@" + toCode(((AnnotationModifier) element).typeReference());
} else if(element instanceof Volatile) {
return "volatile";
} else if(element instanceof Enum) {
return "enum";
}
else {
throw new IllegalArgumentException("The given element is not know by the Java syntax: "+element.getClass().getName());
}
}
示例4: toCodeInterface
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
public String toCodeInterface(Type type) {
final StringBuffer result = startLine();
//Modifiers
for(Modifier element: type.modifiers()) {
result.append((toCodeModifier((Modifier)element)));
result.append(" ");
}
//Name
result.append("interface ");
result.append(type.name());
appendTypeParameters(type.parameters(TypeParameter.class), result);
List<SubtypeRelation> superTypes = new ArrayList<>(type.explicitNonMemberInheritanceRelations(SubtypeRelation.class));
new SafePredicate<SubtypeRelation>() {
public boolean eval(SubtypeRelation rel) {
return ! toCode((rel).superClassReference()).equals("java.lang.Object");
}
}.filter(superTypes);
if(superTypes.size() > 0) {
result.append(" extends ");
Iterator iter = superTypes.iterator();
while(iter.hasNext()) {
TypeReference tr = ((AbstractInheritanceRelation)iter.next()).superClassReference();
result.append(toCode(tr));
if (iter.hasNext()) {
result.append(", ");
}
}
}
result.append(" ");
result.append(toCodeClassBlock(type));
return result.toString();
}
示例5: toCodeVariableDeclarator
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
public String toCodeVariableDeclarator(VariableDeclarator local) {
final StringBuffer result = new StringBuffer();
List modifiers = local.modifiers();
if (modifiers.size() != 0) {
new Visitor() {
public void visit(Object o) {
result.append(toCodeModifier((Modifier)o) + " ");
}
}.applyTo(modifiers);
}
result.append(toCode(local.typeReference()));
result.append(" ");
boolean first = true;
for(VariableDeclaration element: local.variableDeclarations()) {
// LocalVariable variable = (LocalVariable)element;
if (!first) {
result.append(", ");
}
else {
first = false;
}
result.append(element.name());
Expression initCode = element.initialization();
if (initCode != null) {
result.append(" = ");
result.append(toCode(initCode));
}
}
return result.toString();
}
示例6: accessToFieldModifier
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
protected List<Modifier> accessToFieldModifier(int access) {
List<Modifier> result = new ArrayList<Modifier>();
for(Integer i: _fieldAccessList) {
if((access & i) != 0) {
result.add(Util.clone(_fieldAccessMap.get(i)));
}
}
return result;
}
示例7: initFieldAccessMap
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
private void initFieldAccessMap() {
_fieldAccessMap = new HashMap<Integer, Modifier>();
_fieldAccessMap.put(ACC_PUBLIC, new Public());
_fieldAccessMap.put(ACC_PRIVATE, new Private());
_fieldAccessMap.put(ACC_PROTECTED, new Protected());
_fieldAccessMap.put(ACC_STATIC, new Static());
_fieldAccessMap.put(ACC_FINAL, new Final());
_fieldAccessMap.put(Opcodes.ACC_VOLATILE, new Volatile());
_classAccessMap.put(Opcodes.ACC_ENUM, new Enum());
_fieldAccessList = new ArrayList<Integer>(_fieldAccessMap.keySet());
}
示例8: accessToMethodModifier
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
protected List<Modifier> accessToMethodModifier(int access) {
List<Modifier> result = new ArrayList<Modifier>();
for(Integer i: _methodAccessList) {
if((access & i) != 0) {
result.add(Util.clone(_methodAccessMap.get(i)));
}
}
return result;
}
示例9: initMethodAccessMap
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
private void initMethodAccessMap() {
_methodAccessMap = new HashMap<Integer, Modifier>();
_methodAccessMap.put(ACC_PUBLIC, new Public());
_methodAccessMap.put(ACC_PRIVATE, new Private());
_methodAccessMap.put(ACC_PROTECTED, new Protected());
_methodAccessMap.put(ACC_STATIC, new Static());
_methodAccessMap.put(Opcodes.ACC_SYNCHRONIZED, new Synchronized());
_methodAccessMap.put(ACC_FINAL, new Final());
_methodAccessMap.put(Opcodes.ACC_NATIVE, new Native());
_methodAccessMap.put(ACC_STRICT, new StrictFP());
_methodAccessMap.put(ACC_INTERFACE, new Interface());
_methodAccessMap.put(ACC_ABSTRACT, new Abstract());
_methodAccessList = new ArrayList<Integer>(_methodAccessMap.keySet());
}
示例10: accessToClassModifier
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
protected List<Modifier> accessToClassModifier(int access) {
List<Modifier> result = new ArrayList<Modifier>();
for(Integer i: _classAccessList) {
if((access & i) != 0) {
Modifier modifier = _classAccessMap.get(i);
if(modifier != null) {
result.add(Util.clone(modifier));
}
}
}
return result;
}
示例11: initClassAccessMap
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
private void initClassAccessMap() {
_classAccessMap = new HashMap<Integer, Modifier>();
_classAccessMap.put(ACC_PUBLIC, new Public());
_classAccessMap.put(ACC_PRIVATE, new Private());
_classAccessMap.put(ACC_PROTECTED, new Protected());
_classAccessMap.put(ACC_FINAL, new Final());
_classAccessMap.put(ACC_STATIC, new Static()); // not according to Opcodes, but I think that is wrong
_classAccessMap.put(ACC_STRICT, new StrictFP()); // not according to Opcodes, but I think that is wrong
_classAccessMap.put(ACC_SUPER, null); // What is this?
_classAccessMap.put(ACC_INTERFACE, new Interface());
_classAccessMap.put(ACC_ABSTRACT, new Abstract());
_classAccessMap.put(Opcodes.ACC_ENUM, new Enum());
_classAccessList = new ArrayList<Integer>(_classAccessMap.keySet());
}
示例12: isConstructor
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
private boolean isConstructor(Element element) {
// FIXME element.isTrue(language(Java.class).CONSTRUCTOR) doesn't work since
// the type
// and the constructor aren't connected to the model during parsing.
// The suck is strong in this one
List<Modifier> mods = ((Declarator) element).modifiers();
for (Modifier mod : mods) {
if (mod instanceof JavaConstructor) {
return true;
}
}
return false;
}
示例13: visitKlass
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
@Override
public Type visitKlass(KlassContext ctx) {
Type result = ooFactory().createRegularType(ctx.Identifier().getText());
InheritanceRelationContext inheritanceCtx = ctx.inheritanceRelation();
if(inheritanceCtx != null) {
result.addInheritanceRelation(visitInheritanceRelation(inheritanceCtx));
}
visitClassBody(ctx.classBody()).accept(((ClassWithBody)result).body());
for(ModifierContext m: ctx.modifier()) {
result.addModifier((Modifier)visit(m));
}
return processLayout(result,ctx);
}
示例14: isModifier
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
public boolean isModifier(Element element) {
return element instanceof Modifier;
}
示例15: toCodeClass
import org.aikodi.chameleon.core.modifier.Modifier; //导入依赖的package包/类
public String toCodeClass(Type type) {
final StringBuffer result = startLine();
//Modifiers
for(Modifier element:type.modifiers()) {
result.append((toCodeModifier((Modifier)element)));
result.append(" ");
}
//Name
result.append("class ");
result.append(type.name());
appendTypeParameters(type.parameters(TypeParameter.class), result);
List<SubtypeRelation> superTypes = type.explicitNonMemberInheritanceRelations(SubtypeRelation.class);
final List<TypeReference> classRefs = new ArrayList<TypeReference>();
final List<TypeReference> interfaceRefs = new ArrayList<TypeReference>();
for(SubtypeRelation relation:superTypes) {
TypeReference typeRef = relation.superClassReference();
if(relation.is(relation.language(Java7.class).IMPLEMENTS_RELATION) == Ternary.TRUE) {
interfaceRefs.add(typeRef);
} else {
classRefs.add(typeRef);
}
}
if(classRefs.size() > 0) {
result.append(" extends ");
result.append(toCode(classRefs.get(0)));
}
if(interfaceRefs.size() > 0) {
result.append(" implements ");
Iterator<TypeReference> iter = interfaceRefs.iterator();
while(iter.hasNext()) {
result.append(toCode(iter.next()));
if(iter.hasNext()) {
result.append(", ");
}
}
}
result.append(" ");
result.append(toCodeClassBlock(type));
return result.toString();
}