本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.PRIVATE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.PRIVATE屬性的具體用法?Java Modifier.PRIVATE怎麽用?Java Modifier.PRIVATE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.PRIVATE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: installLinkedVisibilityProposals
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) {
ASTNode modifier = findVisibilityModifier(modifiers);
if (modifier != null) {
int selected = ((Modifier) modifier).getKeyword().toFlagValue();
LinkedProposalPositionGroup positionGroup = linkedProposalModel.getPositionGroup(groupId, true);
positionGroup.addPosition(rewrite.track(modifier), false);
positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));
// add all others
int[] flagValues = inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
for (int i = 0; i < flagValues.length; i++) {
if (flagValues[i] != selected) {
positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
}
}
}
}
示例2: isHigherVisibility
/**
* Compares two visibilities.
*
* @param newVisibility the 'new' visibility
* @param oldVisibility the 'old' visibility
* @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
* @see Modifier#PUBLIC
* @see Modifier#PROTECTED
* @see Modifier#NONE
* @see Modifier#PRIVATE
*/
public static boolean isHigherVisibility(int newVisibility, int oldVisibility) {
assertVisibility(oldVisibility);
assertVisibility(newVisibility);
switch (oldVisibility) {
case Modifier.PRIVATE:
return newVisibility == Modifier.NONE
|| newVisibility == Modifier.PUBLIC
|| newVisibility == Modifier.PROTECTED;
case Modifier.NONE:
return newVisibility == Modifier.PUBLIC || newVisibility == Modifier.PROTECTED;
case Modifier.PROTECTED:
return newVisibility == Modifier.PUBLIC;
case Modifier.PUBLIC:
return false;
default:
Assert.isTrue(false);
return false;
}
}
示例3: PromoteTempToFieldRefactoring
/**
* Creates a new promote temp to field refactoring.
*
* @param unit the compilation unit, or <code>null</code> if invoked by scripting
* @param selectionStart start
* @param selectionLength length
*/
public PromoteTempToFieldRefactoring(
ICompilationUnit unit, int selectionStart, int selectionLength) {
Assert.isTrue(selectionStart >= 0);
Assert.isTrue(selectionLength >= 0);
fSelectionStart = selectionStart;
fSelectionLength = selectionLength;
fCu = unit;
fFieldName = ""; // $NON-NLS-1$
fVisibility = Modifier.PRIVATE;
fDeclareStatic = false;
fDeclareFinal = false;
fInitializeIn = INITIALIZE_IN_METHOD;
fLinkedProposalModel = null;
}
示例4: getVisibility
private Visibility getVisibility(int methodModifiers) {
Visibility visibility;
if ((methodModifiers & Modifier.PUBLIC) != 0)
visibility = Visibility.PUBLIC;
else if ((methodModifiers & Modifier.PROTECTED) != 0)
visibility = Visibility.PROTECTED;
else if ((methodModifiers & Modifier.PRIVATE) != 0)
visibility = Visibility.PRIVATE;
else
visibility = Visibility.PACKAGE;
return visibility;
}
示例5: getModifier
private static String getModifier(IBinding ib) {
if ((ib.getModifiers() & Modifier.PUBLIC) > 0)
return Fact.PUBLIC;
else if ((ib.getModifiers() & Modifier.PROTECTED) > 0)
return Fact.PROTECTED;
else if ((ib.getModifiers() & Modifier.PRIVATE) > 0)
return Fact.PRIVATE;
else
return Fact.PACKAGE;
}
示例6: evaluateFieldModifiers
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers= 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent= fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}
示例7: addDefaultConstructor
void addDefaultConstructor(
ITypeBinding type, List<BodyDeclaration> members, List<Statement> initStatements) {
int constructorModifier =
type.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
GeneratedMethodBinding binding = GeneratedMethodBinding.newConstructor(
type.getSuperclass(), constructorModifier);
initStatements.add(0, new SuperConstructorInvocation(binding));
members.add(createMethod(GeneratedMethodBinding.newConstructor(type, constructorModifier),
initStatements));
}
示例8: getVisibilityCode
public static int getVisibilityCode(String visibilityString) {
Assert.isNotNull(visibilityString);
if (VISIBILITY_STRING_PACKAGE.equals(visibilityString)) return 0;
else if (VISIBILITY_STRING_PRIVATE.equals(visibilityString)) return Modifier.PRIVATE;
else if (VISIBILITY_STRING_PROTECTED.equals(visibilityString)) return Modifier.PROTECTED;
else if (VISIBILITY_STRING_PUBLIC.equals(visibilityString)) return Modifier.PUBLIC;
return VISIBILITY_CODE_INVALID;
}
示例9: getVisibilityCode
public static int getVisibilityCode(BodyDeclaration bodyDeclaration) {
if (isPublic(bodyDeclaration)) return Modifier.PUBLIC;
else if (isProtected(bodyDeclaration)) return Modifier.PROTECTED;
else if (isPackageVisible(bodyDeclaration)) return Modifier.NONE;
else if (isPrivate(bodyDeclaration)) return Modifier.PRIVATE;
Assert.isTrue(false);
return VISIBILITY_CODE_INVALID;
}
示例10: isVisibilityModifier
/**
* Is the specified modifier a visibility modifier?
*
* @param modifier the keyword to test
* @return <code>true</code> if it is a visibility modifier, <code>false</code> otherwise
*/
private static boolean isVisibilityModifier(final int modifier) {
return modifier == Modifier.NONE
|| modifier == Modifier.PUBLIC
|| modifier == Modifier.PROTECTED
|| modifier == Modifier.PRIVATE;
}
示例11: checkVisibilityChanges
private RefactoringStatus checkVisibilityChanges() throws JavaModelException {
if (isVisibilitySameAsInitial()) return null;
if (fRippleMethods.length == 1) return null;
Assert.isTrue(JdtFlags.getVisibilityCode(fMethod) != Modifier.PRIVATE);
if (fVisibility == Modifier.PRIVATE)
return RefactoringStatus.createWarningStatus(
RefactoringCoreMessages.ChangeSignatureRefactoring_non_virtual);
return null;
}
示例12: getAccessModifier
private static int getAccessModifier(AbstractTypeDeclaration subclass) {
int modifiers = subclass.getModifiers();
if (Modifier.isPublic(modifiers)) return Modifier.PUBLIC;
else if (Modifier.isProtected(modifiers)) return Modifier.PROTECTED;
else if (Modifier.isPrivate(modifiers)) return Modifier.PRIVATE;
else return Modifier.NONE;
}
示例13: getAvailableVisibilities
public int[] getAvailableVisibilities() {
if (isLocalInnerType()) {
return new int[] {Modifier.NONE};
} else {
return new int[] {Modifier.PUBLIC, Modifier.PROTECTED, Modifier.NONE, Modifier.PRIVATE};
}
}
示例14: evaluateModifiers
private int evaluateModifiers(ASTNode targetTypeDecl) {
if (getSenderBinding().isAnnotation()) {
return 0;
}
if (getSenderBinding().isInterface()) {
// for interface and annotation members copy the modifiers from an existing field
MethodDeclaration[] methodDecls = ((TypeDeclaration) targetTypeDecl).getMethods();
if (methodDecls.length > 0) {
return methodDecls[0].getModifiers();
}
return 0;
}
ASTNode invocationNode = getInvocationNode();
if (invocationNode instanceof MethodInvocation) {
int modifiers = 0;
Expression expression = ((MethodInvocation) invocationNode).getExpression();
if (expression != null) {
if (expression instanceof Name
&& ((Name) expression).resolveBinding().getKind() == IBinding.TYPE) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(invocationNode)) {
modifiers |= Modifier.STATIC;
}
ASTNode node = ASTResolving.findParentType(invocationNode);
if (targetTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration
&& ASTNodes.isParent(node, targetTypeDecl)) {
modifiers |= Modifier.PROTECTED;
if (ASTResolving.isInStaticContext(node) && expression == null) {
modifiers |= Modifier.STATIC;
}
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}
return Modifier.PUBLIC;
}
示例15: evaluateFieldModifiers
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls = ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers = 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent = fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding = ((QualifiedName) parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node = ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}